Update OutputText element when node in Tree is selected.

UI Components for JSF
Post Reply
bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

14 Aug 2010, 22:15

Hi,

I am pretty new to Primefaces or JSF in general and have a question regarding updating elements.
Right now i have a filled tree from a database and what i need is when a treenode is selected within the tree that a outputText elswhere on the page gets updated with the nodeName of the selected node.
Is this possible?

Thanks
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

callahan
Posts: 768
Joined: 27 May 2010, 22:52

15 Aug 2010, 02:08

Hi,

Yes, this can be achieved with the trees instant ajax selection feature. There is an example here http://primefaces.org:8080/prime-showca ... onAjax.jsf. The example updates a growl, but with a few modifications it could update an outputText.

bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

15 Aug 2010, 09:52

Thanks, i followed that example. However what i do notice is that when i set update which references to a layoutUnit that the header of the layoutunit doens't get updated. When i set a update on a outputText it works but when i update the layoutUnit it doesnt work or at least i need to referesh my page to see the header of that layout unit with the right value. Is there a way i can make the layoutUnit's header value being updated when i select a node?
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

callahan
Posts: 768
Joined: 27 May 2010, 22:52

15 Aug 2010, 10:47

I've noticed that in the past myself too. When a layout unit is updated, only the content between <p:layoutUnit> and </p:layoutUnit> gets updated. This means that the header itself is not updated as the header is an attribute of the <p:layoutUnit>.

I assume that this restriction has something to do with interdependencies between layoutUnits. You always use at least two layoutUnits, and updating the attributes of one layoutUnit can effect another layoutUnit. For example, if you have a layout that's 400px high, with a top and center layoutUnit, and you update the height of the top layoutUnit using ajax, what should happen to the center layoutUnits height? To avoid problems here, only the content between <p:layoutUnit> and </p:layoutUnit> gets updated. At least this is what I've always assumed!

An unfortuante side-effect of this is that the header of a layoutUnit can't be updated using ajax.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests