7 Replies Latest reply on Jul 25, 2011 10:45 AM by yaseralhs

    [rich:tree] advisenodeopened alter regular comportement of t

    Bob Mauranne Newbie

      Hello everyone,

      Usually, to open/close a node in the rich:tree, you would have to click on the little arrow next to the icon.

      Recently, i used the adviseNodeOpened attribute to save the state of the tree (session scoped).

      A collateral effect occured : if i click anywhere on the node (not only on the arrow), it opens or closes.

      I first tought it was handy. But in some of my rich:treenode tags i put a rich:contextMenu (event="oncontextmenu") and when i right-click on the menu, the node opens or closes. And that will be considered as a bug :/

      So, if my english is not too bad, and some of you understood what my problem is, i would like to know how to disable this right-click effect.

      I hope someone could help me,

      Thanks in advance.

        • 2. Re: [rich:tree] advisenodeopened alter regular comportement
          Bob Mauranne Newbie

          Richfaces 3.3.0.GA
          Seam 2.1.1.GA

          Here's the tree and a node :

          <r:tree id="arbre_general" switchType="ajax" value="#{structureItem.getStructureTree()}"
          var="stru" nodeFace="#{stru.type}" ajaxSubmitSelection="true"
          nodeSelectListener="#{structureTreeListener.processSelection}" reRender="zone_details" selectedClass="struct_tree_selected"
          adviseNodeOpened="#{structureStateListener.adviseNodeOpened}" toggleOnClick="true">
          
           <r:treeNode type="root_tso">
           <h:outputText value="#{stru.name}" styleClass="struct_tree_root" />
           <r:contextMenu event="oncontextmenu" submitMode="none">
           <r:menuItem value="Something">
           <a4j:support event="onclick" action="#{structureFormsListener.nouvelleForm(0)}" reRender="zone_details" />
           </r:menuItem>
           </r:contextMenu>
           </r:treeNode>
          



          And the treestateadvisor implementation
          @Scope(ScopeType.SESSION)
          @Name("structureStateListener")
          public class StructureStateListener implements Serializable, TreeStateAdvisor {
           private static final long serialVersionUID = -4387459139643144233L;
          
           private Map<Long, Boolean> noeudOuverts;
          
           @In(scope = ScopeType.PAGE, required = false, value = "structureTreeForm")
           private StructureTreeForm structureTreeForm;
          
           public StructureStateListener() {
           super();
          
           noeudOuverts = new HashMap<Long, Boolean>();
           }
          
           @Create
           public void init() {
          
           }
          
           @SuppressWarnings("unchecked")
           public Boolean adviseNodeOpened(UITree arg0) {
           Boolean res = null;
           TreeNode<TreeBean> node = arg0.getTreeNode();
           TreeBean ti = node.getData();
          
           if (noeudOuverts.containsKey(ti.getNodeId())) {
           if (structureTreeForm != null) {
           res = !noeudOuverts.get(ti.getNodeId());
           }
           else {
           res = noeudOuverts.get(ti.getNodeId());
           }
          
           noeudOuverts.put(ti.getNodeId(), res);
           }
           else {
           res = ti.getNodeId() >= 10;
           noeudOuverts.put(ti.getNodeId(), res);
           }
          
           return res;
           }
          
           public Boolean adviseNodeSelected(UITree arg0) {
           return null;
           }
          
           @Destroy
           public void end() {
          
           }
          }


          The "TreeBean" class is mine, it describes the node (id, type, label, face etc..)

          the "noeudsOuverts" (= nodesOpened) attribute is a map<node, state> wich stores the last state of the node.


          The problem :

          On a right-click, the "adviseNodeOpened" event is fired, i want to prevent that, or being able to recognize a rightclick and filter it in the adviseNodeOpened function.


          What do you think ?

          ps : again, sorry for my poor english

          • 4. Re: [rich:tree] advisenodeopened alter regular comportement
            Bob Mauranne Newbie

            rightClickSelection is a richfaces 3.3.1 feature, i'm working on the 3.3.0.GA version and i can't change it for an unstable version.

            Also, when i right-click on a node wich doesn't have a rich:context menu on it, nothing happens (no change of stage). It occurs only when i click on an element of the context menu.

            I hope someone could help me on this one.


            By the way, is there any way to know in the adviseNodeOpened method where did the event came from ? If i could filter the event by its origin, that would be much more simple.

            Thanks for your help

            • 5. Re: [rich:tree] advisenodeopened alter regular comportement
              Bob Mauranne Newbie

              i'm still stuck with this.. Does anyones have an idea ?

              Thanks

              • 6. Re: [rich:tree] advisenodeopened alter regular comportement
                Romulo Diniz Newbie

                Well, probably the answer has already been found, but I guess toggleOnClick should be set to "false"

                • 7. Re: [rich:tree] advisenodeopened alter regular comportement of t
                  yaseralhs Newbie

                  Hi ALL

                  I using richfaces 4 tree where i need to  right click

                   

                  Can I do that in richfaces 4???