GeeCON Prague 2014*
The moose likes JSF and the fly likes How to hide or display jsf pages based on type of user question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "How to hide or display jsf pages based on type of user question" Watch "How to hide or display jsf pages based on type of user question" New topic
Author

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

Dan MacLeod
Ranch Hand

Joined: Mar 19, 2009
Posts: 30
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

Joined: Jun 25, 2001
Posts: 16103
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: How to hide or display jsf pages based on type of user question