-
1. richfaces 4 <rich:tree> simple usage
ilya_shaikovsky Apr 21, 2011 8:52 AM (in response to dozerra)doh.. really that was missed during documentation review. TreeNode interface and TreeNodeImpl class not generic actually. Why was that done? Because we removed abstract field for node data from the default implementation. We decided to keep noly TreeNode interface logic default impl there. so it has no T field for user data anymore.
How to use it now? Still pretty simple. Just create your own class for TreeNode which will extend TreeNodeImpl and add only the data fields you need there with accessor methods. Then you will keep it just as simple as required according your data objects and will get all the node functionlity implemented by default.
-
2. richfaces 4 <rich:tree> simple usage
ilya_shaikovsky Apr 21, 2011 8:56 AM (in response to ilya_shaikovsky)b.t.w. thanks! docs will be corrected http://jira.jboss.org/browse/RFPL-1433
-
3. richfaces 4 <rich:tree> simple usage
dozerra Apr 21, 2011 9:08 AM (in response to ilya_shaikovsky)Thanks for your fast response. I hope the documentaton will be corrected so other poeple will benefit from this beautiful rich component dynamically. It is still not very clear how to set the name of the node but I will give it a try.
-
4. Re: richfaces 4 <rich:tree> simple usage
dozerra Apr 21, 2011 10:30 AM (in response to dozerra)I succeed creating the basic example of rich:tree. The only remark I have is that sometimes the tree nodes look like they are collapsible even if they don't have subnodes
Bellow is my code:
import org.richfaces.model.TreeNodeImpl; public class OptionTreeNode extends TreeNodeImpl { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String toString() { return this.name; } }
I needed to override toString() method because the reference of the class was displayed
public class OptionTree implements Serializable { private static final long serialVersionUID = 1L; private OptionTreeNode stationRoot = new OptionTreeNode(); private OptionTreeNode stationNodes = new OptionTreeNode(); public OptionTreeNode getStationNodes() { return stationNodes; } 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 OptionTree() { initRichFacesTree(); } private void initRichFacesTree() { stationRoot.setName("root"); stationNodes.addChild(0, stationRoot); for (int i = 0; i < kickRadioFeed.length; i++) { OptionTreeNode child = new OptionTreeNode(); child.setName(kickRadioFeed[i]); stationRoot.addChild(i, child); } } }
And my xhtml code
<rich:tree value="#{optionTree.getStationNodes()}" var="station" toggleType="client" > <rich:treeNode > <h:outputText value="#{station}" /> </rich:treeNode> </rich:tree>
The subnodes does not look like in the documentation.
-
5. Re: richfaces 4 <rich:tree> simple usage
ilya_shaikovsky Apr 21, 2011 10:33 AM (in response to dozerra)if you will review default impl org.richfaces.model.TreeNodeImpl you will see that isLeaf returns the property which is getting defined only in constructor and not looking the child component list size. default converter initializes the flag as true. and the tree makes decision about if the node is leaf accordgin to that.
That's done just in order to work with data in more "lazy" manner but require some actions from you. you could:
create a constructor with leaf boolean flag and call it in case of crteating leaf with true value. That constructor should call supor(leafFlag) before setting the other fields. And it should start work fine in your case.
or you could just overried isLeaf method simply checking if you have some nodes in child collection.
-
6. Re: richfaces 4 <rich:tree> simple usage
dozerra Apr 21, 2011 10:39 AM (in response to ilya_shaikovsky)Thanks ! I will make it like it should be
-
7. Re: richfaces 4 <rich:tree> simple usage
terratoch Jan 24, 2012 3:15 PM (in response to ilya_shaikovsky)This documentation 'bug' has kind of been around for almost a year now.
-
8. Re: richfaces 4 <rich:tree> simple usage
fftolentino May 30, 2014 1:18 AM (in response to terratoch)Hi
How did you resolve the missing setData() and getParent() method in TreeNodeImpl in RF4?
Thanks!
-
9. Re: richfaces 4 <rich:tree> simple usage
kkn Jun 10, 2015 3:16 AM (in response to dozerra)Hi,
Can you please explain the significance of keysList in TreeNodeImpl class.
Thank you!
-
10. Re: richfaces 4 <rich:tree> simple usage
michpetrov Jun 10, 2015 5:32 AM (in response to kkn)The keysList is used to create an iterator (and to keep the children ordered). What is unclear to you? I have to assume you've seen the code and where the variable is used. (And please don't revive old threads, chances are that people who created them are no longer around)
-
11. Re: richfaces 4 <rich:tree> simple usage
kkn Jun 10, 2015 12:34 PM (in response to michpetrov)Apologies for posting on old thread, I was not aware of that
Thank you for the reply! Certainly, I saw the class but just wanted to make sure that I am using it the correct way. Now I got the concept. Thank you again!