Weird behaviour Tree inside ui:repeat or ice:panelseries
So i basicly have a tree inside a collapsible and is iterating with a ui:repeat or ice:panelSeries because they pretty much have the same structure
<ui:repeat value="#{navigationBean.navigationPanels}" var="panel" >
<ice:panelCollapsible immediate="true" expanded="#{panel.expanded}" >
<f:facet name="header">
<ice:panelGroup>
<ice:outputText value="#{panel.title}" />
</ice:panelGroup>
</f:facet>
<ice:panelGroup styleClass="treeContainer">
<ice:tree id="tree" value="#{panel.treeModel}" var="item"
hideRootNode="true" hideNavigation="true"
imageDir="#{facesContext.externalContext.requestContextPath}/xmlhttp/css/xp/css-images/">
<ice:treeNode>
<f:facet name="icon">
<ice:panelGroup style="display: inline">
<h:graphicImage
开发者_运维技巧 value="#{userPreferences.imageDirectory}/#{item.userObject.icon}" />
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:panelGroup style="display: inline">
<ice:outputLink value="#{item.userObject.url}">
<ice:outputText styleClass="treeNode" value="#{item.userObject.text}" />
</ice:outputLink>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
</ice:panelGroup>
</ice:panelCollapsible>
</ui:repeat>
The problem is that when i expand or collapse the panel gives me an awful error here is the stack:
java.lang.NullPointerException
at com.icesoft.faces.component.tree.Tree.visitRows(Tree.java:1447)
at com.icesoft.faces.component.tree.Tree.visitTree(Tree.java:1402)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at com.sun.faces.facelets.component.UIRepeat.visitTree(UIRepeat.java:606)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at javax.faces.component.UIForm.visitTree(UIForm.java:331)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:258)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Any idea why it could be behaving like this??
According to the source, #{panel.treeModel}
evaluates to null.
Try <ice:tree rendered="#{panel.treeModel != null} ...
, and see what happens.
It could be that the the problem does not occur at rendering. It could occur while building the server side component tree. On such cases you have to make sure that the xml tag <ice:tree../>
is not parsed at all.
So try:
<c:if test="#{not empty panel.treeModel}"> <ice:tree ../> </c:if>
This is not working in all cases. So give it a try :-)
精彩评论