我正在使用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)
有谁知道为什么会这样?
删除 activeItem 属性并将 id 属性设置为 rich:accordion。为我工作。祝你好运!