JSF Expression Language - JavaServer Faces (JSF)

What is JSF Expression Language?

A rich expression language is facilitated by JSF which enables to write the normal operations using #{operations-expression}.

What are the advantages of JSF Expression Language?

JSF Expression Language has some of the advantages like:

  • JSF Expression Language can refer bean properties where bean can be a stored object of the request, a session or application scope or a managed bean.
  • Enables to easily access the elements of a collection which can be list, map or an array.
  • Enables to easily access the predefined objects like request.
  • JSF Expression Language facilitates in Arithmetic, logical and relational operations.
  • Automatic Type Conversion.
  • Enables display of the missing values as empty string instead of NullPointerException.

Example Application

A test JSF application is created to test expression language.

Step
Description
1
Create a project with a namehelloworldunder a packagecom.wisdomjobs.testas explained in theJSF - First Applicationchapter.
2
ModifyUserData.javaunder packagecom.wisdomjobs.testas explained below.
3
Modifyhome.xhtmlas explained below. Keep the rest of the files unchanged.
4
Compile and run the application to make sure the business logic is working as per the requirements.
5
Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver.
6
Launch your web application using appropriate URL as explained below in the last step.

UserData.java

home.xhtml

Once all the changes are done, the application is compiled and run as in JSF – Create Application chapter. On successful creation of the application, the result appears as:

JSF Expression Language

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JavaServer Faces (JSF) Topics