JSF
What are differences between struts and JSF?
Dec 1st
In a nutshell, Faces has the following advantages over Struts:
- Eliminated the need for a Form Bean
- Eliminated the need for a DTO Class
- Allows the use of the same POJO on all Tiers because of the Backing Bean
The primary advantages of Struts as compared to JavaServer Faces technology are as follows:
- Because Struts is a web application framework, it has a more sophisticated controller architecture than does JavaServer Faces technology. It is more sophisticated partly because the application developer can access the controller by creating an Action object that can integrate with the controller, whereas JavaServer Faces technology does not allow access to More >
How do you declare the managed beans in the faces-config.xml file?
Nov 27th
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.
Is it possible to have more than one Faces Configuration file?
Nov 26th
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
javax.faces.CONFIG_FILES
/WEB-INF/faces-config1.xml, /WEB-INF/faces-config2.xml, /WEB-INF/faces-config3.xml
How to declare the page navigation (navigation rules) in faces-config.xml file ?
Nov 26th
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:
/index.jsp
login /welcome.jsp
This declaration states that the login action navigates to /welcome.jsp, if it occurred inside /index.jsp.
How do you declare the managed beans in the faces-config.xml file?
Nov 26th
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 classcom.developersBookJsf.loginBean, give it the name login, and keep it alive for the duration of the request.
What if no navigation rule matches a given action?
Nov 26th
If no navigation rule matches a given action, then the current page is redisplayed.
What are the JSF life-cycle phases?
Nov 26th
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
Explain briefly the life-cycle phases of JSF?
Nov 26th
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 More >
What does it mean by render kit in JSF?
Nov 26th
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.
What are the different kinds of Bean Scopes in JSF?
Nov 26th
JSF supports three Bean Scopes. viz.,
- Request Scope: The request scope is short-lived. It starts when an HTTP request is submitted and ends when the response is sent back to the client.
- Session Scope: The session scope persists from the time that a session is established until session termination.
- Application Scope: The application scope persists for the entire duration of the web application. This scope is shared among all the requests and sessions.
