JSF EL and Implicit Objects

Expression Language (EL), provides an important mechanism for enabling the presentation layer (facelets) to communicate with the application logic. JSF EL expressions can refer to the following objects and their properties or attributes:
  • JavaBeans components
  • Collections
  • Java SE enumerated types
  • Implicit object

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 #{falsh.now} (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
and
Logical And                                                          &&
or
Logical OR                                                            ||
le
Relational less than or equal to                            <=
ge
Relational greater than or equal to                       >=
lt
Relational less than                                               <
gt
Relational greater than                                         >
null
Null literal
empty
To determine whether a value is null or empty.
mod
Arithmetic operator modulo                                   %
not
Logical Opposite                                                   !
div
Arithmetic operator division                                    /
eq
Equal to                                                               ==
ne
Not equal to                                                        !=
instanceof
 Java Keyword, is object an instance of the
 given class?
true
Boolean true
false
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
  • ? :


14 comments:

  1. Thank you so much. Clear and Direct. Much Thanks. Love your Blog.

    ReplyDelete
  2. It helped me so many time. Thanks

    ReplyDelete
  3. Really thanks for posting such an useful and informative stuff...

    iib tutorial

    ReplyDelete
  4. Thanks for posting such an useful and informative stuff...

    informatica online training

    ReplyDelete
  5. Forex Signals, MT4 and MT5 Indicators, Strategies, Expert Advisors, Forex News, Technical Analysis and Trade Updates in the FOREX IN WORLD

    Forex Signals Forex Strategies Forex Indicators Forex News Forex World

    ReplyDelete

  6. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.i want to share about websphere online training .


    ReplyDelete
  7. Electro smart television is a more used product in middle class families in Bangladesh. It ensures your eye health protection, reduces electricity and super speedy ram and processor 2500GB expandable memory super glossy panel USB HDMI CCTV VGA port Warranty 08 years papers Wireless mouse usable & boxes with the good sound system.

    ReplyDelete
  8. Hello All !
    I am a seoer in HCM VN
    My bussiness supply Air conditioning and install them for office house
    I come here to study the new knowledge

    ReplyDelete