You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Surrey Hughes <SH...@dws.com.au> on 2005/07/25 11:20:10 UTC
Tree2 expand Control problem when in a form
Hi,
I've found the x:tree2 tag creates an HtmlTree that contains a property called expandControl. The expand control is set as a new commandLink. It is rendered using an image of a plus or a minus and expands or collapses the node. The commandLink component renders a bunch of javascript or a url query string (depending on if you allow javascript in web.xml) that uses either the form containing the link or it creates a dummy form and submits that as part of its action. Now the problem with tree2 is that the expandControl commandLink has no parent as it is created as a property of the HtmlTree. That means during rending no form is detected even if the tree2 is in a form. As you could well imagine, that means if you are relying on the form fields to be submitted correctly when you expand or contract a server toggled tree you are out of luck.
The solution:
Well I guess I'd change tree2 so it creates a commandLink and sets the parent as the tree component.
But I didn't do that. Instead I created a PhaseListener that listend to the restore view phase where it recursively goes through the UIViewRoot and for each HtmlTree I set the expandControl parent to be the tree it is housed in.
This is an imperfect solution but at least I can get on with the rest of my app.
Yeah, it sent me insane and kept me back at work for many long hours.
I hope this helps someone else outthere. Also if anyone wants to fix the tree2 component then feel free :)
Surrey.