5 Replies Latest reply on Nov 6, 2009 4:12 AM by ahoehma

    clear selected node in rich:tree tag

    snowhite

      Hi,

      Is there a way to clear the selected node in richfaces tree?

      Thanks

        • 1. Re: clear selected node in rich:tree tag
          ahoehma

          Untested:

          Reset the selected node in your "TreeStateAdvisor":

          public Boolean adviseNodeSelected(UITree tree) -> return null.

          regards
          Andreas

          • 2. Re: clear selected node in rich:tree tag
            snowhite

            Thanks for your reply. I already tried adviseNodeSelected attribute(for rich:tree) to point to a method returning null. I also tried using TreeStateAdvisor as you suggested. It did not help me either.
            To explain it further, my tree is inside a modalpanel. On selecting a node, I need to populate a datatable. When modalpanel is closed and opened again, selected node state is maintaining. I want to reset the selection. Any help is appreciated.

            Thanks

            • 3. Re: clear selected node in rich:tree tag
              shadowcreeper

              IIRC, the return values mean:


              true - it is selected
              false - it is not selected
              null - no change


              Thus, if you select the node on the client, and the advisor returns null, it will still be selected. I believe false is what you want to return.

              • 4. Re: clear selected node in rich:tree tag
                snowhite

                Tried with return value set to false. Now, I am able to reset the selection. But

                the reset is happening immediately after the node is selected (avoiding me to

                change the color of node selected). I want the selection

                to reset when the modalpanel is closed.

                • 5. Re: clear selected node in rich:tree tag
                  ahoehma

                  You have to trigger a "reset-tree-action" on dialog close/open.

                  1. The "dialog-close-action" can change the tree-state-advisor.

                  or

                  2. Reset the tree-state before you open the dialog.
                  Maybe you have currently only a js-call "Richfaces.showModalPanel('...')" ?!
                  Try this:
                  <a4j:commandButton
                  id="openDialogCommand"
                  value="#{bundle['components.softwareVariant.add']}"
                  action="#{dialogTreeManager.resetSelection}"
                  oncomplete="Richfaces.showModalPanel('dlgId');return false;"
                  reRender="#{rich:clientId('dlgId')}"/>