RF4/rich:tabPanel: adding tabs dynamically --> NPE
ovesper Apr 30, 2011 2:11 AMHi folks,
I am using a rich:tabPanel with switchType="server" where the rich:tab elements are dynamic - meaning they are backed by a bean. The XHTML looks like this:
{code:xml}<h:form id="majorForm" prependId="true">
<rich:tabPanel id="majorTabPanel" width="40%" headerAlignment="left" switchType="server">
<c:forEach items="#{tabService.dynamicTabs}" var="tab">
<rich:tab header="foo">
<h:outputText value="bar"/>
</rich:tab>
</c:forEach>
</rich:tabPanel>
</h:form>{code}
Somewhere else on the page I've got a link which adds further tabs to the tabPanel:
{code:xml}<h:commandLink>
<h:graphicImage value="images/foo.png" />
<a4j:ajax event="click" render=":majorForm:majorTabPanel" listener="#{tabService.addTab()}"/>
</h:commandLink>{code}
Clicking on the link causes the tabService to add another item to its list "dynamicTabs". Afterwards the tab-panel is rendered and a new tab shows up. It is possible to switch to the new tab. So far everything works fine.
Now I switch back to any another tab (or even re-selecting this currently shown new tab) and it results in a NullPointerException:
java.lang.NullPointerException
at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:64)
at org.richfaces.component.AbstractTogglePanel.getActiveItemValue(AbstractTogglePanel.java:477)
at org.richfaces.component.AbstractTogglePanel.processDecodes(AbstractTogglePanel.java:210)
at javax.faces.component.UIForm.processDecodes(UIForm.java:212)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:920)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:74)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
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:324)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
at java.lang.Thread.run(Thread.java:662)
Any idea what is going wrong?
Thanks in advance for your support,
Oliver
p.s. for the sake of completeness:
- my backing bean is annotated with @ViewScoped
- my app is running on JBoss AS 6.0 using Mojarra 2.0.3-b05