Richfaces嵌套手风琴中的空指针异常

时间:2013-01-29 10:40:40

标签: jsf jsf-2 richfaces

我正在使用Richfaces 4.2.2,我尝试使用相同的方法实现嵌套的手风琴。相同的Facelet代码如下:

<h:form id="accordForm">
    <rich:accordion switchType="client" activeItem="#{projectCreation.activeTab}">
        <c:forEach var="proj" items="#{projectCreation.projects}">
            <rich:accordionItem name="#{proj.description}">
                <f:facet name="header">#{proj.description}</f:facet>
                <h:form>
                    <rich:accordion switchType="client" activeItem="#{projectCreation.activeModuleTab}" rendered="#{proj.modules[0]!=null}">
                        <c:forEach var="mdle" items="#{proj.modules}">
                            <rich:accordionItem name="#{mdle.description}">
                                <f:facet name="header">#{mdle.description}</f:facet>
                                <t:dataList var="subMdle" value="#{mdle.subModules}" layout="unorderedList">
                                    <h:outputText value="#{subMdle.description}"></h:outputText>
                                </t:dataList>
                            </rich:accordionItem>
                        </c:forEach>
                    </rich:accordion>
                </h:form>
            </rich:accordionItem>
        </c:forEach>
    </rich:accordion>
</h:form>

但是我得到NullPointerException,错误日志如下:

java.lang.NullPointerException
    org.richfaces.component.AbstractAccordion.getActiveItem(AbstractAccordion.java:66)
    org.richfaces.component.AbstractTogglePanel.encodeBegin(AbstractTogglePanel.java:166)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1777)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
    org.richfaces.renderkit.html.TogglePanelItemRenderer.doEncodeChildren(TogglePanelItemRenderer.java:136)
    org.richfaces.renderkit.html.AccordionItemRenderer.doEncodeChildren(AccordionItemRenderer.java:93)
    org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:157)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
    org.richfaces.renderkit.html.TogglePanelRenderer.doEncodeChildren(TogglePanelRenderer.java:127)
    org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:157)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
    javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
    com.hcl.common.filter.MySessionFilter.doFilter(MySessionFilter.java:90)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

有谁知道为什么会这样?

1 个答案:

答案 0 :(得分:0)

删除activeItem属性并将id属性设置为rich:accordion。为我工作。祝你好运!