I have two primefaces (p:layoutUnit) widgets: a tree in the layoutUnit on the left of my page and and a dataArea (to be decided on) in the layoutUnit in the center of my page. I have the tree menu working so that when a node is selected, the appropriate DAO method is called and the object(s) is(are) returned. My trouble is, is that the object is returned to the tree’s form on the left of the page.
My question is: how can I get the returned object(s) to populate in the center of my page? Is there a JSF mechanism to do this?
You can leverage the select event of the
<p:tree>component to issue an ajax call that will update the dataArea of your page based on the selected node:For example:
In onNodeSelect, you’ll populate an instance variable on your controller with the value(s) you want to show in dataArea. Setting the update attribute to “form2:dataArea” will cause the page to update the dataArea to the latest state (and pick up the data you’ve placed in the instance variable). Note that “form2:dataArea” is just a guess as to what your second form id and dataArea’s id are labeled as.