9 Replies Latest reply on Oct 9, 2013 2:14 PM by Brian Leathem

    context menu on a rich tree does not work in some cases

    Alexandre Granier Newbie

      Hi,

       

      I would like to use a context menu on a tree. And this context menu has to re-render before to be displayed to enable or disable some menu depending on the node clicked. More over I would like to have a popupPanel status while processing the ajax request.

       

      here's the jsf

       

      <h:form id="form" prependId="true">
              <rich:tree id="tree" nodeType="item" var="node"
                          value="#{myBean.nodes}" toggleType="client" status="waitingStatus"
                          render="context"
                         selectionType="ajax" selectionChangeListener="#{myBean.selectionChanged}">
                  <rich:treeNode type="item">
                      <h:outputText value="#{node.label}"/>
                  </rich:treeNode>
              </rich:tree>
      
              <rich:contextMenu target="tree" mode="ajax" id="context">
                  <rich:menuItem label="View"
                                 mode="ajax" icon="/images/icons/open.gif"/>
              </rich:contextMenu>
      </h:form>
      </h:form>
           <rich:popupPanel id="mpstatus" moveable="false" modal="true"
                      style="text-align: center;background-color:white;">
                       <h:outputText value="#{msg.loading}" style="display:block;"/>
                       <h:graphicImage value="/images/loading.gif"/>
            </rich:popupPanel>
            <a4j:status id="waitingStatus" name="waitingStatus"
                       onstart="#{rich:component('mpstatus')}.show('', {height:'80',width:'150'})"
                       onstop="#{rich:component('mpstatus')}.hide()"/>
      
      

       

      Here's the managed bean:

       

      @ManagedBean(name="myBean")
      @SessionScoped
      public class MyBean implements Serializable{
         
          private ArrayList<Node> nodes;
         
          private Collection<Object> selectedItems;
         
          public MyBean() {
              setNodes(new ArrayList<Node>());
              Node n1 = new Node("node1");
              Node n2 = new Node("node12");
              n1.addChild(n2);
              getNodes().add(n1);
              getNodes().add(new Node("node2"));
          }
          public void selectionChanged(TreeSelectionChangeEvent event) {  }
          public ArrayList<Node> getNodes() {
              return nodes;
          }
          public void setNodes(ArrayList<Node> nodes) {
              this.nodes = nodes;
          }
          public Collection<Object> getSelectedItems() {
              return selectedItems;
          }
          public void setSelectedItems(Collection<Object> selectedItems) {
              this.selectedItems = selectedItems;
          }
      }
      
      

       

      So If I specify no render (in the rich:tree) and no status, the context menu works. But If I specify render either on "tree" or "context" or both, or a status "waitingStatus" the context menu does not appear anymore.

      This behavior did work perfecly in RF3.

       

      Env:RF4.3.3 Mojarra2.1.6, glassfish 3.1.2.2

       

      Does anyone can help ?

      Alex

        • 1. Re: context menu on a rich tree does not work in some cases
          Brian Leathem Master

          Mojarra 2.1.6 is really old, can you try something newer?

           

          Any error messages in your browser console or server log?

          • 2. Re: context menu on a rich tree does not work in some cases
            Alexandre Granier Newbie

            Hi Brian,

            I updated to 2.1.26 the problem remains the same.

            There is no error message in JS console.

            see the screenshot for richfaces log messages after a context menu event on node 2.screenshot.png

            • 3. Re: context menu on a rich tree does not work in some cases
              Brian Leathem Master

              Your status exists outside of the form.  Can you try:

               

              1. Move the a4j:status out of the popup panel and in the form itslef?
              2. if 1. works, try moving the popuppanel in to your form and setting the domElementAttachment attribute to form?
              • 4. Re: Re: context menu on a rich tree does not work in some cases
                Alexandre Granier Newbie

                Hi Brian,

                so I tried this but it does not work better.

                 

                <h:form id="form" prependId="true" >
                    <rich:tree id="tree" nodeType="item" var="node" status="waitingStatus"
                            value="#{myBean.nodes}" toggleType="client"
                            render=""
                                selectionType="ajax" selectionChangeListener="#{myBean.selectionChanged}">
                          <rich:treeNode type="item">
                              <h:outputText value="#{node.label}"/>
                          </rich:treeNode>
                    </rich:tree>
                
                    <rich:contextMenu target="tree" mode="ajax" id="context">
                        <rich:menuItem label="View" render="popupContent" oncomplete="#{rich:component('popup')}.show()"
                                        mode="ajax"/>
                    </rich:contextMenu>
                    <a4j:status id="waitingStatus" name="waitingStatus"
                        onstart="#{rich:component('mpstatus')}.show('', {height:'80',width:'150'})"
                        onstop="#{rich:component('mpstatus')}.hide()"/>
                   
                </h:form>
                <rich:popupPanel id="mpstatus" moveable="false" modal="true"
                        style="text-align: center;background-color:white;">
                        <h:outputText value="#{msg.loading}" style="display:block;"/>
                        <h:graphicImage value="/images/loading.gif"/>
                </rich:popupPanel>
                <a4j:log></a4j:log>
                

                 

                thx for your reply.

                • 5. Re: context menu on a rich tree does not work in some cases
                  Brian Leathem Master

                  How does it "not work better"?  Same failure? Different failure?

                  • 6. Re: context menu on a rich tree does not work in some cases
                    Alexandre Granier Newbie

                    It is the same failure : the context menu does not appear.

                    • 7. Re: context menu on a rich tree does not work in some cases
                      Brian Leathem Master

                      Sounds like you've uncovered a bug.  There are a few too many variables at play here though, we need to narrow it down.

                       

                      • The problem:
                        • the contextMenu does not appear under certain conditions.
                      • The components involved:
                        • the tree, contextMenu, popup and status.
                      • To Reproduce
                        • render the contextMenu or the tree
                          • or
                        • include the status

                       

                      Can you try cutting the popupPanel out of the above equation, and see if you can still reproduce?  Follow these steps while debugging the applications:

                      https://gist.github.com/lfryc/6123495

                      • 8. Re: Re: context menu on a rich tree does not work in some cases
                        Alexandre Granier Newbie

                        Ok Brian,

                        so there is 3 differents cases.

                         

                        1. Context menu does not work on a tree when re-render context menu

                         

                        <h:form id="form" prependId="true" >
                            <rich:tree id="tree" nodeType="item" var="node" render="context"
                                        selectionType="ajax" selectionChangeListener="#{myBean.selectionChanged}">
                                  <rich:treeNode type="item">
                                      <h:outputText value="#{node.label}"/>
                                  </rich:treeNode>
                            </rich:tree>
                        
                            <rich:contextMenu target="tree" mode="ajax" id="context">
                                <rich:menuItem label="View" render="popupContent" oncomplete="#{rich:component('smth')}.show()"
                                                mode="ajax"/>
                            </rich:contextMenu>   
                        </h:form>
                        

                         

                        No warning in JS console, a4j:debug console and ui:debug output

                         

                        2. Context menu does not work on a tree when re-render the tree

                         

                        <h:form id="form" prependId="true" >
                            <rich:tree id="tree" nodeType="item" var="node"
                                    value="#{myBean.nodes}" toggleType="client" 
                                    render="tree"
                                         selectionType="ajax" selectionChangeListener="#{myBean.selectionChanged}">
                                  <rich:treeNode type="item">
                                      <h:outputText value="#{node.label}"/>
                                  </rich:treeNode>
                             </rich:tree>
                        
                             <rich:contextMenu target="tree" mode="ajax" id="context">
                                 <rich:menuItem label="View" render="popupContent" oncomplete="#{rich:component('smth')}.show()"
                                                mode="ajax"/>
                             </rich:contextMenu>     
                        </h:form>
                        

                         

                        The context menu appears once (at the first context menu event) and after it does not appear anymore.

                        No JS console error.

                         

                        3. Context menu does not work on a tree with  a popupPanel status

                         

                        <h:form id="form" prependId="true" >
                            <rich:tree id="tree" nodeType="item" var="node" status="waitingStatus"
                                    value="#{myBean.nodes}" toggleType="client" 
                                         selectionType="ajax" selectionChangeListener="#{myBean.selectionChanged}">
                                  <rich:treeNode type="item">
                                      <h:outputText value="#{node.label}"/>
                                  </rich:treeNode>
                             </rich:tree>
                        
                             <rich:contextMenu target="tree" mode="ajax" id="context">
                                 <rich:menuItem label="View" render="popupContent" oncomplete="#{rich:component('popup')}.show()"
                                                mode="ajax"/>
                             </rich:contextMenu>
                                <a4j:status id="waitingStatus" name="waitingStatus"
                                onstart="#{rich:component('mpstatus')}.show('', {height:'80',width:'150'})"
                                onstop="#{rich:component('mpstatus')}.hide()"/>
                        </h:form>
                        <rich:popupPanel id="mpstatus" moveable="false" modal="true"
                                style="text-align: center;background-color:white;">
                                 <h:outputText value="#{msg.loading}" style="display:block;"/>
                                 <h:graphicImage value="/images/loading.gif"/>
                        </rich:popupPanel>
                        

                        No JS error or logs error.

                         

                        The managed bean associated is the same for the three cas, see first message.

                        • 9. Re: context menu on a rich tree does not work in some cases
                          Brian Leathem Master

                          thanks for breaking down the use cases so succinctly.  I've asked our QE team (cc: ppitonak) to check if any of these use cases are covered by our functional test suite.