Jsf interview questions and answers for experienced
JSF interview questions and answers for experienced
What is JSF?
JSF provides set of API’s which represents different UI Components and helps in managing state,handling events and validate user input. JSF is based on MVC architecture.
What are the different phases of JSF request processing life cycle?
There are six phases in JSF request processing life cycle
- Restore View
- Apply requests
- Process Validations
- Update model values
- Invoke applications
- Render response
What are the basis elements of JSF?
Following are the basis elements of JSF
- UI Component
- Backing Beans
- Events and Listeners
What are the different types of JSF Standard actions?
The different types of JSF Standard actions are
- Action events
- Value change events
- Data Model events
- Phase events
What is FacesServlet?
FacesServlet is the controller of JSF architecture. The FacesServlet receives all the requests and manages the request processing life cycle to generate the response. FacesServlet has to be configured in web.xml
What is Backing Bean and Managed Bean?
The Java Bean which handle or store data between the business model and UI Components are called the Backing Beans. Backing Beans contain the properties and event listener method for storing and manipulating user’s data. The backing beans that are registered with JSF using annotations or in faces-config.xml are called Managed Beans.
What are different scopes that can be given to the Managed Bean?
What is a validator? What are the different ways of validating the data in JSF?
Validators ensure the application data contains the executed content. JSF can handle the validations in following ways
- Validations inside UI Components
- Using Validator methods
- Using Validator class
How to configure the session time in JSF?
Session time out is a property that is assigned to the Session object. If user do not request or refresh the page with the specified time, the session will end.
JSF session time out can be configured in two ways
- Adding ‘session-timeout’ in web.xml
- Using setMaxInactiveInterval in code read more
What is rendered attribute?
The rendered attribute which uses Boolean EL expression indicates whether a component is currently visible or not. The property is useful when you want to hide components for specific users or based on condition. The default value of rendered attribute is true. read more
What is a validator method?
Validator methods are created when the validation is specific to the page. The validator methods are created in the backing beans and it should have the following syntax
public void methodname(FacesContext facesContext,UIComponent component,
Object objectToValidate) throws ValidatorException
If component’s value is not according to the expected, throw a new ValidatorException instance. If an exception is thrown, Jsf will automatically add the FacesMessage instance to the message queue. read more
What is a custom validator?
A custom validator in Jsf can be created by implementing javax.faces.validator.Validator interface which has a one method (validate).
public void validate(FacesContext context, UIComponent component,Object value) throws ValidatorException;
The class has to implement validate method. If component’s value is not according to the expected, throw a new ValidatorException instance. If an exception is thrown, Jsf will automatically add the FacesMessage instance to the message queue. read more
What is ‘setpropertyactionlistener’ tag?
JSF ‘<f:setPropertyActionListener>’ tag creates a special action listener and registers with the associated action. It sets value specified by ‘value’ attribute to ‘target’ attribute.It is generally used in datatable to get the record selected by the user.
Attribute Value expression
value store the value of target attribute
target defines the destination of value attribute read more
What is required attribute?
JSF required attribute accepts a boolean value . If value is set to true, the user has to enter the value for the UI Component.The default value is false.
Articles related to Jsf interview questions and answers for experienced