Dynamic Tree state lost 3.0.M3-SNAPSHOT

UI Components for JSF
Post Reply
jwalgemoed
Posts: 18
Joined: 02 Nov 2010, 18:19

15 Jul 2011, 08:40

Hi,

I've been using primefaces 3.0 for testing purposes. I've been testing the tree component in particular. I am hoping to integrate this component in an existing JSF 2.0 application. Because I've already styled all my components and don't want to start styling primefaces buttons again I want to use this component with a plain old h:commandButton.

After submitting the form, the page rerenders and the tree collapses losing all its state. How can I prevent this? Snippet below:

Code: Select all

<h:form id="form" preprendId="false">
<table>
	<tr>
		<th>File locations</th>
	</tr>
	<tr>
		<td><p:tree value="#{treeController.root}" var="node" width="600px;"
			selectionMode="checkbox"
			selection="#{treeController.selectedNodes}" 
			propagateSelectionUp="true" propagateSelectionDown="true"
			id="tree" nodeExpandListener="#{treeController.onNodeExpand}"
			dynamic="true" cache="true">

			<p:treeNode>
				<h:outputText value="#{node.getName()}" />
			</p:treeNode>
		</p:tree> </td>
	</tr>
	<tr>
		<td><h:commandButton action="#{treeController.save}" value="Save"> <p:ajax event="action" process="@form" update="@form" /></h:commandButton></td>
	</tr>
</table>
</h:form>
I've tried all combinations listed below, with the same results:

Code: Select all

<td><h:commandButton action="#{treeController.save}" value="Save"><f:ajax render="@form" execute="@form" /></h:commandButton></td>

Code: Select all

<td><p:commandButton action="#{treeController.save}" value="Save" update="@form"></p:commandButton></td>
I would really like to use the tree and specifically with <h:commandButton>. I can use either p:ajax or f:ajax. I'd rather not use the p:commandbutton because I don't want to have to edit the style for these buttons. I already have button styling in place for h:commandbuttons, and want to keep using that.

Is this a known bug for dynamic trees? How can I submit the form while keeping tree state at the same time?

Any help greatly appreciated!

Jarno

hame
Posts: 3
Joined: 30 Jun 2011, 14:28

15 Jul 2011, 09:30

I think I saw something similar with dynamic="true", if you by "loosing state" means that your tree expansions and selections are not reflected in the rendering after update (the whole tree is collapsed). Changing dynamic to false on the <p:tree/> fixed that for me.

jwalgemoed
Posts: 18
Joined: 02 Nov 2010, 18:19

15 Jul 2011, 12:18

I understand what you mean, but this is in fact a dynamic tree. On expanding a node, the subnodes for that particular node are loaded. After loading they are added to the tree. This works in 3.0.M1, but from 3.0.M2 onwards it stopped working. The tree collapses and new nodes are not rendered, even though they are loaded (I can see this happening when debugging).

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Jul 2011, 12:21

I've replicated this as well, an issue ticket seems necessary.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests