How to compare String value in Expression Language when using JSF
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'}"/>