1 2 Previous Next 15 Replies Latest reply on Feb 19, 2008 8:40 AM by Christian Douven

    rich:tree can't process selected event

    Tim Newbie

      I got this piece of code to process a selection on a tree node
      JSF page

       <rich:tree value="#{productHome.policyTree}" var="node" switchType="client"
       nodeSelectListener="#{productHome.processSelection}"
       ajaxSubmitSelection="true"
       reRender="tree"
       >
       <rich:treeNode>
       <a:commandLink value="#{node.label}" reRender="subpanel" ajaxSingle="true" immediate="true">
       <f:param name="link" value="#{node.link}"/>
       <f:param name="id" value="#{node.id}"/>
       </a:commandLink>
       </rich:treeNode>
       </rich:tree>
      

      and the code
       public void processSelection(NodeSelectedEvent event)
       {
       UIComponent comp = event.getComponent();
       log.info("component is " + comp.getClass().getName());
       HtmlTree tree = (HtmlTree) comp;
       currentNode = (TreeNode) tree.getTreeNode();
       log.info("User select node = " + ((TreeData)currentNode.getData()).getLabel());
       }
      

      but it never goes to the last log. No error except for something on the jsf page
      17:10:50,298 INFO [ProductHome] component is org.richfaces.component.html.HtmlTree
      17:10:50,314 WARN [lifecycle] /config/ProductEdit.xhtml @25,8 nodeSelectListener="#{productHome.processSelection}": java.lang.ClassCastException: org.richfaces.component.html.HtmlTree
      17:10:50,501 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      


      I don't know what's going on here and completely lost on why it didn't go any further.
      Any explaination??


        • 1. Re: rich:tree can't process selected event
          Wei Han Newbie

          This is a classloader issue. I had the same issue just days ago. please post your application.xml, jboss-app.xml and ear/war/jar structures here.

          • 2. Re: rich:tree can't process selected event
            Tim Newbie

            I use JBoss Seam-gen 2.0.1 as the scaffold, so the app structure is typical

            proj.ear
            -lib
            -proj.jar
             - META-INF
            -proj.war
             - WEB-INF
             -lib
            

            where ear lib contains jboss-el.jar, richfaces-api.jar and others.
            war/WEB-INF/lib contains richfaces-impl.jar, richfaces-ui.jar, jboss-seam*.jar, jsf-facelets..jar
            My application.xml is
            <?xml version="1.0" encoding="UTF-8"?>
            <application xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
             version="5">
            
             <display-name>proj</display-name>
            
             <module>
             <web>
             <web-uri>proj.war</web-uri>
             <context-root>/proj</context-root>
             </web>
             </module>
            
             <module>
             <ejb>proj.jar</ejb>
             </module>
            
             <!-- Seam and EL -->
             <module>
             <java>jboss-seam.jar</java>
             </module>
            
             <module>
             <java>/proj.war/WEB-INF/lib/richfaces-ui.jar</java>
             </module>
            
             <module>
             <java>/proj.war/WEB-INF/lib/richfaces-impl.jar</java>
             </module>
            
            </application>
            


            jboss-app.xml is
            <?xml version="1.0" encoding="UTF-8"?>
             <!DOCTYPE jboss-app
             PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
             "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
            
            <jboss-app>
             <loader-repository>
             seam.jboss.org:loader=neo
             </loader-repository>
            </jboss-app>
            


            I believe Seam 2.0.1 use Richfaces 3.1.2.SP1, but I got the same problem with Richfaces 3.1.3.GA. I also clean out my JBoss4.2.2GA default/tmp and work, but it has no effect.


            • 3. Re: rich:tree can't process selected event
              Wei Han Newbie

              Modify your jboss-app.xml like this

              <?xml version="1.0" encoding="UTF-8"?>
               <!DOCTYPE jboss-app
               PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
               "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
              
              <jboss-app>
              </jboss-app>


              this results in all modules share the same classloader, it's might not be good but resolves the problem.


              • 4. Re: rich:tree can't process selected event
                Wei Han Newbie

                In addtion, you need move all jar files under WAR/WEB-INF/lib to EAR/lib.

                • 5. Re: rich:tree can't process selected event
                  Tim Newbie

                  I can't even get application started that way. JBoss throws bunch of errors.

                  • 6. Re: rich:tree can't process selected event
                    Sebastian Scotti Newbie

                    I have the same problem, please one solution

                    • 7. Re: rich:tree can't process selected event
                      Sebastian Scotti Newbie

                      Here one solution,

                      Code

                      public void processSelection(NodeSelectedEvent event) {
                      UITree tree = (UITree) event.getComponent();
                      templateSel= (Template) tree.getRowData();
                      }

                      Template is my POJO class (Node Selected)

                      Very important, touch file jboss-service, from jboss-web-deplyer
                      the option, UseJBossWebLoader=true

                      • 8. Re: rich:tree can't process selected event
                        Taya Yerygina Newbie

                         

                        Very important, touch file jboss-service, from jboss-web-deplyer
                        the option, UseJBossWebLoader=true


                        Does somebody know another way? Set UseJBossWebLoader to true cause too many other errors...

                        • 9. Re: rich:tree can't process selected event
                          Tim Newbie

                          I don't want to mess with classloader. You're going hit other problem later with that. It always fails at the casting call with default (conflicting) classloading process.

                          I work around with this:

                          <rich:tree style="width:300px"
                           switchType="client"
                           ajaxSubmitSelection="true"
                           bypassUpdates="true"
                           value="#{productHome.treeRoot}" var="item">
                           <rich:treeNode>
                           <a:commandLink value="#{item.label}"
                           action="#{productHome.clickNode(item)}"
                           bypassUpdates="true"
                           ajaxSingle="true"
                           ajaxSubmitSelection="true"
                           reRender="selectPanel"
                           >
                           </a:commandLink>
                           </rich:treeNode>
                          </rich:tree>
                          


                          Since you can't count on tree to detect event, you have to use link to act on it. Bad thing is this page is reloaded (hate it), so if you build the tree for page, it will rebuild the tree each time.
                          I encounter many bugs in Richfaces, but this one is the worse of all, right before modalPanel which I have given up on doing anything useful (beside the simple example open/close).


                          • 10. Re: rich:tree can't process selected event
                            Taya Yerygina Newbie

                            tim_ph, try to use JSFunction instead of CommandLink

                            <rich:tree value="{...}" var="item">
                             <rich:treeNode onselected="clickNode(item)">
                             #{item.name}
                             </rich:treeNode>
                            </rich:tree>
                            
                            <a4j:form>
                             <a4j:jsFunction name="clickNode">
                             <a4j:actionparam name="param1" assignTo="#{...}"/>
                             </a4j:jsFunction>
                            </a4j:form>
                            


                            • 11. Re: rich:tree can't process selected event
                              hello All Newbie

                              I am facing the same issue. Does anyone have a solution ? I tried the classloader solution but still facing the same problem.

                              Here one solution,

                              Code

                              public void processSelection(NodeSelectedEvent event) {
                              UITree tree = (UITree) event.getComponent();
                              templateSel= (Template) tree.getRowData();
                              }

                              Template is my POJO class (Node Selected)

                              Very important, touch file jboss-service, from jboss-web-deplyer
                              the option, UseJBossWebLoader=true

                              Could you please post your POJO class ?

                              Thanks

                              • 12. Re: rich:tree can't process selected event
                                Tim Newbie

                                POJO class doesn't matter in this case. You will never reach second line.
                                I will try jsFunction to aleviate tree building problem. I think the tree should be inside form, so <a4j:form> should be put before <rich:tree>.

                                • 13. Re: rich:tree can't process selected event
                                  Wei Han Newbie

                                  Let me explain a little bit more about the issues I faced and the resolution.

                                  My application is generated by seam-gen. So initially Richfaces libraries are placed at two locations.

                                  richfaces-api.jar under EAR/lib
                                  richfaces-ui.jar and richfaces-impl.jar under EAR/MyApp.war/WEB-INF/lib

                                  My java classes are packaged into EAR/MyApp.jar

                                  My code to process the selection

                                   public void processSelection(NodeSelectedEvent event) {
                                   HtmlTree tree = (HtmlTree) event.getComponent();
                                   ...
                                   }
                                  


                                  The first issue I encountered is a ClassNotFoundException of "HtmlTree". That's because "HtmlTree" is packaged into richface-ui.jar which is not available to MyApp.jar.

                                  So I moved all richfaces jar files into EAR/lib, the ClassNotFoundException goes away, instead I got the ClassCastException. The reason being is MyApp.jar and MyApp.war have different classloaders. So I changed the configuration file to make all components in the EAR share the same classloader.

                                  I am aware of the downside of this solution, also welcome for a cleaning solution.



                                  • 14. Re: rich:tree can't process selected event
                                    Taya Yerygina Newbie

                                    ylx24, I've investigated RF binding problem for some time and I've seen a dozen of similar themes but all of them examine the same solution with configuration file changing. So I started to think that using of this framework (in particular with Seam) isn't a right way to develop realy rich and interactive application...

                                    1 2 Previous Next