sax解析xml,《传对象》 传到前台,不能点击的置灰

置灰的disable=“disabled”   disable=“true”(不可以点击操作)disable=“”false“(可以点击操作)

》》》》》》》》》》》action

package com.ths.projects.xzxk.web.syssb.wysb;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ths.platform.custom.action.BaseAction;
import com.ths.platform.custom.util.res.Path;
import com.ths.projects.xzxk.web.syssb.wysb.model.XCell;
import com.ths.projects.xzxk.web.syssb.wysb.model.XRow;

public class WysbAction extends BaseAction {
 private static final Logger log = LoggerFactory.getLogger(WysbAction.class);

 private String xmlname;

 private ArrayList<XRow> rows = new ArrayList<XRow>();

 /**
  * 我要申报主页面
  */
 public String mainlist() {

  // 创建解析器
  SAXReader xmlReader = new SAXReader();
  // 创建集合类型

  try {
   // 获取xml路径
   String xmlpath = (Path.ROOT
     + "WEB-INF/conf/res/masterplate/"
     + com.ths.platform.custom.util.res.ResInfo
       .getResValue("masterplate") + "/sb/" + xmlname + ".xml")
     .replace("/", File.separator);
   Document doc = xmlReader.read(xmlpath);
   // 把xml加载到document对象中
   Element myRoot = doc.getRootElement();
   // 按照树的思想进行解析
   Element ele_ttable = myRoot.element("table");
   // 得到下一级元素集合
   List<Element> ele_trows = ele_ttable.elements();
   // 循环遍历

   for (int i = 0; i < ele_trows.size(); i++) {
    // 获取table的key ,value
    Element trow = ele_trows.get(i);
    XRow xrow = new XRow();
    xrow.setTitle(trow.attributeValue("title"));
    // 获取cell的key ,value
    List<Element> ele_tcells = trow.elements();
    for (int j = 0; j < ele_tcells.size(); j++) {
     Element ele_cell = ele_tcells.get(j);
     String key = ele_cell.attributeValue("key");
     String name = ele_cell.attributeValue("name");
     String url = ele_cell.attributeValue("url");
     String disable = ele_cell.attributeValue("disable");
     XCell xcell = new XCell(key, name, url, disable);
     xrow.addCell(xcell);
    }
    rows.add(xrow);
   }
  } catch (DocumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

  return "wysbmain_list";
 }

 /**
  * @return the xmlname
  */
 public String getXmlname() {
  return xmlname;
 }

 /**
  * @param xmlname
  *            the xmlname to set
  */
 public void setXmlname(String xmlname) {
  this.xmlname = xmlname;
 }

 public ArrayList<XRow> getRows() {
  return rows;
 }

 public void setRows(ArrayList<XRow> rows) {
  this.rows = rows;
 }

}

》》》》》》》》》》》》xml

<?xml version="1.0" encoding="utf-8"?>

<root>
  <show time_step="" time_unit="">
    <param>
     <replace format="request" name="companyid" place="companyid"/>
     <replace format="request" name="id" place="id"/>
     <replace format="request" name="belongsdate" place="belongsdate"/>
     <replace format="request" name="intact" place="intact"/>
        <replace format="sql"     name="" datasource=""  place="newid"/>
    </param>
  </show>
  <table>
     <row title="建设项目环境影响评价文件审批">
    <cell  key="card11"  name="办事指南" url="../../syssb/wysb/hpsp/hpsp!guid.action"  disable="disabled"/>
    <cell  key="card12"  name="表格下载" url="../../syssb/wysb/hpsp/hpsp!regist.action"  disable="disabled"/> 
    <cell  key="card13"  name="在线申报" url="zxtb('cf-hpsp','阅读办事指南','card1')"  disable="ture"/>
    <cell key="card14" name="状态查询" url="../../syssb/wysb/hpsp/hpsp!registCon.action" disable="disabled" /> 
   </row>
   <row title="建设项目试生产试运行审批">
    <cell  key="card21"  name="办事指南" url="../../syssb/wysb/hpsp/hpsp!guid.action"  disable="disabled"/>
    <cell  key="card22"  name="表格下载" url="../../syssb/wysb/hpsp/hpsp!apply.action"  disable="disabled"/>
    <cell  key="card23"  name="在线申报" url="zxtb('cf-hpsp','阅读办事指南','card1')"  disable="false"/>
    <cell  key="card24"  name="状态查询" url="../../syssb/wysb/hpsp/hpsp!registCon.action"   disable="disabled"/>
   </row>
   <row title="建设项目竣工环境保护验收审批">
    <cell  key="card31"  name="办事指南" url="../../syssb/wysb/hpsp/hpsp!guid.action"  disable="disabled"/>
    <cell  key="card32"  name="表格下载" url="../../syssb/wysb/hpsp/hpsp!apply.action"   disable="disabled"/>
    <cell  key="card33"  name="在线申报" url="zxtb('cf-hpsp','阅读办事指南','card1')"  disable="false"/>
    <cell  key="card34"  name="状态查询" url="../../syssb/wysb/hpsp/hpsp!registCon.action"  disable="disabled"/>
   </row>
    <row title="其他管理事项审批">
    <cell  key="card41"  name="办事指南" url="../../syssb/wysb/hpsp/hpsp!guid.action" disable="disabled"/>
    <cell  key="card42"  name="表格下载" url="../../syssb/wysb/hpsp/hpsp!apply.action"  disable="disabled"/>
    <cell  key="card43"  name="在线申报" url="zxtb('cf-hpsp','阅读办事指南','card1')"  disable="false"/>
    <cell  key="card44"  name="状态查询" url="../../syssb/wysb/hpsp/hpsp!registCon.action"  disable="disabled"/>
   </row>
  </table> 
</root>

》》》》》》》jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>办事指南</title>
<!--[if lte IE 7]>
<style>
.content { margin-right: -1px; }
ul.nav a { zoom: 1; }
</style>
<![endif]-->
<%@ include file="/thscommon/jsp/taglibsforform.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx }/util/xzxk/css/xzxk_style.css" />
<script type="text/javascript">
function zxtb(cardtype,nodeid,cursel){
 $("#state").val(nodeid);
 $("#cardtype").val(cardtype);
 $("#cursel").val(cursel);
 document.all.jumpform.action="${ctx}/common/itemcard/item-card!itemcardmain.action";
 document.all.jumpform.submit();
 //window.open('${ctx}/common/itemcard/item-card!itemcardmain.action?state=申报1&cardtype='+cardtype,'itemcardmain','height=600px,width=1100px,top=36px,left=100px,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');
}

</script>
</head>

<body>
<br>
 <s:iterator value="rows" var="rows">  
     <div class="button-div">
      <div class="list-title"><span><img src="${ctx }/util/xzxk/images/title.png"/></span><s:property value="#rows.title"/> </div>
      <ul>
      <s:iterator value="#rows.cells" var="cell"  status="status">  
       <s:if test="#status.last"> 
             <li  class="li-last" οnclick="<s:property value="#cell.url"/>" ><span <s:property value="#cell.disable"/>><s:property value="#cell.name"/></span></li> 
       </s:if>
       <s:else>
             <li οnclick="<s:property value="#cell.url"/>"   ><span <s:property value="#cell.disable"/>><s:property value="#cell.name"/></span></li> 
       </s:else>
       </s:iterator> 
      
        <div class="clearfloat"></div>
      </ul>
  </div>
 </s:iterator> 
<form action="" target="_blank" method="post"  id="jumpform" name="jumpform">
  <input name="state" id="state" type="hidden" value=""/>
  <input name="cardtype" id="cardtype" type="hidden" value=""/>
  <input name="cursel" id="cursel" type="hidden" value=""/>
</form>
</body>
</html>

》》》》》》》class

package com.ths.projects.xzxk.web.syssb.wysb.model;

public class XCell {

 private String key;
 private String name;
 private String url;
 private String disable;
 
 public XCell() {
  super();
  // TODO Auto-generated constructor stub
 }
 
 public XCell(String key, String name, String url, String disable) {
  super();
  this.key = key;
  this.name = name;
  this.url = url;
  this.disable = disable;
 }

 public String getKey() {
  return key;
 }
 public void setKey(String key) {
  this.key = key;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getUrl() {
  return url;
 }
 public void setUrl(String url) {
  this.url = url;
 }
 public String getDisable() {
  return disable;
 }
 public void setDisable(String disable) {
  this.disable = disable;
 }
 


}

》》》》》》》》》》》》》》class

package com.ths.projects.xzxk.web.syssb.wysb.model;

import java.util.ArrayList;

public class XRow {

 private String title;
 private ArrayList<XCell> cells;
 
 
 public XRow() {
  super();
  // TODO Auto-generated constructor stub
 }
 public String getTitle() {
  return title;
 }
 public void setTitle(String title) {
  this.title = title;
 }
 
 public ArrayList<XCell> getCells() {
  return cells;
 }
 public void setCells(ArrayList<XCell> cells) {
  this.cells = cells;
 }
 public void addCell(XCell cell) {
  if(this.cells==null){
   this.cells = new ArrayList<XCell>();
  }
  this.cells.add(cell);
 }
 
 
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值