n_g
n_g

Reputation: 3545

How to create a left navigation pane using facelets in JSF?

I need to create a user interface where the content changes every time the user moves to a new page. However, the header and footer remains the same.

But, within the content, there is sometimes a left pane visible on some of the pages. I'm not sure how can this be achieved since I'm new to using JSF.

Can someone please suggest a way?

Thanks!

Upvotes: 0

Views: 2813

Answers (2)

skuntsel
skuntsel

Reputation: 11742

For the 'puzzly' composition of pages you need to use templating. Great overview can be found in the answer to How to include another XHTML in XHTML using JSF 2.0 Facelets?. The layout itself is HTML/CSS-related, so you need to check that out first.

If you want to produce one part of a template conditionally, there are two possibilities: to do that from a master template, or to do it from a template client. Of course, you could create many templates, as others recommend, but this is counterproductive and hard to maintain in my opinion.

If you want to render a part of template conditionally, you can include rendered="#{view.viewId = '...'}" attribute to JSF components in master template.

Alternatively, if you want to 'overwrite' the default part of a template, that for example has a left panel, just define the target area as an empty one in a template client like <ui:define name="left" />.

Upvotes: 0

NullPointerException
NullPointerException

Reputation: 3814

You can achieve this by creating 2 different layouts and using for the correct layout

  • one with left rail
  • another without left rail

You need to look at JSF template with Facelets

Here are some links that you can refer

Upvotes: 1

Related Questions