This is an xhtml document which reproduces the problem:
<tr:document xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad">
<f:loadBundle basename="labels" var="labels" />
<tr:form id="titolare_form">
<tr:messages styleClass="jsf_messages" />
<tr:selectOneChoice id="myList" value="#{treeTest.selectedId}"
autoSubmit="true" immediate="true" valuePassThru="true"
valueChangeListener="#{treeTest.change}">
<f:selectItems value="#{treeTest.selectItems}"/>
</tr:selectOneChoice>
<tr:tree var="descritorre" value="#{treeTest.model}"
partialTriggers="myList">
<f:facet name="nodeStamp">
<tr:selectBooleanCheckbox selected="#{descritorre.selected}"
text="#{descritorre.desMattone}" />
</f:facet>
</tr:tree>
</tr:form>
</tr:document>
And this is the Java bean, in session scope:
package it.eng.sis.mra.test;
import it.eng.sis.mra.beans.jsf.TpDescritorreNode;
import java.util.ArrayList;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
import org.apache.myfaces.trinidad.model.TreeModel;
public class TreeTest
{
private TreeModel model;
private List<TpDescritorreNode> nodes;
private List selectItems;
private String selectedId;
public void change(ValueChangeEvent vce)
{
System.out.println("here");
boolean select = true;
if(vce.getNewValue().equals("1"))
select = false;
TpDescritorreNode node = nodes.get(0);
node.setSelected(select);
for(TpDescritorreNode n: node.getChildNodes())
n.setSelected(select);
FacesContext.getCurrentInstance().renderResponse();
}
public TreeTest()
{
nodes = new ArrayList<TpDescritorreNode>();
List children = new ArrayList();
TpDescritorreNode node = new TpDescritorreNode();
node.setDesMattone("child 1");
children.add(node);
node = new TpDescritorreNode();
node.setDesMattone("child 2");
children.add(node);
node = new TpDescritorreNode();
node.setDesMattone("child 3");
children.add(node);
node = new TpDescritorreNode();
node.setDesMattone("parent");
node.setChildNodes(children);
nodes.add(node);
model = new ChildPropertyTreeModel(nodes, "childNodes");
selectItems = new ArrayList();
selectItems.add(new SelectItem("1", "one"));
selectItems.add(new SelectItem("2", "two"));
}
public TreeModel getModel()
{
return model;
}
public List getSelectItems()
{
return selectItems;
}
public String getSelectedId()
{
return selectedId;
}
public void setSelectedId(String selectedId)
{
this.selectedId = selectedId;
}
}
On Mon, Apr 12, 2010 at 6:44 PM, Scott McMasters
<[email protected]>wrote:
> Hello,
>
> I'm using the tree component with ppr, but if a branch is already expanded
> and a trigger is assigned to a select list in the form, the nodes don't
> update. Can someone give me an example how to update the tree nodes
> properly? Each node is a checkbox.
>
> Maybe to explain better, when the user changes the value in the select list
> element, the selected nodes in the tree should change. The values in my
> node objects are being updated, but that's not being reflected in the page
> if the node is visible. If the branch is collapsed, I change the select
> list value and expand the branch, the changes are reflected in the page.
>
> Thanks,
>
> Scott McMasters
>
>