Home > Development > Configuring user role based navigation from error page in Seam framework

Configuring user role based navigation from error page in Seam framework

Let us assume a scenario where multiple roles exist for users. But we wish to display a single error page and from this error page they should click a button (or link) and go to their respective home page.

This can be achieved by using the following code snippet which is in error.xhtml


<h:form id="errorform">
 <h3> <rich:messages errorClass="error" level="warn"/></h3>

 <h:commandLink  action="/role1/main1.xhtml" rendered="#{s:hasRole('role1')}">
 <h3>Click Here To Proceed </h3>
 </h:commandLink>
 <h:commandLink  action="/role2/main2.xhtml" rendered="#{s:hasRole('role2')}">
 <h3>Click Here To Proceed </h3>
 </h:commandLink>
 </h:form>

We will configure the redirection in pages.xml as below.


<exception class= "java.lang.RuntimeException">
 <redirect view-id="/error.xhtml">
 <message severity="warn">Cannot perform the requested operation due to error. </message>
 </redirect>
 </exception>
  • Share/Bookmark
Categories: Development Tags:
  1. No comments yet.
  1. No trackbacks yet.