Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><em>I tried making a composite component that called itself recursively if the node had more children. I did this via and -- surprise! -- this resulted in an infinite loop and a stack overflow.</em></p> </blockquote> <p>It failed because <code>rendered</code> attribute isn't evaluated during building the JSF component tree, but only during generating the HTML output. You basically need JSTL <code>&lt;c:if&gt;</code> instead of <code>&lt;some:component rendered&gt;</code>. <a href="https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense">It runs during building the JSF component tree</a>, so you don't end up in infinitely including the composite itself.</p> <hr> <blockquote> <p><em>The project already has PrimeFaces installed, so I'm looking at PrimeFaces Tree and TreeNode. But that doesn't quite feel right; I don't want the tree nodes to be expandable in the user interface. I want everything to be fully expanded.</em></p> </blockquote> <p>The JSF utility library <a href="http://omnifaces.org" rel="nofollow noreferrer">OmniFaces</a> has exactly the component you're looking for, the <code>&lt;o:tree&gt;</code>. That component doesn't generate any HTML markup by itself, so you've all the freedom to declare the HTML/JSF markup the way you want, also for specific depth levels.</p> <p><a href="http://showcase.omnifaces.org/components/tree" rel="nofollow noreferrer">Here's the showcase example</a>. Note the links at the bottom of the page, they point to the source code which may be helpful/interesting as learning exercise. It isn't exactly trivial as you perhaps initially thought while developing the composite (which is after all not exactly <a href="https://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/6822269#6822269">the right tool for the job</a>).</p> <p>As to distinguishing leaf nodes, the <code>&lt;o:tree&gt;</code> offers this possibility as follows:</p> <pre><code>&lt;o:tree value="#{bean.tree}" var="item" varNode="node"&gt; &lt;o:treeNode&gt; &lt;o:treeNodeItem&gt; &lt;ui:fragment rendered="#{not node.leaf}"&gt; ... &lt;/ui:fragment&gt; &lt;ui:fragment rendered="#{node.leaf}"&gt; ... &lt;/ui:fragment&gt; &lt;o:treeInsertChildren /&gt; &lt;/o:treeNodeItem&gt; &lt;/o:treeNode&gt; &lt;/o:tree&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload