JSF Interview Questions

Java Quick Notes

Refresh Your Java

We are Agile, believe in less Documentation - Only Quick notes of Java/J2ee Read more....

Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

"Click on other Tabs for more Questions"  

"JSF "


1 )   What is JSF ?


JavaServer Faces (JSF) is a Java-based Web application framework intended to
simplify development integration of web-based user interfaces.

JSF is a request-driven MVC web framework for constructing user interfaces using
components. As a display technology, JSF 2 uses Facelets. JSF 1.x uses JavaServer
Pages (JSP) for its displaytechnology.

One of the very imporant features of JSF is it's "A server-side event model"

A server-side event model : For dispatching events and attaching listeners to
core system functionality, such as "Before Render Response" or "After Validation"

Back to top

2 )   What are the LifeCycle Phases of JSF page ?


  • LifeCycle Phases of JSF page
    Sample Img 2

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

Phase 1: Restore view
In the first phase of the JSF lifecycle -- 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.

Phase 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. Component values are typically retrieved from the request parameters,
 although they can also be retrieved from cookies or headers.
Phase 3: Process validation

The first event handling of the lifecycle takes place after the apply request values phase.
At this stage, each component will have its values validated against the application's
validation rules. The validation rules can be pre-defined (shipped with JSF) or defined by the developer

Phase 4: Update model values

The fourth phase of the JSF application lifecycle -- update model values -- updates the actual
values of the server-side model -- namely, by updating the properties of your backing beans
(also known as managed beans).

Phase 5: Invoke application
At the fifth phase of the lifecycle -- invoke application -- the JSF controller invokes the
application to handle Form submissions.

Phase 6: Render response

In the sixth phase of the lifecycle -- render response -- you display the view with all
of its components in their current state.

Back to top

3 )   JSF Tags for html components ?


Tag Libs to be included :

<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

HTML form:

... other JavaServer Faces tags and other content...

Hyper Link:

<h:commandLink id="check"
  rendered="#{cart.numberOfItems > 0}">

Table :

<h:dataTable id="items"
    <f:facet name="header">
      <h:outputText value="#{bundle.ItemQuantity}"/>
      <f:validateLongRange minimum="1"/>

Back to top

4 )   Sample "faces-config.xml" ?



"faces-config" is going to have two high level Elements "navigation-rule" and  "managed-bean"


<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"



Back to top

5 )   Sample Event Handling in JSF ?


Event Handling :

<h:selectOneRadio id="category"
    <f:selectItems value="#{CDManagerBean.categories}"/>

Event Handling Method :

public void categorySelected(ValueChangeEvent event) {

    String value = (String) event.getNewValue();

    if (value != null) {
        this.subCategories = this.getSubcategoriesList(value);

    FacesContext context = FacesContext.getCurrentInstance();

Managed Bean :

  <description>The "backing file"
    bean that backs up the CD application</description>

Back to top

6 )   How to add "FacesServlet" to Web.xml for a JSF application ?


Make for JSF has different "url-pattern" other than JSP.

<!-- JSF -->
    <servlet-name>Faces Servlet</servlet-name>

Back to top

Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,

This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.

Face Book

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free

Go To Site Map