Java EL implicit objects


What are Expression Language Implicit Objects?
JSF framework provides several objects related to current request being processed and/or execution environment. These objects aka Implicit Objects can be accessed at runtime in a facelet or backing bean using EL. Although you can access implicit objects using EL and JEE Servlet API as well, having predefined objects comes in handy.

Here is a handy reference of JSF Implicit Objects:

JSF 2.x Expression Language (EL) Implicit Objects

  1. facesContext: an instance of FacesContext. FacesContext contains all of the per-request state information related to the processing of a single JavaServer Faces request, and the rendering of the corresponding response.
  2. application: an instance of the ServletContext. A ServletContext instance provides access to the execution environment i.e. the servlet container.
  3. initParam: A Map of the initialization parameters of this web application.
  4. session: an instance of HttpSession.  A HttpSession can be used to bind objects, get  information about a session, such as the session identifier, creation time, and last accessed time. Session information is scoped only to the current web application (ServletContext), so information stored in one context will not be directly visible in another
  5. view: The current UIViewRoot for this view. UIViewRoot is the UIComponent that represents the root of the UIComponent tree.
  6. component: The UIComponent instance being currently processed at the time of evaluation.
  7. cc: The top-level composite component currently being processed.
  8. request: an instance of HttpServletRequest.
  9. applicationScope: A Map (name and value) of all application scope attributes.
  10. sessionScope: A Map (name and value) of all attributes in the current session.
  11. viewScope: A Map (name and value) of all attributes in the current view scope.
  12. requestScope: A Map (name and value) of all attributes in the current request being processed.
  13. flowScope:*   #{flowScope}, for flow local storage. This maps to facesContext.getApplication().getFlowHandler().getCurrentFlowScope().
  14. flash: A Map for forwarding  temporary objects between the user/next views generated by the faces lifecycle or the current view using #{} (see flash.putNow( ..)).
  15. param: A Map (name and value) of HTTP request parameters, containing only the first value for each name.
  16. paramValues: A Map of HTTP request parameters, yielding a String[] array of all values for a given name.
  17. header: A Map of HTTP header parameters for the current request.
  18. headerValues: A Map of HTTP header parameters for the current request, yielding a String[] array of all values for a given name.
  19. cookie: A Map of the cookie names and values of the current request.
  20. resource: A Map of application resources.
  21. pageContext  ${pageContext.request.contextPath}

* New in JSF 2.2

Expression Language (EL) Operators

Operator Description                                                          Symbol Operator
Logical And                                                          &&
Logical OR                                                            ||
Relational less than or equal to                            <=
Relational greater than or equal to                       >=
Relational less than                                               <
Relational greater than                                         >
Null literal
To determine whether a value is null or empty.
Arithmetic operator modulo                                   %
Logical Opposite                                                   !
Arithmetic operator division                                    /
Equal to                                                               ==
Not equal to                                                        !=
 Java Keyword, is object an instance of the
given class?
Boolean true
Boolean false
All the above operators are reserved for the EL and should not be used as identifiers

The precedence of operators highest to lowest, left to right is as follows:

  • [] .
  • () (used to change the precedence of operators)
  • - (unary) not ! empty
  • * / div % mod
  • + - (binary)
  • < > <= >= lt gt le ge
  • == != eq ne
  • && and
  • || or
  • ? :