treeSelectionChangeListener didn’t work in richFaces 4.3.4 ?
222222 Jan 2, 2014 3:17 AMtest.xhtml
<rich:tree id="tree"
value="#{stations.getStationNodes()}"
var="node"
selectionType="ajax"
selectionChangeListener="#{stations.selectionChanged}">
<rich:treeSelectionChangeListener listener="#{stations.selectionChanged}"/>
</rich:tree>
stations
package stations;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.event.AbortProcessingException;
import org.richfaces.component.UITree;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.richfaces.event.TreeSelectionChangeListener;
import org.richfaces.model.TreeNode;
import my_tree.OptionTreeNode;
@ManagedBean(name = "stations")
@SessionScoped
@ViewScoped
public class Stations implements Serializable, TreeSelectionChangeListener{
private static final long serialVersionUID = 1L;
private OptionTreeNode stationRoot = new OptionTreeNode();
private OptionTreeNode stationNodes = new OptionTreeNode();
public OptionTreeNode getStationNodes() {
return stationNodes;
}
public Stations()
{
h();
}
private String[] kickRadioFeed = {
"Hall & Oates - Kiss On My List",
"David Bowie - Let's Dance",
"Lyn Collins - Think (About It)",
"Kim Carnes - Bette Davis Eyes",
"KC & the Sunshine Band - Give It Up" };
public void h()
{
//stationRoot.addChild(key, child);
stationRoot.setName("KickRadio");
stationNodes.addChild(0, stationRoot);
for (int i = 0; i < kickRadioFeed.length; i++)
{
OptionTreeNode child = new OptionTreeNode();
child.setName(kickRadioFeed[i]);
stationRoot.addChild(i, child);
}
}
//----------------------------
public void selectionChanged(TreeSelectionChangeEvent event)
{
//OptionTreeNode child = new OptionTreeNode();
//child.setName("**-->");
//stationRoot.addChild(0, child);
UITree tree = (UITree)event.getSource();
//System.out.println("**");
List<Object> selection = new ArrayList<Object>(event.getNewSelection());
Object currentSelectionKey = selection.get(0);
OptionTreeNode child = (OptionTreeNode)currentSelectionKey;
child.setName("**-->");
//stationRoot.addChild(0, child);
TreeNode currentSelection = (TreeNode) tree.getRowData();
currentSelection.addChild(0, child);
}
public void onClick()
{
OptionTreeNode child = new OptionTreeNode();
child.setName("**-->");
//stationRoot.addChild(0, child);
}
@Override
public void processTreeSelectionChange(TreeSelectionChangeEvent event)
throws AbortProcessingException {
// TODO Auto-generated method stub
System.out.println("change");
OptionTreeNode child = new OptionTreeNode();
child.setName("**-->");
}
}
(JBoss EAP 6.1)
not work
help