4 Replies Latest reply on Aug 19, 2013 8:54 AM by yuri_

    rich:tree doesn't fire selectionChange event

    fpiraneo

      Hi all,

       

      I'm quite new to RichFaces and I'm integrating it into my web application.

       

      I'm using rich:tree to allow user to make a choice in a tree; the code on xhtml page is:

       

      <?xml version='1.0' encoding='UTF-8' ?>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:ezcomp="http://java.sun.com/jsf/composite/ezcomp"

            xmlns:rich="http://richfaces.org/rich">

          <h:head>

              <h:outputStylesheet library="css" name="main.css" />

              <title>#{messages.app0}</title>

          </h:head>

          <h:body>


              <h:form id="mainForm">

                  <rich:tree id="treeSingle" value="#{chooseFirm.firmsDirectory}" var="node" rendered="#{chooseFirm.firmsPresents}" selectionType="ajax" selectionChangeListener="#{chooseFirm.selectionChanged(event)}" toggleType="ajax" toggleListener="#{chooseFirm.nodeToggled(event)}" style="width:100%" />

              </h:form>

       

          </h:body>

      </html>

       

      on my chooseFirm.java bean I created the two listeners:

       

      @ManagedBean

      @SessionScoped

      public class chooseFirm implements Serializable {

      ....some code....

       

          public void selectionChanged(TreeSelectionChangeEvent event) {
              System.out.print("*** Evento select lanciato ***");       
          }
         
          public void nodeToggled(TreeToggleEvent event) {
              System.out.print("*** Evento toggle lanciato ***");
          }

      ...some other code...

      }

       

      Now the funny: on my GlassFish console I can read "INFO: *** Evento toggle lanciato ***" when I open or close a node, unfortunately I cannot read the "select" change message and my suspect is that the event is not correctly handled on the server side. Looking at the GET / POST exchanges between the browser and the server I noted that the browser correctly send the POST to server.

       

      For references I use the Apress "Practical RichFaces (2nd ed.)" chapter 9.

       

      Any help is strongly apreciated, thank you!

       

      Francesco

        • 1. Re: rich:tree doesn't fire selectionChange event
          fpiraneo

          The solution has been found! ;-)

           

          Be very careful how you populate the tree; the tree may renders correctly but not well populated; the appearance is nice and also the node toggle event correctly risen; for the selection event is not the case.

           

          My concern is about why the framework doesn't issue a single warning about this criticity...

           

          FPG

          • 2. Re: rich:tree doesn't fire selectionChange event
            bleathem

            Can you post some details of what you did wrong, and what you did to fix it?  We can definitely add more error checking onto the component renderer, it would help a lot if you let us know what kinds of mistakes we should be looking out for.

            • 3. Re: rich:tree doesn't fire selectionChange event
              fpiraneo

              Frankly speaking I don't know what I did wrong! :-( Simply I adapted the example on the book to my needs. I think that a stronger check of what the rich:tree tag expect for correctly working can be useful to programmer to promptly debug; major frustraction is to have a code that doesn't work and don't arise a single warning / exception.

              • 4. Re: rich:tree doesn't fire selectionChange event
                yuri_

                Thank you so much Francesco for pointing me in the right direction.

                I also had this strange behaivior: the tree was toggling just fine but selection and drag-and-drop functionality was broken.

                I had this in my tree node impl:

                 

                public class OrgTreeNode extends org.richfaces.model.TreeNodeImpl { ... }

                 

                Changed it to

                 

                public class OrgTreeNode implements javax.swing.tree.TreeNode.TreeNode {

                    // implement methods

                }

                 

                and now it works like a charm.

                1 of 1 people found this helpful