Code: Select all
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<ui:insert name="headIncludes" />
</h:head>
<h:body>
<h:form id="testForm">
<p:tabView id="myTabView" dynamic="true">
<p:tab title="Tab One" id="tabOne">
<h:panelGroup id="tabOneGroup">
<p:commandLink id="linkX" value="Link X" actionListener="#{sandboxBean.testCommandLinkx}" >
<f:ajax />
</p:commandLink>
</h:panelGroup>
</p:tab>
<p:tab title="Tab Two" id="tabTwo">
<h:panelGroup id="tabTwoGroup">
<p:commandLink id="linkY" value="Link Y" actionListener="#{sandboxBean.testCommandLinky}" >
<f:ajax />
</p:commandLink>
</h:panelGroup>
</p:tab>
</p:tabView>
</h:form>
</h:body>
</html>
When we switch to Tab Two, an ajax request is made and during this another UIComponent representing linkY is created the same way and persisted. However, when we actually click on the commandlink and try to retrieve the actionListener attribute value, we find that there is no such attribute. We instead receive an entirely new object.
If we change to dynamic="false" for the tabView, both commandlinks are created and persisted during the initial page request and everything works fine. If we keep dynamic="true" but use a h:commandLink instead of a p:commandLink, everything also works fine.
Now, I don't really think this is a primefaces bug, as if it was tons of other people would have noted it too. Other people have also tested this particular code fragment without issues. For the same reason I doubt this is a webflow bug. It seems more likely to be a configuration error in our project but I have no idea where. It seems a bit lengthy to include every single configuration file but if you want to see the contents of one just comment and I will add it.
As for versions of different components as people will undoubtedly ask:
- Primefaces: 3.0.1 and all later versions for dynamic tabViews (as this was the first version to support it for real) but it's possible to recreate it in earlier versions if you use another construct that instantiates components in ajax requests.
- Mojarra: 2.0.4 (but I have also tried 2.0.8 and 2.1.6 without improvement)
- Spring Webflow: 2.2.1 (have also tried 2.3)
- Tomcat: 7.0.12 (have tried various other also)
EDIT: This is fixed in Spring Webflow 2.3.1