Angelo.Hannes
Angelo.Hannes

Reputation: 1729

JSF represent tree data as nested squares

I need to represent a tree data in JSF. But it should not look like a tree, but rather use nested squares. All my efforts did utterly fail. I tried to build a recursive composite component, but failed due to view/build time issues.

I don't think I can reuse a tree component, since they don't provide the required visual outcome.

I need some direction.

Upvotes: 1

Views: 101

Answers (1)

BalusC
BalusC

Reputation: 1108782

This is indeed not possible with a composite. You need to use a fullworthy component like as almost all those component/utility libraries have in their assortiment. Given that you want full control over the tree markup, you thus need a markupless tree component. OmniFaces has a <o:tree> component which doesn't generate any markup. As an example, if you intend to generate a <div> for every tree node, regardless of the depth level, then do so:

<o:tree value="#{bean.tree}" var="item">
    <o:treeNode>
        <o:treeNodeItem>
            <div>
                #{item}
                <o:treeInsertChildren />
            </div>
        </o:treeNodeItem>
    </o:treeNode>
</o:tree>

Upvotes: 2

Related Questions