2 Replies Latest reply on Dec 31, 2010 10:15 PM by eevictim

    How do I find node level / depth of recursive tree table?


      Using Studio Edition Version

      After 2-3 days of banging my head up against the monitor, I'm ready to ask for help. I admit it: I'm a noob, and can't figure out how to get the node level / depth of a treeTable. I haven't seen this mentioned in the forums or in any of the treeTable examples on the various blogs. Google, God praise it, has failed me as well.

      In my Parent->Child->Recursive Child (References Child's view object) tree table I've tried:

      1) Various EL expressions (my EL sucks) in an output text within the node. Hoping that something like #{node.HierTypeBinding.Parent.etc.} would yield some kind of valuable info I could manipulate.
      2) Setting the node value to a managed bean, but don't know how to get the currently rendered node. I can only figure out how to get the currently selected node, which is only helpful after the table has already been rendered.
      3) Creating a transient field called Level in the Child view object and setting its ViewRowImpl equal to the parent's Level + 1, but if the Child has multiple parents, I get incorrect calculations. I got the farthest with this, but eventually gave up. Accessing entities via ViewLinks works great for moving through child rows, but trying to get a node's parent is baffling if you've got multiple parents.
      4) Both saying "Please!" and various colorful four-letter metaphors. Neither had much of an effect.

      Any kind of general direction or help would be great.

      Thanks guys,
        • 1. Re: How do I find node level / depth of recursive tree table?
          Navaneetha Krishnan Nataraj
          Based on table Employees in HR Schema, a view link is defined between the employe-id and manager-id.
          When a view instance based on the above is used as tree table (recursive), I am able to find the depth of the node.

          Code Sample:
          JSPX code fragment:

          <af:treeTable value="#{bindings.Employees.treeModel}" var="node"
          rowSelection="single" id="tt1"
          <f:facet name="nodeStamp">
          <af:column id="c1" width="400px">
          <af:outputText value="#{node}" id="ot2"/>
          *<af:outputText value="#{bindings.Employees.treeModel.depth}"*
          <f:facet name="pathStamp">
          <af:outputText value="#{node}" id="ot1"/>

          <tree IterBinding="EmployeesIterator" id="Employees">
          <nodeDefinition DefName="model.vo.EmployeesVO" Name="Employees0">
          <Item Value="EmployeeId"/>
          <Item Value="FirstName"/>
          <Item Value="LastName"/>
          <Item Value="EmployeesVO"/>

          Can you map the same in your scenario and see if you can get the depth of a node?

          • 2. Re: How do I find node level / depth of recursive tree table?
            Navaneeth, that'll do it. Noobs everywhere salute you.

            To get the depth of a tree ....

            #{bindings.<your tree model>.treeModel.depth}

            I should have looked in my tree binding for a function. I KNEW I had to be overlooking something straightforward. The only explanation I can stammer out for my gross incompetence would be poor genetics.

            Really, thanks alot. I'd be lost without these forums.