This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Is it possible to use List<java Object> and bind it to my rich:tree rather than List<Sring>? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Is it possible to use List<java Object> and bind it to my rich:tree rather than List<Sring>?" Watch "Is it possible to use List<java Object> and bind it to my rich:tree rather than List<Sring>?" New topic
Author

Is it possible to use List<java Object> and bind it to my rich:tree rather than List<Sring>?

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

There is one main question here, and then others that are followups depending on the answer to this, so I will ask the big question first -

Is it possible to use Collections that are loaded with java Objects rather than String variables to bind to my rich:tree? I know I can bind a List loaded with String values to my tree and have it display, but can I use a List that is loaded with java Objects and have it also display a tree somehow?

If you don't understand what I am trying to ask just read on

I have been looking at various things, and so far all I have been able to get to display a tree is a List full of String values.

Now if I load this List with the actual java Object itself, including all the variables within that Object of course, where the tree should be is a blank space. There may be a problem with how I am doing my rich:tree tag attributes and such so my first question is - if I have a List loaded with java Objects, and those Objects have two String variables - name and device, is there a way to bind this List to a rich:tree, and have it use the name String variable as the root and the device String variable as the nodes under each root? I have tried many variations but there are just so many different ways to try this I figured it would be better to ask here and hope someone answers.

And, if that is not possible, I was also looking at the TreeNodeImple data type. Now in the examples I have seen it uses String values like this:




but is it possible to replace String with my Project Object and still have that work (like I have been trying to do with List), like this:



And if so, then the same question I had for the List data type, how can I bind this to the rich:tree correctly so it uses the name String variable from Project as the root and the device String variable as the node?

But all this hinges on the question, is it possible to use Collections loaded with Objects rather than Strings as the variable I bind to the rich:tree?


edit - here is an idea of how I have been trying to bind this stuff to my jsf page (projectTreeNode is a TreeNodeImpl data type):



True wisdom is in knowing you know nothing - Socrates
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
I have not used rich:tree, but I am doing a similar thing with rich:dataTable. So long as the <Object> has explicit getters and setters, it will simply work. So in your example, "Project" would need to have a public "getName()" and "getDevice()".

What you cannot seem to do is pass parameters into the EL #{project.value('something')}. There may be a way around this, but I have not needed to investigate it.

J.


SCJP6
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Well if it is possible, then the problem is how I am binding it to the rich:tree tag. I will just have to keep trying different variations till it works I guess
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to use List<java Object> and bind it to my rich:tree rather than List<Sring>?
 
Similar Threads
really need some help here concerning treeNode data types and the like. (data type issues really)
Advice on Object data types to use for the rich:tree I am trying to create
Does TreeNode hold multiple values?
Rich:tree and managing expand/collapse from first load
Is a Map data type that holds three objects possible?