1 Reply Latest reply on May 12, 2008 1:19 PM by blabno

    Richfaces Tree control instead of SelectOneMenu

    Malcolm Green Newbie

      Hi,


      In my application, instead of presenting a user with a SelectOneMenu like this ...



      <h:selectOneMenu value="#{company.tradingActivity}" required="true">
        <s:selectItems value="#{companyTradeActivityList.resultList}"
                         var="act"
                       label="#{act.tradeActivityName}"
            noSelectionLabel="Please Select ..."
        hideNoSelectionLabel="true" />
      
        <s:convertEntity />
      
      </h:selectOneMenu>



      I would like to present the user with a tree control instead, but still using <s:convertEntity/> and the automatic validation, and automatic assignment to company.tradingActivity.


      I am able to generate the tree control succesfully like this ...



      <rich:tree switchType="client">
        <rich:recursiveTreeNodesAdaptor roots="#{tradeGroupList.resultList}"
          nodes="#{dir.tradeGroups}"
            var="dir">
            <rich:treeNode>#{dir.tradeGroupName}/</rich:treeNode>
            <rich:treeNodesAdaptor nodes="#{dir.tradeActivities}" var="act">
                <rich:treeNode>#{act.tradeActivityName}</rich:treeNode>
            </rich:treeNodesAdaptor>
        </rich:recursiveTreeNodesAdaptor>
      </rich:tree>



      I am just not sure how to bind the selected node to the company.tradingActivity field in the company object.


      I am using Richfaces 3.2.0, JBoss 4.2.2, facelets, Seam 2.0.1


      I have tried to post what I think is relevant information, but as this is my first post please be gentle :-)


      Thanks,


      Malcolm

        • 1. Re: Richfaces Tree control instead of SelectOneMenu
          blabno Master

          You need to provide NodeSelectionListener


          public void processSelection(NodeSelectedEvent e) {
                  UITree tree = (UITree) e.getComponent();
                  company.tradingActivity = tree.getRowData();
          }



          <rich:recursiveTreeNodesAdaptor
                roots="#{tradeGroupList.resultList}"
                nodes="#{dir.tradeGroups}"
                var="dir"
                nodeSelectListener="#{yourListener.processSelection}>"