Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Tabbed Panel  RSS feed

Fabio Maass
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone,

I'm struggling with the following problem:

I need a special tabbed panel for displaying a bunch of elements. The elements
implement a common interface but may be of different classes. They have a field for
the title of a tab and the path to the facelet that is used to display the element.
The tabbed panel should be completely modular, i.e. it should be able to handle new
types of elements without problems.

My first attempt was to use <ui:repeat> to loop over the elements and include their
content with <ui:include src="#{element.faceletpath}" which failed because the EL
for the src is evaluated in the view built and therefore not valid yet.

My second attempt was to replace the <ui:repeat> by a <c:forEach> which made it possible
to display the tabbed panel as I wanted. However the <c:forEach> has some side-effects
when I update the model, i.e. especially when I add a new element.

So, has anyone an idea how I could implement a tabbed panel that matches my requirements?

Tim Holloway
Posts: 18709
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Fabio!

The JSF View Template Language is not a "programming language". View definitions are expected to be static, so use of looping constructs isn't something I recommend.

As a general practice, I would recommend simply coding all of the tabs and controlling their rendering via their "render=" attributes. This is the simplest way, and no looping or client-side decision-making is required.

If you want something that's more open-ended, you can bind a backing bean property to the tab control container and dynamically attach panes in backing bean logic as needed.

I would like to draw a distinction between "maintainable" and what I might call "uncontrolled" tabset definition (I can't think of a better word, but there has to be one). A maintainable tab would be something that you could just add ui:include statements to, rebuild and deploy. An "uncontrolled" (fully dynamic) tabset requires more complicated mechanisms. Aside from that, there is a virtue in a consistent display, since users get confused enough even when the screenshots in the app documentation actually match the screen, much less when the screen display has a life of its own.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!