问题描述
这是动力节点王勇先生的drp项目,我想用s1sh改代码。在开发过程中,我碰到了在分销商这模块,在显示动态树的过程中,发觉无法显示树层。但一查调试后页面源文件,竟然发觉已经出现了d.add('',....),我纳闷了很久,始终无法解决.<divclass="dtree"><p><ahref="javascript:d.openAll();">openall</a>|<ahref="javascript:d.closeAll();">closeall</a></p><scripttype="text/javascript"><!--d=newdTree('d');d.add(0,-1,'终极分销商');<c:forEachitems="${areaList}"var="area"><c:choose><c:whentest="${area.parent==null}">d.add(${area.areaNo},0,'${area.name}','showArea_client_area_crud.do?method=showArea&areaId=${area.areaNo}','${area.name}','clientAreaCRUDFrame','../images/img/folder.gif','../images/img/folderopen.gif',true);</c:when><c:otherwise>d.add(${area.areaNo},${area.parent.areaNo},'${area.name}','showArea_client_area_crud.do?method=showArea&areaId=${area.areaNo}','${area.name}','clientAreaCRUDFrame','../images/img/folder.gif','../images/img/folderopen.gif',true);</c:otherwise></c:choose></c:forEach><c:forEachitems="${clientList}"var="client"varStatus="clientStatus"><c:iftest="${clientStatus.count>0}">d.add(${client.clientNo},${client.parentArea.areaNo},'${client.name}','basedata/showClient_client_crud.do?clientId=${client.clientNo}','${client.name}','clientAreaCRUDFrame','images/mytree/folder.gif','images/mytree/page.gif',true);</c:if></c:forEach>document.write(d);//--></script></div>只要我把上面代码第二个<c:foreach>内容删了就可以显示第一部分树层结构。第二个foreach是第一个foreach表的一对多关联表。其中model层代码如下:<classname="Area"table="t_area"lazy="false"><idname="areaNo"><columnname="areaNo"></column><generatorclass="assigned"/></id><propertyname="name"not-null="true"><columnname="name"></column></property><many-to-onename="parent"column="parentId"/><setname="son"lazy="extra"inverse="true"><keycolumn="parentId"/><one-to-manyclass="com.laocai.domain.model.Area"/></set><setname="sonAimClients"lazy="extra"inverse="true"><keycolumn="parentAreaId"/><one-to-manyclass="com.laocai.domain.model.Client"/></set></class>第二个foreach所指示的表<hibernate-mappingpackage="com.laocai.domain.model"><classname="Client"table="t_client"lazy="false"><idname="clientNo"length="50"><columnname="clientNo"></column><generatorclass="assigned"/></id><propertyname="name"not-null="true"length="100"><columnname="client_name"></column></property><propertyname="bankAcctNo"column="bank_acct_no"length="30"/><propertyname="contactTel"column="contact_tel"length="30"/><propertyname="address"column="address"length="300"></property><propertyname="zipCode"column="zip_code"length="30"></property><many-to-onename="parentArea"not-null="true"column="parentAreaId"update="false"/><many-to-onename="clientLevel"not-null="true"/></class></hibernate-mapping>
解决方案
解决方案二:
业务逻辑和dao层应该没问题。我就奇怪是第二个foreach内容一加入树形结构就显示不出了,但查看第二foreach我认为代码是没问题的。
解决方案三:
action的代码:protectedClientServiceclientService;protectedAreaServiceareaService;publicClientServicegetClientService(){returnclientService;}publicvoidsetClientService(ClientServiceclientService){this.clientService=clientService;}publicAreaServicegetAreaService(){returnareaService;}publicvoidsetAreaService(AreaServiceareaService){this.areaService=areaService;}publicActionForwardshowTree(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{List<Area>areaList=this.areaService.findAll();System.out.println("--------------show.areaList.size()----------------------------------"+areaList.size());request.setAttribute("areaList",areaList);List<Client>clientList=this.clientService.findAllClients();System.out.println("--------------show.clientList.size()----------------------------------"+clientList.size());request.setAttribute("clientList",clientList);returnmapping.findForward("showTree");}也已经打印出数据库list的size()大小。
解决方案四:
请路过的不管懂不懂的大哥大姐,请你们高抬贵手帮忙下小弟。分数有点低,确实不好意思,因为我是新手,分数有限。