Pages

Saturday, April 06, 2013

JSF 2.x Tip of the Day: JSF Expression Language (EL) Keywords and Implicit Objects

A friend of mine asked me if there was a list of reserved words in EL and JSF. He had previously looked for it, and after some Google searching I didn't find a comprehensive list anywhere. I decided to create one for him and anyone else who may need it. If you are aware of any other keywords, please post a comment and I will add them to the listings.

Expression Language (EL) Reserved Keywords
Value Description
and Logical operator alternative to (&&)
false Boolean literal
le Relation operator less than or equal to alternative to (<=)
not Logical operator reverse alternative to (!)
div Arithmetic operator division alternative to (/)
ge Relational operator greater or equal to alternative to (>=)
lt Relational operator less than alternative to (<)
null Null literal
empty The empty operator is a prefix operation that can be used to determine whether a value is null or empty.
gt Relational operator greater than alternative to (>)
mod Arithmetic operator modulo alternative to (%)
or Logical operator alternative to (||)
eq Logical operator alternative to (==)
instanceof Java Keyword to do a Class comparison between Objects
ne Relational operator not equal alternative to (!=)
true Boolean literal


JSF 2.x Expression Language (EL) Implicit Objects
Value Description
application This provides user access to the ApplicationContext implementation of ServletContext that represents a web application's execution environment.
Note: This is not related to the JSF Application object.
applicationScope Maps application-scoped variable names to their values.
cc Implicit EL object that provides access to the JSF Composite Component. cc refers to the top level composite component processed at the time of evaluation
component Implicit EL object representing javax.faces.component.UIComponentfor the current component.
cookie Maps a cookie name to a single cookie.
facesContext The FacesContext instance for the current request.
flash Provides user access to the EL implicit javax.faces.context.Flash object. It may additional obtained via #{facesContext.externalContext.flash}. The implementation must ensure that the flash is usable from both JSP and from Facelets for JSF 2.
header Maps a request header name to a single value.
headerValues Maps a request header name to an array of values.
initParam Maps a context initialization parameter name to a single value.
param Maps a request parameter name to a single value.
paramValues Maps a request parameter name to an array of values.
request EL implicit object for current request.
requestScope Maps request-scoped variable names to their values.
resource EL implicit object for javax.faces.application.ResourceHandler.
session Provides EL access to the current HttpSession object.
sessionScope Maps session-scoped variable names to their values.
view Provides access to the javax.faces.component.UIViewRoot for the current instance.
viewScope Maps view-scoped variable names to their values.

No comments:

Post a Comment