-
1. Re: How to get my List<String> to bind to richfaces tree nod
meghiddo May 30, 2009 8:55 PM (in response to meghiddo)oh yes, and I also have tried to use nodesBean.getIds but no luck
-
2. Re: How to get my List<String> to bind to richfaces tree nod
nbelaevski May 31, 2009 6:22 AM (in response to meghiddo)Hi,
Methods should not be static. -
3. Re: How to get my List<String> to bind to richfaces tree nod
meghiddo May 31, 2009 9:05 AM (in response to meghiddo)AH OK, thanks, I forgot that I had called that in my main to prnt out the values and that I would need to change it back from static.
Unfortunately right now the web service is down so I cant see if this worked.
SO Ill just ask one other question, in my jsf, sould I use nodes="#{nodesBean.ids}" or nodes="#{nodesBean.getIds}" ? -
4. Re: How to get my List<String> to bind to richfaces tree nod
nbelaevski May 31, 2009 9:16 AM (in response to meghiddo)#{nodesBean.ids}
-
5. Re: How to get my List<String> to bind to richfaces tree nod
meghiddo May 31, 2009 12:30 PM (in response to meghiddo)I must be missing something I need pertaining to how to use a list to populate the tree. SO instead of using the code above that has a lot of potential for errors, I simplified things as far as I could, but I am still not able to use a list to populate the tree. Here is what i did:
First I made a simple class to declare a list, populate it with one entry and have setter and getter:public class RootNodes { List<String> ids = new ArrayList<String>(); public List<String> getIds() { ids.add("Test"); System.out.println(ids); return ids; } public void setIds(List<String> ids) { this.ids = ids; } }
When I printed out the value of ids it printed out [Test] so it seems the list is getting the value, and should not be null. SO I created a managed bean, and then tried to bind ids to a tree:<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <h:form> <rich:tree style="width:300px" switchType="ajax" > <rich:recursiveTreeNodesAdaptor nodes="#{nodesBean.ids}" /> </rich:tree> </h:form> </ui:composition>
But all that does is print out a blank page, just like my other code up there. This is as simple as it can get, so I must be missing something about how to bind this to a treeNode. Can anyone tell me what Im doing wrong? -
6. Re: How to get my List<String> to bind to richfaces tree nod
meghiddo May 31, 2009 12:48 PM (in response to meghiddo)I even simplified it a bit further by doing this:
int[] ids = {1, 2, 3, 4}; public int[] getIds() { return ids; } public void setIds(int[] ids) { this.ids = ids; }
ANd still a blank page. However, I did change nodes="#{nodesBean.ids}" to roots="#{nodesBean.ids}" and I did get a one branch tree with a value of
[I@1486306
Not what I was looking for, but compared to the luck I have had with this it is almost a mircale -
7. Re: How to get my List<String> to bind to richfaces tree nod
nbelaevski May 31, 2009 12:54 PM (in response to meghiddo)Should be roots="#{nodesBean.ids}" and ids should be List not array.
-
8. Re: How to get my List<String> to bind to richfaces tree nod
meghiddo May 31, 2009 2:09 PM (in response to meghiddo)man, the reason my original code isnt working is the web service is down, I keep forgetting.
Ill have to try it again once things are up again and then Ill let you know what happens.