简体   繁体   中英

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!

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

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" /> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM