-
1. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 3:31 AM (in response to meghiddo)here is an idea of how I have been trying to bind this stuff to my jsf page (projectTreeNode is a TreeNodeImpl data type):
<rich:tree value="#{nodesBean.projectTreeNode}" var="project"> <rich:recursiveTreeNodesAdaptor roots="#{project.name}" nodes="#{project.device}" /> </rich:tree>
-
2. Re: Need help deciding on data type for rich:tree and how to
nbelaevski Jul 8, 2009 4:52 AM (in response to meghiddo)"Meghiddo" wrote:
Is it possible to use Collections that are loaded with java Objects rather than String variables to bind to my rich:tree?
Yes. That's the main purpose of tree node adaptor tags (rich:treeNodesAdaptor and rich:recursiveTreeNodesAdaptor). -
3. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 5:25 PM (in response to meghiddo)OK, good, because I can get it this far with no problem.
Let's say I have an object that has two variables, projectName and deviceName. I need to use projectName for the top level of the tree and the deviceName under each projectName as the nodes.
What Collection would you suggest, I have it in a List right now so I can just leave it that way easily.
My problem I guess then is how I am trying to bind this list to the rich:tree tag. An example of one of my attempts is above.
Can you give me an idea of what the jsf should look like to achieve this? -
4. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 5:31 PM (in response to meghiddo)Hmm now that I think about it I may not be calling the method that loads the list first. I may need to use @PostConstruct above my loadNodes() method.
That may be what I have been missing the entire time.
But still, if you have an example of a List loaded with Objects, and how the jsf rich:tree tags should look when using them it would be great.
I will look back through the livedemo and dev guide stuff and try to find an example myself too, but if you could direct me there faster it would help (This has to be done by Friday ) or an actual example using the two variables I gave you in the above post would be outstanding -
5. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 7:01 PM (in response to meghiddo)should be something like this from what I can tell but I cant get anything from this:
<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectTreeNode}" var="project" nodes="#{project.projectName}" /> </rich:tree>
-
6. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 7:05 PM (in response to meghiddo)When i try that though it always takes a while, but project from the nodes attribute gets underlined and says "project cannot be resolved"
Any idea why this is happening or what I can do about it? -
7. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 7:16 PM (in response to meghiddo)actually now this is showing a tree, although not what i want. this code:
<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project" nodes="#{project.name}" /> </rich:tree>
is showing a tree, however for each node it has something representing the java object, not the projectName. Then when I try to expand the tree node it tells me something about not being able to find the value for project.name -
8. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 8, 2009 7:50 PM (in response to meghiddo)Im getting very close now, I just need a bit of guidance. I have two different things that give me trees but not exactly what Im looking for. This is the first:
<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project" > <rich:treeNodesAdaptor nodes="#{project.name}" /> </rich:recursiveTreeNodesAdaptor> </rich:tree>
Now that gives me a tree that has the Object representations as the roots and then when you expand the nodes you see the actual project name. The tree looks like this:
-projectContainer.MeasurementProject@46a09b
--Project Test 005
-projectContainer.MeasurementProject@6f19d5
--Project Test 06
etc
or I have this displaying another tree that isnt exactly what I need:<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project" > <rich:treeNode value="#{project.name}" > <h:outputText value="#{project.name}" /> </rich:treeNode> </rich:recursiveTreeNodesAdaptor> </rich:tree>
ow this display a tree where the project Names are the first thing you see, but there are no nodes to expand, it is just a list of the projects. I have tried a few things like adding another rich:treeNode or another h:outputText, but I can't seem to get it any further.
So which one is on the right track and how can I fix it lol? Ill keep trying myself, but would love for someone to help me a,long here -
9. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 9, 2009 4:37 AM (in response to meghiddo)I can get the projectName to display with the devices under it, but the Project Object is still the top level node. Anyone tell me how I should change this code?
<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project"> <rich:treeNodesAdaptor nodes="#{project.name}"> <rich:treeNodesAdaptor nodes="#{project.deviceName}" /> </rich:treeNodesAdaptor> </rich:recursiveTreeNodesAdaptor> </rich:tree>
it gives me a tree like this:
-projectContainer.MeasurementProject@46a09b
--Project Test 005
----Device 05
-projectContainer.MeasurementProject@6f19d5
--Project Test 06
----Device 06
So I pretty much have it if I could just move everything one level up and get rid of the actual Object String representation as the topmost node -
10. Re: Need help deciding on data type for rich:tree and how to
nbelaevski Jul 9, 2009 6:16 AM (in response to meghiddo)Add rich:treeNode component into the top rich:recursiveTreeNodesAdaptor. BTW, it will work if you use rich:treeNodesAdaptor instead of rich:recursiveTreeNodesAdaptor.
-
11. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 9, 2009 4:02 PM (in response to meghiddo)Hmm Im doing somethign wrong with your advice, can you tell me what I am missing?
I tried this:<rich:tree> <rich:treeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project"> <rich:treeNodesAdaptor nodes="#{project.projectId}"> <rich:treeNodesAdaptor nodes="#{project.name}" /> </rich:treeNodesAdaptor> </rich:treeNodesAdaptor> </rich:tree>
And this:<rich:tree> <rich:treeNode> <rich:treeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project"> <rich:treeNodesAdaptor nodes="#{project.projectId}"> <rich:treeNodesAdaptor nodes="#{project.name}" /> </rich:treeNodesAdaptor> </rich:treeNodesAdaptor> </rich:treeNode> </rich:tree>
and I got a blank space from both, no tree displays at all -
12. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 9, 2009 4:22 PM (in response to meghiddo)yeah the only thing that will give me a tree is if I use recursiveTreeNodesAdaptor, Im not sure why. All that this object has are two String variables.
The closest I have been able to get is with this code:<rich:tree> <rich:recursiveTreeNodesAdaptor roots="#{nodesBean.projectNameList}" var="project"> <rich:treeNode> <h:outputText value="#{project.projectId}" /> <rich:treeNode> <h:outputText value="#{project.name}" /> </rich:treeNode> </rich:treeNode> </rich:recursiveTreeNodesAdaptor> </rich:tree>
This give me a tree that you cant expand or collapse, but all the projects are listed under their projectIds. Closer but still cant be used -
13. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 9, 2009 4:40 PM (in response to meghiddo)The following worked although it seems very odd syntax:
<rich:tree> <rich:treeNodesAdaptor nodes="#{nodesBean.projectNameList}" var="project"> <rich:treeNodesAdaptor nodes="#{project.name}" /> <rich:treeNode> <h:commandLink value="#{project.projectId}" /> </rich:treeNode> </rich:treeNodesAdaptor> </rich:tree>
That uses the ID as the root node and the projectName as the child under each root. It seems like it would be the other way around, can anyone explain why this is? From the way I have it there it seems like the name would be the root node and the ID would be the child under each root. I want it the way it is now, but when I first did this I had projectId and name swicthed, because I thought it would work in the reverse order.
Either way looks like I have it now. The next step is going to be to replace the name String value with a devices List value, which Im sure will give me more issues lol.
C'est la vie -
14. Re: Need help deciding on data type for rich:tree and how to
meghiddo Jul 9, 2009 4:44 PM (in response to meghiddo)actually even though the display is correct now, I dont think this will work...
I need to be able to control what clicking on a node does, and how will I be able to do so for<rich:treeNodesAdaptor nodes="#{project.name}" />
?
I know I can do it for<rich:treeNode> <h:commandLink value="#{project.projectId}" /> </rich:treeNode>
but how will I do so for the name which is in the treeNodesAdaptor tag?