6 Replies Latest reply on Jun 11, 2007 7:45 PM by kirancsagi

    Tree nodeSelectListener

    dustismo

      Hi,

      I have a tree that is defined like:

      <h:form>
       <rich:tree
       value="#{watchGroupNav.tree.root}"
       var="item"
       nodeFace="#{item.type}"
       switchType="ajax"
       styleClass="nav-tree"
       nodeSelectListener="#{watchGroupNav.onSelect}"
       >
       <rich:treeNode type="wg_folder"
       nodeClass="nn-label-folder"
       icon="/img/folder.png"
       iconCollapsed="/img/tree-expand.gif"
       iconExpanded="/img/tree-collapse.gif"
       >
       <h:outputText value="#{item.label}" />
       </rich:treeNode>
       <rich:treeNode type="watch_group"
       nodeClass="nn-label-watch_group"
       >
      
       <h:outputText value="#{item.label}" />
       </rich:treeNode>
       </rich:tree>
      </h:form>
      


      Where onSelect is:

      public void onSelect(NodeSelectedEvent event) {
       System.out.println("node selected!");
      }
      


      onSelect is never called. When I select a node the styleClass changes, but nothing else happens, no post, nothing..

      any help?

      thanks,
      Dustin

        • 1. Re: Tree nodeSelectListener
          dustismo

          ack, ok, I found the problem, was missing:

          ajaxSubmitSelection="true"
          


          One more question, I'd like a node selection to result in a page reload. How can I accomplish?

          thanks,
          Dustin

          • 2. Re: Tree nodeSelectListener

            I solved this problem for myself by changing switchType to "server"

            • 3. Re: Tree nodeSelectListener
              dustismo

              Thanks for the response. Unfortunately switching to 'server' switch type is not possible. I need to have the open close events be ajax and the select be 'server'. Can I assume that this isn't possible? I don't even see any javascript hooks that I can use to reload the page (onselected is called before the ajax post returns). Is there a workaround that anyone can think of?

              thanks,
              Dustin

              • 4. Re: Tree nodeSelectListener
                nbelaevski

                Hello!

                You can disable ajax submits for node selection by setting ajaxSubmitSelection="false". Then use onselected to submit() the form.

                • 5. Re: Tree nodeSelectListener
                  dustismo

                  Thanks!

                  <h:form id="watchGroupTree">
                   <rich:tree
                   value="#{watchGroupNav.tree.root}"
                   var="item"
                   nodeFace="#{item.type}"
                   switchType="ajax"
                   styleClass="nav-tree"
                   nodeSelectListener="#{watchGroupNav.onSelect}"
                  
                   ajaxSubmitSelection="false"
                   onselected="document.forms['watchGroupTree'].submit();"
                   >
                  


                  • 6. Re: Tree nodeSelectListener
                    kirancsagi

                    How do you get to know the value or id of the node selected in the nodeSelectListener........

                    any help is appreciated.

                    Thanks