0 Replies Latest reply on Feb 24, 2011 2:52 AM by jfaath

    building a tree with recursion

    jfaath

      This may not be the right forum for this but I thought I might get some helpful advice.  I want to create a simple tree where I use this include:

       

          <c:forEach items="#{items}" var="_item">

            <div>

               <a:commandLink action="#{myAction.execute}" ajaxSingle="true" reRender="layeredNav">

                 <h:outputText value="#{_item.displayName}" />

                 <f:setPropertyActionListener value="#{_item}" target="#{myAction.selection}" />

               </a:commandLink>

             </div>

             <a:include viewId="layered-nav.xhtml">

               <ui:param name="items" value="#{_item.children}" />

               <ui:param name="level" value="#{level + 1}" />

             </a:include>           

           </c:forEach>

       

      to generate a tree structure.  The indenting isn't in there, but I intend to add it.  The starting point include looks like this:

       

          <s:div id="layeredNav">

             <h:form>

               <a:include viewId="/common/layered-nav.xhtml">

                 <ui:param name="items" value="#{myAction.items}" />

                 <ui:param name="level" value="0" />

               </a:include>

             </h:form>

           </s:div>

       

      I really am just trying to create a simple indented navigation structure.  The action executes fine when clicking on an item, and during this action the "items" collection that backs this whole thing gets rebuilt from scratch.

       

      The problem is, the UI gets a little whacky.  It appears to work but eventually gets all messed up.  In the java code, the items structure is building correctly.  I'm guessing this has something to do with mixing the c:forEach tag with the other UI components?  Is there some other way to creatively do this?

       

      I'd like to use the tree control, but I was hoping to do something a little simpler and I'm not sure how easy the tree is to skin.  I am going for a very basic look here.  Can anyone offer suggestions as to the best way to go about this?

       

      Regards,

       

      JF