• How do I set a node selected when clicked in navigator?

    By Katarina Stubberud 1 decade ago

    Hi. I have a question about the navigator and how to make the node I click "selected" (dark green).

    The navigator content is created from a bean. All items are BasicLeafTreeNodes or BasicContainerTreeNodes. The bean sets a submitvalue that is handled by a ssjs. The ssjs basically just sets a few viewscope variables in order for the partial refresh to open the correct view and database.

    All that works okey, but I fail to see where and how I can set the node selected.

    I've tried giving each node an id in the bean (node.setId()) and then in the onItemClick event access the node thru getComponent() but it does not work (getComponent() is null). My intention was to get get a handle to the node and use setSelected(true).

    PageTreeNodes have an attribute called selection, but BasicLeafTreeNodes dont have that, besides I dont get how those work anyway.

                expandable="true" expandLevel="0"
                onItemClick="#{javascript:menu.run(context.getSubmittedValue())}">
                
                    
                

                                 refreshMode="partial" submit="true" refreshId="reloadPanel"
                    action="#{javascript:menu.run(context.getSubmittedValue())}">
                

            

     

    Best regards,

    Katarina

    • Possible solution

      By Philippe Riand 1 decade ago

      Make your code, on onClickItem, set a viewScope variable, like viewScope.myselection=context.getSubmittedValue(). Then compute the selected property like viewScope.myselection='a value'.

      Now, we might want to make it easier, like having a property in the navigator itself that keeps a reference to the selected component. Any ides is welcomed.

      getComponent() doesn't work with nodes as they are not actual JSF components

      selection in the page node is related to a the current page being displayed. See the navigationPath in the layout component.

       

      • Found a simple solution

        By Katarina Stubberud 1 decade ago

        Thanks for response Philippe. I guess there are many ways to solve this problem, but I found one that works find and is fairly straightforward.

        It includes initiating a second partial refresh on the left column where the navigator resides. Each node has a selected formula that returns true depending on a viewScope variable.


           }]]>
          
         

        best regards

        Katarina