6 Replies Latest reply on Mar 15, 2013 9:30 AM by srikanthreddy123

    Context menu for multiple targets

    srikanthreddy123

      Hi,

      I have a requirment where in I have to render a context menu on the header of an accordion item and I need to a dynamic accordion.

       

      Can you please help me out in associating context menu to it. I tried to used targetSelector by asociated it to a style class which din't worked out.

       

       

      <rich:accordion id="accCTN" switchType="client" activeItem="#{ctnMgmtController.activeTab}">
        <c:forEach id="ctnRepeatL"
         items="#{ctnMgmtController.ctnGroups}" var="groupName">
          <rich:accordionItem switchType="client"
           name="#{groupName}" headerStyle="height: 10px" >
          <f:facet name="header">
           <h:outputText value="CTN Groups" id="test112" styleClass="menuable"></h:outputText>
         </f:facet>
        </rich:accordionItem>
      </c:forEach>
      </rich:accordion>


      <rich:contextMenu id="ctnGrpCtxmenu" target="test112"
               disableDefaultMenu="true">
               <rich:menuItem label="Manage Permissions"
                onclick="enlarge(#{rich:element('pic')});"
                id="manPerCtxMnuItm" />
               <rich:menuItem label="Add CTN"
                onclick="decrease(#{rich:element('pic')});"
                id="addCtnCtxMnuItm" />
               <rich:menuItem label="Update group name"
                onclick="decrease(#{rich:element('pic')});"
                id="updateGrpCtxMnuItm" />
               <rich:menuItem label="Delete Group"
                onclick="decrease(#{rich:element('pic')});"
                id="delGrpCtxMnuItm" />
      </rich:contextMenu>

       

      <rich:contextMenu id="ctnGrpCtxmenu" targetSelector=".menuable"

               disableDefaultMenu="true">

               <rich:menuItem label="Manage Permissions"

                onclick="enlarge(#{rich:element('pic')});"

                id="manPerCtxMnuItm" />

               <rich:menuItem label="Add CTN"

                onclick="decrease(#{rich:element('pic')});"

                id="addCtnCtxMnuItm" />

               <rich:menuItem label="Update group name"

                onclick="decrease(#{rich:element('pic')});"

                id="updateGrpCtxMnuItm" />

               <rich:menuItem label="Delete Group"

                onclick="decrease(#{rich:element('pic')});"

                id="delGrpCtxMnuItm" />

      </rich:contextMenu>

        • 1. Re: Context menu for multiple targets
          michpetrov

          Hi,

           

          you can put the menu inside the header and make it attached="true". But it won't work on the header, I guess there's something preventing "unwanted" behaviour on the header since you must be able to control the accordion with it.

          • 2. Re: Context menu for multiple targets
            srikanthreddy123

            can you please brief it.

            • 3. Re: Context menu for multiple targets
              michpetrov

              Srikanth Reddy wrote:

               

              can you please brief it.

              Hi,

               

              I'm sorry, I don't understand what you mean by "brief it." Do you want a code example?

              • 4. Re: Context menu for multiple targets
                srikanthreddy123

                Ya can you please give me an code example.

                • 5. Re: Context menu for multiple targets
                  michpetrov

                  Ah, ok:

                   

                          <rich:accordion id="accCTN" switchType="client" activeItem="#{ctnMgmtController.activeTab}">
                              <c:forEach id="ctnRepeatL" items="#{ctnMgmtController.ctnGroups}" var="groupName">
                                  <rich:accordionItem switchType="client" name="#{groupName}">
                                      <f:facet name="header">
                                          <rich:panel>
                                              <h:outputText value="CTN Groups" id="test112" styleClass="menuable" />
                                              <rich:contextMenu>
                                                  <rich:menuItem label="Manage Permissions" />
                                                  <rich:menuItem label="Add CTN" />
                                                  <rich:menuItem label="Update group name" />
                                                  <rich:menuItem label="Delete Group" />
                                              </rich:contextMenu>
                                          </rich:panel>
                                      </f:facet>
                                  </rich:accordionItem>
                              </c:forEach>
                          </rich:accordion>
                  

                   

                  The contextMenu will only work on an open panel (which is probably what you want) and you have to use rich:panel or something similar as the contextMenu cannot be attached just to a text.

                  • 6. Re: Context menu for multiple targets
                    srikanthreddy123

                    Thanks Michal .. It worked.