0 Replies Latest reply on Feb 22, 2008 7:40 AM by Stefan Siebel

    Passing parameter using a contextmenu in treenode

    Stefan Siebel Newbie

      Hi,

      I set up the following tree with contextmenu for each node and it works pretty fine.

      <h:form>
      <rich:tree stateAdvisor="#{materialTreeStateAdvisor}" switchType="ajax" componentState="#{materialTree.componentState}">
      
      <rich:recursiveTreeNodesAdaptor roots="#{materialTree.root}"
       var="node" nodes="#{node.children}">
      
      <rich:treeNode>
      <h:outputText value="#{node.material.name}" />
      <h:panelGroup>
       <rich:contextMenu event="oncontextmenu" attached="true"
       submitMode="none">
       <rich:menuItem submitMode="ajax" value="Create Material"
       action="#{navigationHandler.doCreateMaterial}"
       reRender="material_edit_panel">
       </rich:menuItem>
       </rich:contextMenu>
      </h:panelGroup>
      </rich:treeNode>
      </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      </h:form>
      


      doCreateMaterial is action methode which navigates to a new page where you can create then a new item.
      The user right clicks now on a node and the contextmenu of the node opens. The problem is, that the I don't see any possiblity to pass the id of that node to the next page.

      f:param does not work because doCreateMaterial is just a action method. i can't change it to an actionlistener because i need it for navigation.

      because rich:tree needs to be nested in a h:form tag, i can't wrap every contextmenu within a h:form. thus i can't use a hidden field which saves the current id.

      one possibility i see is to create a h:commandlink within the menuitem. i could put there the url of the next page and pass arguments with a get parameter. What i don't like on that solution is that i bypass the jsf navigation completly.

      Are there any suggestions how i could do it in a nice jsf way?

      Best regards,
      STefan.