0 Replies Latest reply on Jun 17, 2008 12:27 PM by Lee Theobald

    RichTree - Am I Using It Right

    Lee Theobald Newbie

      Hi all,

      I'm having a bit of a problem with my RichTree and I was wondering if someone can give what I have a quick once over to see if I'm doing things right. I'll post the code first so that the example makes more sense.

      Seam page (well the part of it!)

      <h:form id="typeForm"
       rendered="#{not empty typeHome.selectedTypeList.id}">
       <p>Selected Type = #{typeHome.selectedType}</p>
       <div><h:inputText value="#{typeListHome.example.value}" /> <h:commandButton
       action="#{typeListHome.update()}" value="Update" /></div>
      
       <div id="typeselector" class="clear">
      
       <rich:tree
       value="#{typeHome.selectedTypeList.asTreeNode}" var="item" showConnectingLines="false">
       <rich:treeNode selectedClass="selected">
       <h:outputText value="#{item.value}" />
       <a:support event="onclick" action="#{typeHome.select(item)}" reRender="typeForm" />
       </rich:treeNode>
       </rich:tree>
      
       <ul>
       <li><h:commandLink action="#{typeHome.moveFirst()}" styleClass="actionlink movefirst"
       immediate="true">
       First
       </h:commandLink></li>
       <li><h:commandLink action="#{typeHome.moveUp()}" styleClass="actionlink moveup"
       immediate="true">
       Up
       </h:commandLink></li>
       <li><h:commandLink action="#{typeHome.moveDown()}" styleClass="actionlink movedown"
       immediate="true">
       Down
       </h:commandLink></li>
       <li><h:commandLink action="#{typeHome.moveLast()}" styleClass="actionlink movelast"
       immediate="true">
       Last
       </h:commandLink></li>
       <li><h:commandLink styleClass="actionlink delete" action="#{typeHome.remove()}">
       <a:support event="onclick"
       onsubmit="return showDeleteConfirmation('type #{selectedType.value}')" />
       Delete
       </h:commandLink></li>
       <li><h:commandLink value="New" styleClass="actionlink add"
       action="#{typeHome.clearInstance()}" /></li>
       </ul></div>


      Functions that create my tree node:
      class TypeList {
      // Stuff omitted...
      
      public TreeNode getAsTreeNode() {
       TreeNode rootNode = new TreeNodeImpl();
       rootNode.setData(this);
       rootNode = addTreeNodeChildren(rootNode, getChildren());
       return rootNode;
       }
      
       public TreeNode addTreeNodeChildren(TreeNode parentNode, List<Type> children) {
       for (Type child : children) {
       TreeNode childNode = new TreeNodeImpl();
       childNode.setData(child);
       childNode.setParent(parentNode);
      
       if (child.getChildren() != null && child.getChildren().size() > 0) {
       childNode = addTreeNodeChildren(childNode, child.getChildren());
       }
      
       parentNode.addChild(child.getValue(), childNode);
       }
      
       return parentNode;
       }
      }


      TypeHome also has two properties on the conversation scope - selectedTypeList and selectedType.

      Anyway, onto the problem... When I create a new type, I assign it to selectedType. I can then use the up, down and other move buttons to move that type around in it's typelist. I also want to have it so that when you click on a type in the richtree, that item is copied to selectedType. This is happening via the Ajax4J support tag in the treenode. Trouble is, when I come to click on the move buttons - nothing happens. No errors or anything like that. The action method is never invoked after I select the item from the richtree.

      So can anyone see anything obviously wrong about how I am using the RichTree as for now I'm assuming that the way I select the items is somehow causing a problem (although it appears to select exactly the right thing).

      Cheers for any help,
      Lee