1

i have a jsf 1.2 / rich faces 3.2.2 project (with java 6). i want to display menu bar conditionally depending on type of user logged in. From the question How to conditionally include a file in my template using JSF and Facelets? i tried the following:-

...
<td valign="top" align="left" height="100%">
</f:verbatim> 
 <jsp:include page="../Menu${authenticateBean.menuSuffix}.jsp" /> <f:verbatim></td>
...
i also tried 
  <jsp:include page="../Menu#{authenticateBean.menuSuffix}.jsp" />
...

where authenticateBean.menuSuffix is a string that will return "A" or "B" and ultimately, theoretically "MenuA.jsp" or "MenuB.jsp" page should include in my page. but i get following error

javax.servlet.ServletException: File &quot;/pages/includes/LeftPan.jsp&quot; not found

Help. Plz.

Community
  • 1
  • 1
learner
  • 757
  • 2
  • 14
  • 35

1 Answers1

0

Heres how I managed it. Placing as an answer if ne one needs…

<%
AuthenticateBean authBean=
((AuthenticateBean)FacesUtils.getManagedBean(AuthenticateBean.MANAGED_NAME));
    String panSuffix = authBean.getPanSuffix();
String impPage = "../includes/Menu"+ panSuffix +".jsp";
 %>
 .
 .
 .  
<jsp:include page="<%= impPage %>" />

In the getPanSuffix() i have placed business logic that checks the type of user logged on and return a string accordingly. for Type "A" user. MenuA.jsp would display and for type "B" user MenuB.jsp would display. May be a primitive way of doing things but worked for me. Thanks All.

learner
  • 757
  • 2
  • 14
  • 35