Q: What is
the difference between JSP-EL and JSF-EL?
JSP-EL JSF-EL
In JSP-EL the value expressions are delimited
by ${…}. In JSf-EL the value expressions
are delimited by #{…}.
The ${…} delimiter denotes the immediate
evaluation of the expressions, at the time that
the application server processes the page. The
#{…} delimiter denotes deferred evaluation.
With deferred evaluation ,the application server
retains the expression and evaluates it whenever
a value is needed.
note:As of JSF 1.2
and JSP 2.1 ,the syntax of both expression languages
has been unified.
Q: What are
The main tags in JSF?
JSF application typically uses JSP pages to
represent views. JSF provides useful special
tags to enhance these views. Each tag gives
rise to an associated component. JSF (Sun Implementation)
provides 43 tags in two standard JSF tag libraries:
• JSF Core Tags Library.
• JSF Html Tags Library.
18. How do you declare the managed beans in
the faces-config.xml file?
The bean instance is configured in the faces-config.xml
file:
<managed-bean>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>com.developersBookJsf.loginBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
This means: Construct
an object of the class com.developersBookJsf.loginBean,
give it the name login, and keep it alive for
the duration of the request.
Q: How to declare
the Message Bundle in JSF?
We can declare the message bundle in two ways:
(Let’s assume com.developersBookJsf.messages
is the properties file)
1. The simplest way is to include the following
elements in faces-config.xml file:
<application>
<resource-bundle>
<base-name>com.developersBookJsf.messages</base-name>
<var>message</var>
</resource-bundle>
</application>
2. Alternatively, you can add the f:loadBundle
element to each JSF page that needs access to
the bundle:
<f:loadBundle
baseName = “com.developersBookJsf.messages”
var=”message”/>
Q: How to declare
the page navigation (navigation rules) in faces-config.xml
file ?
Navigation rules tells JSF implementation which
page to send back to the browser after a form
has been submitted. We can declare the page
navigation as follows:
<naviagation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</naviagation-rule>
This declaration states that the login action
navigates to /welcome.jsp, if it occurred inside
/index.jsp.
Q: What if
no navigation rule matches a given action?
If no navigation rule matches a given action,
then the current page is redisplayed.
Q: What are the JSF life-cycle phases?
The six phases of the JSF application lifecycle
are as follows (note the event processing at
each phase): 1. Restore view
2. Apply request values; process events
3. Process validations; process events
4. Update model values; process events
5. Invoke application; process events
6. Render response
Q: Explain briefly the life-cycle phases
of JSF?
1. Restore View : A request comes through the
FacesServlet controller. The controller examines
the request and extracts the view ID, which
is determined by the name of the JSP page.
2. Apply request values: The purpose of the
apply request values phase is for each component
to retrieve its current state. The components
must first be retrieved or created from the
FacesContext object, followed by their values.
3. Process validations: In this phase, each
component will have its values validated against
the application's validation rules.
4. Update model values: In this phase JSF updates
the actual values of the server-side model ,by
updating the properties of your backing beans.
5. Invoke application: In this phase the JSF
controller invokes the application to handle
Form submissions.
6. Render response: In this phase JSF displays
the view with all of its components in their
current state.
Q: What does it mean by render kit in JSF?
A render kit defines how component classes map
to component tags that are appropriate for a
particular client. The JavaServer Faces implementation
includes a standard HTML render kit for rendering
to an HTML client.
Q: Is it possible to have more than
one Faces Configuration file?
We can have any number of config files. Just
need to register in web.xml.
Assume that we want to use faces-config(1,2,and
3),to register more than one faces configuration
file in JSF,just declare in the web.xml file
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces-config1.xml,
/WEB-INF/faces-config2.xml,
/WEB-INF/faces-config3.xml
</param-value>
</context-param>