奇怪的行为ui里面的树:重复或冰:panelseries

时间:2011-03-10 16:39:59

标签: jsf tree jsf-2 icefaces

所以我基本上在一个可折叠的内部有一个树,并且正在使用ui:repeat或ice:panelSeries进行迭代,因为它们几乎具有相同的结构

<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>

问题在于,当我展开或折叠面板时,给我一个可怕的错误就是堆栈:

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)

知道为什么它会像这样表现吗?

2 个答案:

答案 0 :(得分:0)

根据source#{panel.treeModel}评估为null。

尝试<ice:tree rendered="#{panel.treeModel != null} ...,看看会发生什么。

答案 1 :(得分:0)

可能是渲染时不会出现问题。在构建服务器端组件树时可能会发生这种情况。在这种情况下,您必须确保根本不解析xml标记<ice:tree../>

所以试试:

<c:if test="#{not empty panel.treeModel}"> <ice:tree ../> </c:if>

这并非在所有情况下都有效。所以试一试: - )