3 Replies Latest reply on Jan 7, 2011 5:39 PM by ilya40umov

    rich:tree selected node value on client side

    anonyin

      I have a requirement to capture the last selected node value when the user click on another action(out side the tree) in the page. Is there anyway I could get the last selected tree node value ?

       

      Thanks.

        • 1. Re: rich:tree selected node value on client side
          ilya40umov

          1) You can handle every user selection and save it on server. Like this

          http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model&cid=1197527

          2) You can handle every user selection by onselected event and save selected node in JS variable. It could look like this:

          onselected="handleSelectionJSFunction(#{treeItem.id});"
          • 2. rich:tree selected node value on client side
            anonyin

            Thanks for the reply.

             

            onselected will give me the value when we click on the tree node, yes I could certainly capture it on server side by passing the selected node value to the refresh function below. Infact I'm doing it.

             

             

            <a4j:jsFunction name="refresh"

                            action="#"

                            reRender="data">

                            <a4j:actionparam name="param1" assignTo="#{bean.treeNodeId}" />

            </a4j:jsFunction>

             

            But when I click on another action(Say Search) in the page(this link/button is not part of the tree its outside the tree) I want the value of the last tree node selected before clicking Search button to be passed to my bean. Eventhough I set the value of the treeNodeId in the bean when click on the tree node, by the time I click on the search button that value is lost.

             

            Any otherways to acheive this will also help.

             

            Thanks.

            • 3. rich:tree selected node value on client side
              ilya40umov

              Look at the following link:

              http://community.jboss.org/thread/158981

              I guess you need to pass selectedNodeId in actionparam inside a4j:commandButton - Search button.

               

              P.S. Make sure that you do save selectedNodeId in a JS variable. Use alert command or debug your JS in firebug.