1 2 Previous Next 15 Replies Latest reply on Jun 3, 2009 5:58 PM by Nick Belaevski

    Cant get list to populate with values before trying to add n

    Matt Kohanek Novice

      I am so close here, when I call my method to load the values to a list it does so, because I am able to then call a print method that shows the values in the list.

      So I have my list with values that I want to bind to my tree. But when I try to do so I get

      roots="#{tempTreeBean.ids}": Error reading 'ids' on type testContainer.Temp

      Now I am sue the reason is that the rich tree is trying to get the values from the list before the method to populate said list is invoked. So how do I tell the tree to first load the list with values, and then use the list to populate the tree? I can load the list with values if I just call the method on my own, but when I try to use this list to populate the tree Im pretty sure this method to load the list is not being invoked. Its the last step before I finally have my tree worked out, but I cant seem to figure it out!!

      I knwo there must be some attribute to add to the rich:recursiveTreeNodesAdaptor tag, but Im just not sure what it is

      Ill keep looking, but if someone can tell me it would save me a lot of time

        • 1. Re: Cant get list to populate with values before trying to a
          Matt Kohanek Novice

          oh and also can someone tell me where in the richfaces folder I can find whatever it is I need to add as the source so when I click on 183 on the following line:

          at org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor.getRoots(HtmlRecursiveTreeNodesAdaptor.java:183)


          it wil bring up that class file editor so I can see what it is referring to? I thought it would just be the src folder but apparently not

          • 2. Re: Cant get list to populate with values before trying to a
            Matt Kohanek Novice

            Here is the first part of the stack if it will help someone to help me figure this out:

            javax.el.ELException: /test/treetest.xhtml @18,75 roots="#{tempTreeBean.ids}": Error reading 'ids' on type testContainer.Temp
            com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
            org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor.getRoots(HtmlRecursiveTreeNodesAdaptor.java:181)
            org.richfaces.component.UIRecursiveTreeNodesAdaptor.getData(UIRecursiveTreeNodesAdaptor.java:55)
            org.richfaces.component.UITreeNodesAdaptor$1.getData(UITreeNodesAdaptor.java:54)
            org.richfaces.model.StackingTreeModel.getDataModel(StackingTreeModel.java:83)
            org.richfaces.model.StackingTreeModel.doWalk(StackingTreeModel.java:309)
            org.richfaces.model.StackingTreeModel.walk(StackingTreeModel.java:381)
            org.richfaces.component.UITree.walk(UITree.java:422)

            • 3. Re: Cant get list to populate with values before trying to a
              Matt Kohanek Novice

              essentially Im needing to tell my jsf page "invoke this method to load the list before you do anything else, then use this list to populate the tree"

              • 4. Re: Cant get list to populate with values before trying to a
                Nick Belaevski Master

                 

                "Meghiddo" wrote:
                essentially Im needing to tell my jsf page "invoke this method to load the list before you do anything else, then use this list to populate the tree"

                You can use @PostConstruct annotation or constructor itself.

                • 5. Re: Cant get list to populate with values before trying to a
                  Matt Kohanek Novice

                  sigh - well apparently there is just a problem with the method used to populate the list.

                  because I see this:

                  javax.servlet.ServletException: java.lang.IllegalArgumentException: Invalid PostConstruct annotation
                  javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
                  org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                  org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                  org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                  org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)



                  Here is the method itself if you feel like trying to see whats wrong, Im at a loss. I think Im just going to have to give up on the rich tree Ive spent the last two weeks on. Its weird, this method seems to work when I just run it from eclipse but it just wont do it otherwise. Maybe it has something to do with client/server side issues?

                  @PostConstruct
                   public void loadNodes() throws IOException, Exception {
                  
                   DeviceCollectionXMLAO access = new DeviceCollectionXMLAO();
                   HttpClientMethods method = new HttpClientMethods();
                   DeviceCollection deviceCollection = null;
                  
                  
                   deviceCollection = access.readXML(method.Response(null));
                  
                  
                   //System.out.println("printing deviceCollection = access.readXML(method.getResponseBodyAsStream(null));: "
                   //+ deviceCollection.toString());
                  
                   for (Device device : deviceCollection.getDevices()){
                   String x = device.getDeviceId();
                   ids.add(x);
                   //System.out.println(ids);
                   }
                  
                   }
                  
                   public List<String> getIds() {
                   //loadNodes();
                   return ids;
                   }
                  
                   public void setIds(List<String> ids) {
                   this.ids = ids;
                   }
                  
                   public void print(){
                   System.out.println("Printing ids list: "+ids);
                   }
                  }


                  And when I call that print method it prints out a list of deviceIds, so when I run it in eclipse its fine...I dont know what is up with this anymore, I thought I had it...

                  • 6. Re: Cant get list to populate with values before trying to a
                    Nick Belaevski Master

                    Methods annotated with @PostConstruct should not declare any exceptions in "throws", that's why you get java.lang.IllegalArgumentException.


                    Here is the first part of the stack if it will help someone to help me figure this out:

                    javax.el.ELException: /test/treetest.xhtml @18,75 roots="#{tempTreeBean.ids}": Error reading 'ids' on type testContainer.Temp
                    com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                    org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor.getRoots(HtmlRecursiveTreeNodesAdaptor.java:181)
                    org.richfaces.component.UIRecursiveTreeNodesAdaptor.getData(UIRecursiveTreeNodesAdaptor.java:55)
                    org.richfaces.component.UITreeNodesAdaptor$1.getData(UITreeNodesAdaptor.java:54)
                    org.richfaces.model.StackingTreeModel.getDataModel(StackingTreeModel.java:83)
                    org.richfaces.model.StackingTreeModel.doWalk(StackingTreeModel.java:309)
                    org.richfaces.model.StackingTreeModel.walk(StackingTreeModel.java:381)
                    org.richfaces.component.UITree.walk(UITree.java:422)

                    Full stack trace is necessary to check.

                    Can you please post full example source code (managed beans, full page code, faces-config.xml) here or somewhere on the Internet (e.g. on sendspace.com)?

                    • 7. Re: Cant get list to populate with values before trying to a
                      Matt Kohanek Novice

                      I deleted all the other stuff besides the 6 java classes and one .xhtml page that are necessary for what Im trying to do, so I cut out all the excess I was able to.

                      http://www.sendspace.com/file/ce6t1p

                      I am about to go to class for 4 hours. Please dont go out of your way - any farther than you already have I should say for this. I think its obvious Im trying to work this out on my own (how many threads on this in two weeks now haha), I just dont have the needed experience yet.

                      • 8. Re: Cant get list to populate with values before trying to a
                        Nick Belaevski Master

                        I've removed throws (wrapped all in try/catch for now) and successfully launched the application on Tomcat 6 and JBoss 5.0.1.GA (removed jsf-api/jsf-impl and stax-* jars from the project before deploying to JBoss). I see one leaf tree - as in the source XML file.

                        • 9. Re: Cant get list to populate with values before trying to a
                          Matt Kohanek Novice

                          I messed things up for myself even more now it would seem.
                          How do you start the server without the jsf api and jsf impl jars, every time I try to I get this log:

                          SEVERE: Exception starting filter richfaces
                          java.lang.NoClassDefFoundError: javax/faces/FacesException
                          at org.ajax4jsf.webapp.BaseFilter.init(BaseFilter.java:170)
                          at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
                          at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
                          at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
                          at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
                          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
                          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
                          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
                          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
                          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
                          at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
                          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
                          at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
                          at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
                          at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
                          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
                          at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
                          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                          at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                          at org.apache.catalina.core.StandardService.start(StandardService.java:516)
                          at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
                          at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                          at java.lang.reflect.Method.invoke(Method.java:597)
                          at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
                          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
                          Caused by: java.lang.ClassNotFoundException: javax.faces.FacesException
                          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
                          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
                          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                          ... 28 more

                          And then when I add those jars back in the server starts with no errors, but then when trying to launch the tree I get

                          javax.servlet.ServletException: java.lang.reflect.InvocationTargetException
                          javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
                          org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                          org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                          org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                          org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)



                          This is even more frustrating to know that my methods are all working but it is my friggin libraries messing things up!

                          And you didnt edit the web.xml or faces-config files at all then?

                          • 10. Re: Cant get list to populate with values before trying to a
                            Matt Kohanek Novice

                            btw, Im trying to figure out what the problem is now, Ill let you know if I find it.

                            Just to clear up your reply as well, did you first launch the server, and then go in and remove those jars? because as I say my server gives me errors when I tried to remove them.

                            And when creating the project, did you use server side implementation, or mojarra (which is where those two jsf JARS come from)?

                            • 11. Re: Cant get list to populate with values before trying to a
                              Matt Kohanek Novice

                              I really think it is something in my web.xml file that is tellling my project it must have the jsf api and impl jars.
                              So did you use the web.xml file I sent with my example, or did you have your own?

                              • 12. Re: Cant get list to populate with values before trying to a
                                Matt Kohanek Novice


                                I think these lines from my web.xml file may be the problm:

                                <servlet>
                                 <servlet-name>Faces Servlet</servlet-name>
                                 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                                 <load-on-startup>1</load-on-startup>
                                 </servlet>
                                


                                As soon as I removed those though my libraries started going crazy and changing positions and eclipse wont let me do anything... we shall see...

                                • 13. Re: Cant get list to populate with values before trying to a
                                  Nick Belaevski Master

                                  I've removed libraries, then deployed.

                                  • 14. Re: Cant get list to populate with values before trying to a
                                    Matt Kohanek Novice

                                    working finally!

                                    the probelm was, I kept making libraries and putting jars in them, and then when I made a project I would import those libraries. Eclipse didnt like this, so instead I just made project with the bare minimum jars, and then added all the jars I knew I needed into web-inf/lib (which is what the gettying started guide says to do but I did not because it didnt work for me whan I first tried it)

                                    Thanks a ton nbevalaeski, couldnt have done it without your tremendous effort

                                    1 2 Previous Next