Archive

Posts Tagged ‘Seam’

Configuring user role based navigation from error page in Seam framework

November 24th, 2009 Karthikeyan C No comments

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:

How to compare String value in Expression Language when using JSF

November 20th, 2009 Karthikeyan C No comments

Assume we need to compare the value of a String value and then display value accordingly. An example to quote will be displaying the sex of the candidate depending on the value of an attribute of a backing bean resumeviewaction.

The below code shows how to accomplish the same using equals and not equals.

<h:outputText value="#{resumeviewaction.resume.sex eq 'M' ? 'Male':'Female'}"/>

Now using not equals the same can be written in the Expression Language as

<h:outputText value="#{resumeviewaction.resume.sex ne 'M' ? 'Female':'Male'}"/>
  • Share/Bookmark
Categories: Development Tags: ,