File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes treenode with all sub-nodes automatically selected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "treenode with all sub-nodes automatically selected" Watch "treenode with all sub-nodes automatically selected" New topic
Author

treenode with all sub-nodes automatically selected

Cedric Chaveriat
Greenhorn

Joined: Feb 12, 2013
Posts: 2
Hello,

I'm a beginner in jsf

I have scientific data with tree organization it could be ecosystems, species, keywords...

aquatic
> freshwater
> marine
terrestrial
> forest
> mountain
...

for searching in a database I want allow user to select nodes in a treenode
I'm using <rich:treeNode> and it works

<rich:treeNode icon="images/branch.gif" iconLeaf="images/blank.gif" reRender="listeEcosystemNodes" >
<h:selectBooleanCheckbox value="#{searchLabsBean.checkMapEcosystem[item]}">
<a4j:support event="onclick" action="#{searchLabsBean.getSelectedEcosystem}" reRender="listeEcosystemNodes"/>
</h:selectBooleanCheckbox> 
<hutputText value="#{item}" />
</rich:treeNode>

with :
private Map<String,Boolean> checkMapEcosystem = new HashMap<String,Boolean>();
in SearchLabsBean

( getSelectedEcosystem is a method for append selected ecosystems in a String, it's just a feedback for the user )

BUT I want that if a user select aquatic for example, then freshwater and marine will be automatically selected ant not only the direct child but all the nodes under aquatic
AND if a user unselected a node all this sub-nodes will be unselected too

I want a solution with the graphical component how can I get child nodes of the selected node from the <rich:treeNode> and (un)select them ?
If <rich:treeNode> couldn't work, are they other components that could do the job ?

thank you for your help
Cedric Chaveriat
Greenhorn

Joined: Feb 12, 2013
Posts: 2
I forget something

<rich:tree style="margin: 10px; width:700px" binding="#{searchLabosBean.ecosystemTreeBinding}" value="#{searchLabosBean.ecosystemTreeNode}" var="item" ajaxKeys="#{null}" >
<rich:treeNode icon="images/branch.gif" iconLeaf="images/blank.gif" reRender="listeEcosystemNodes" >
<h:selectBooleanCheckbox value="#{searchLabsBean.checkMapEcosystem[item]}">
<a4j:support event="onclick" action="#{searchLabsBean.getSelectedEcosystem}" reRender="listeEcosystemNodes"/>
</h:selectBooleanCheckbox> 
<hutputText value="#{item}" />
</rich:treeNode>
</rich:tree>

class SearchLabsBean
private org.richfaces.component.UITree ecosystemTreeBinding ;
private static org.richfaces.model.TreeNode ecosystemTreeNode ;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: treenode with all sub-nodes automatically selected