I am trying to update the content of PrimeFaces <p:layoutUnit> on <p:tree> node selection. However, when I select a node, the content does not change. When I refresh the page I see that the content is changed.
How can I change the content without refreshing the whole page?
My view code is:
<h:body>
<h:form id="form">
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" resizable="false" closable="false" collapsible="false">
<h:outputText value="Top" />
</p:layoutUnit>
<p:layoutUnit position="south" size="100" resizable="flase" closable="false" collapsible="false">
<h:outputText value="Bottom" />
</p:layoutUnit>
<p:layoutUnit position="west" size="250" header="Tree" resizable="true" closable="flase" collapsible="true">
<p:tree id="tree" value="#{treeBean.root}" selection="#{treeBean.selectedNode}" var="node" selectionMode="single" dynamic="true" cache="false" >
<p:ajax listener="#{treeBean.onNodeSelect}" update="test" event="select"/>
<p:treeNode>
<h:outputText value="#{node}"/>
</p:treeNode>
</p:tree>
</p:layoutUnit>
<p:layoutUnit position="center" id="test">
<ui:include src="${treeBean.selectedNode.name}.xhtml"/>
</p:layoutUnit>
</p:layout>
</h:form>
</h:body>
First, you should not put the layout-units inside form, instead put forms inside layout-units.
Another problem is that you have nested forms, you should not have nested forms.
Your form
<h:form id="from"is at the wrong spot. You should move it inside<p:layoutUnit position="west":Also consider using a
h:panelGroupinstead of<h:form id="myForm"and update the panelgroup, because you don’t need thath:formthere:And update that panelgroup: