This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Composite Recursive List

 
Robe Eleckers
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to build a multi-layer list, preferably from a composite component. The eventual result should be something like this:

This should be generated dynamically based on a structure in a backing bean. What I found so far is that it cannot be done using the c:foreach tag (it gives a stackoverflow). So therefore I started writing my own FacesComponent by implementating of the UIComponentBase which handles the recursive writing of the <ul> and <li> tags. I created a facelet-taglib for this and this works as it should.

However, I would still prefer to implement this using the composite mechanisme. Any ideas on how to do this? I do know how to create a composite component, but I do not know how to handle the 'recursiveness'.

Thanks
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17620
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, JSTL once again fails. No surprise.

I think your main constraint here is that you're thinking in HTML terms, not in JSF terms. There are other ways to render stuff like this than using <li> elements, especially for unordered lists. For example, using nested <div> elements. CSS provides a way to make divs look like listitems. Or, for that matter, like a lot of other things that used to require a discrete HTML element type.

However, that's still thinking in HTML terms, and I generally discourage use of raw HTML in JSF views. The closest JSF approximation to a div would be a single-column panelGrid.

I'm actually doing something like that for a quick-and-dirty app where I have headings that I can pop open via a mouse click.

But that's only one approach. It might actually make more sense to use one of the treeview or menu components that often come with extension tagsets.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic