Java Server Faces Interview Preparation Guide
Download PDF

Java Server Faces frequently Asked Questions by expert members with experience in Java server faces. These interview questions and answers on Java Server Faces will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the Java Server Faces job interview

18 Java Server Faces Questions and Answers:

1 :: What is Apache Tomahawk?

A series of JSF components are provided by MyFaces Tomahawk. Tomahawk provides several custom components that are 100% JSF compatible components. It is easier to implement JSF projects with Tomahawk. The extended functionalities are – improved inputText components, Converter interfaces and solutions to use JSF and Tiles together.

2 :: What is Facelets?

The JSF and JSP are aligned in a web application; Facelets provides a high performance JSF-centric view which is the outside of JSP specification. The designing of Facelets are similar to that of JSP creation. The difference between these is that, the entire JSP vendor API is removed and enhances the JSF performance which provides easy plug-and-go development.

3 :: Explain Shale?

Shale is a framework for web applications, based on JSF. Shale architecture includes a set of loosely coupled services which can be combined to meet specific application requirements. The additional functionality provided by Shale - application event callbacks, dialogs with conversation-scoped state, a view technology named Clay, annotation-based functionality. These functionalities will reduce the requirement of configuration and provides support for remote computing. Other framework links for integration is provided by Shale, which eases the combined technology based development.

4 :: What is Seam?

Seam is a framework for web application, which combines the existing popular frameworks – EJB and JSF. A back-end component of an enterprise (EJB) can be accessed by the front-end by addressing its name of the Seam component.

The concept of ‘context’ is expanded by Seam. The context contains each Seam component. The context of a session captures the actions of all logged in users until he logs out. A command line tool seam-gen can be used to automatically generate the actions – create, read, update, delete (CRUD) of a web application. The integration of Seam can be with JBOSS, RichFaces or ICEFaces AJAX libraries.

5 :: What is JSF Taglibs?

The JSF Taglibs are of two.

HTML Tag lib
Core Tag lib

HTML Tag lib: This tag library contains all the tags that pertains all the tags that are to deal with forms and other HTML-specific stuff.

Core Tag lib: The Core Tag lib contains the tags that pertaining all the tags that are to deal with logic, validation, controller and other JSF-specific stuff.

The two tag libs are to be specified as follows:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

6 :: What is JSF life cycle?

i. Restore view phase:
This phase starts when a user requests a JSF page by clicking a link, button etc. In this phase view generation of the page, binding of components to its event handlers and validators are performed and view is saved in the FacesContext object.

ii. Apply request values phase:
The purpose of this phase is for each component to retrieve its current state.

iii. Process validations phase:
During this phase local values stored for the component in the tree are compared to the validation rules registered for the components.

iv. Update model values phase:
After confirming that data is valid in the previous phase local values of components can be set to corresponding server side object properties i.e. backing beans.

v. Invoke application phase:
Before this phase the component values have been converted, validated, and applied to the bean objects, so you can now use them to execute the application's business logic.

vi. Render response phase:
In this phase JSP container renders the page back to the user, if jsp is used by application i.e. view is displayed with all of its components in their current state

7 :: What is JavaServer Faces, JSF?

JavaServer Faces technology includes:

A set of APIs for representing UI components and managing their state, handling events and input validation, defining page navigation, and supporting internationalization and accessibility.
A JavaServer Pages (JSP) custom tag library for expressing a JavaServer Faces interface within a JSP page.

Designed to be flexible, JavaServer Faces technology leverages existing, standard UI and web-tier concepts without limiting developers to a particular mark-up language, protocol, or client device.

Ease-of-use being the primary goal, the JavaServer Faces architecture clearly defines a separation between application logic and presentation while making it easy to connect the presentation layer to the application code.

Developed through the Java Community Process under JSR - 314, JavaServer Faces technology establishes the standard for building server-side user interfaces.

8 :: Do you know JSF and AJAX?

AJAX and JSF together makes a rich web application. AJAX usage is focused on creating richer user interfaces. The UI components in JSF and MyFaces were originally developed using HTML. AJAX-enabled components can easily be added to JSF-based User Interfaces, as JSF supports the output formats at multiple levels. The support for AJAX for the implementation of UI logic that is to run on the client and also on the server; is provided by JSF 2.0 specification. When the Java Script in the browser is disabled, JSF 2.0 provides the support for degradation.

9 :: Explain JSF Architecture?

JSF developed based on MVC design pattern. Therefore, the applications can be scaled better and well maintained. It is standardized pattern driven by Java Community Process. The advantage of JSF is both Java web user interface and a framework which perfectly fits with MVC. The presentation and behaviour of a web application is a clean separation. UI can be created by web page authors and the business logic can be utilized by managed beans. There are controllers which can be used to perform user actions.

10 :: Can you explain JSF Ajax components?

The custom web tier components for JSF can be developed using AJAX along with JSF. Using JSF the state of an application, event handling, input validation and page navigation tasks can be done for user interface components. AJAX technology is used for client side Java Script leverage in order to provide richer and more responsive user experience.

To implement the JSF component for spell check text area, the following tag is used.

<jcr: spellCheckTextArea cols="30" rows="15" value="# {user.interests}" />

This component extends HtmlInputTextArea provides a simple AJAX-enabled spell checking facility