File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to hide or display jsf pages based on type of user question

 
Dan MacLeod
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a standard template that displays links a user can navigate to inside a footer. Is there a way to hide links (pages) based on the type of user logged into the web site. Below is a snippet of how the pages are displayed in the footer.

<c:forEach var="item" items="${sitenav.items}">
<c:choose>
<c:when test="${item.self}">
<td class="nav-f-highlighted"><c:out value='${item.label}' escapeXml='false'/></td>
</c:when>
<c:when test="${item.group}">
<td class="nav-f-group"><b><c:out value='${item.label}' escapeXml='false'/>:</b></td>
</c:when>
<c:otherwise>
<td class="nav-f-normal"><c:out value='<a href="${item.href}">${item.label}</a>' escapeXml='false'/></td>
</c:otherwise>
</c:choose>
</c:forEach>
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, JSTL on a JSF page is a bad thing. Especially since there are high-level JSF components to do things like menus so you don't have to create them the hard way out of component atoms.

If you're using container-based security, there's support for testing the user roles. Some JSF component libraries (including MyFaces Tomahawk) have the ability to code those tests as JSF attributes. When that's not possible you have to supply your own solution, which might be simply having the backing bean present is "userRole" property. Or better yet, filter the menu's datamodel and leave the logic off the JSF page entirely.

If you're using DYI (in)security, your solution will depend on the implementation of your custom security system.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic