Reputation: 961
Hi I have been beating my head all day with this issue and I am not sure what to do about it and I am hoping someone in this forum can help me.
When I render a standalone page with a dataTable element, all Ajax functionality works: Sorting, Navigation, etc.
But when I include the same page with the dataTable element inside another page via the "ui:include" tag, the table renders but all Ajax functionality is lost.
Here is the code for my "p:dataTable" page:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:dataTable id="dataTable"
var="alarm"
value="#{alarmsBean.alarms}"
paginator="true" rows="10"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink}"
paginatorPosition="bottom">
<f:facet name="header">
Alarms
</f:facet>
<p:column id="deviceHeader" sortBy="#{alarm.device}">
<f:facet name="header">
<h:outputText value="Device" />
</f:facet>
<h:outputText value="#{alarm.device}" />
</p:column>
<p:column sortBy="#{alarm.alarm}">
<f:facet name="header">
<h:outputText value="Alarm" />
</f:facet>
<h:outputText value="#{alarm.alarm}" />
</p:column>
<p:column sortBy="#{alarm.managedObject}">
<f:facet name="header">
<h:outputText value="Managed Object" />
</f:facet>
<h:outputText value="#{alarm.managedObject}" />
</p:column>
<p:column sortBy="#{alarm.alarmTime}">
<f:facet name="header">
<h:outputText value="Alarm Time" />
</f:facet>
<h:outputText value="#{alarm.alarmTime}" />
</p:column>
<p:column sortBy="#{alarm.severity}">
<f:facet name="header">
<h:outputText value="Severity" />
</f:facet>
<h:outputText value="#{alarm.severity}" />
</p:column>
<p:column sortBy="#{alarm.message}">
<f:facet name="header">
<h:outputText value="Message" />
</f:facet>
<h:outputText value="#{alarm.message}" />
</p:column>
</p:dataTable>
</ui:composition>
And here is the section of the other page that includes that page:
<h:form id="mainF">
<pe:layoutPane id="center" position="center">
<h:panelGroup id="centerContent">
<ui:include src="#{navigationBean.pageName}.xhtml" />
</h:panelGroup>
</pe:layoutPane>
</h:form>
What am I doing wrong or is this a bug in PrimeFaces 3.3?
Upvotes: 3
Views: 2254
Reputation: 1108722
<ui:include src="#{navigationBean.pageName}.xhtml" />
You need to make sure that #{navigationBean.pageName}
returns exactly the same value during processing the (ajax) form submit as it was when the initial page was displayed. If this is not the case, then JSF won't be able to find the input and command components involved in the (ajax) form submit.
So if that value depends on a request based parameter/variable, then you need to make sure that this request parameter/variable is preserved across form submits and available during bean's (post)construction. You can achieve that by passing it as <f:param>
in the command buttons and setting it as @ManagedProperty
. Note that placing the bean in the view scope won't work as the <ui:include src>
as being a view build time tag gets its own brand new instance. You would need to turn off the partial state saving or to upgrade to JSF 2.2.
Upvotes: 2