What is JSF?
JavaServer Faces (JSF) is a MVC web framework that simplifies the construction of user interfaces (UI) for server-based applications by using reusable UI components in a page.JSF provides facility to connect UI widgets with data sources and to server-side event handlers. The JSF specification defines a set of standard UI components and provides an Application Programming Interface (API) for developing components.JSF enables the reuse and extension of the existing standard UI components.Benefits
JSF reduces the effort in creating and maintaining applications which will run on a Java application server and will render application UI on to a target client.JSF facilitates Web application development by- providing reusable UI components
- making easy data transfer between UI components
- managing UI state across multiple server requests
- enabling implementation of custom components
- wiring client side event to server side application code
JSF UI component model
JSF provides developers capability to create Web application from collections of UI components that can render themselves in different ways for multiple client types (for example HTML browser, wireless or WAP device).JSF provides
- Core library
- A set of base UI components - standard HTML input elements
- Extension of the base UI components to create additional UI component libraries or to extend existing components.
- Multiple rendering capabilities that enable JSF UI components to render themselves differently depending on the client types
SF technology is a framework for developing, building server side User Interface Components and using them in a web application.JSF technology is based on the Model View Controller (MVC) architecture for separating logic from presentation.
What is MVC Design Pattern?
MVC design pattern designs an application using three separate modules:Module | Description |
---|---|
Model | Carries Data and login |
View | Shows User Interface |
Controller | Handles processing of an application. |
Web Designers have to concentrate only on view layer rather than model and controller layer. Developers can change the code for model and typically need not to change view layer.Controllers are used to process user actions. In this process layer model and views may be changed.
JSF Architecture
A JSF application is similar to any other Java technology-based web application; it runs in a Java servlet container, and contains- JavaBeans components as models containing application-specific functionality and data
- A custom tag library for representing event handlers and validators
- A custom tag library for rendering UI components
- UI components represented as stateful objects on the server
- Server-side helper classes
- Validators, event handlers, and navigation handlers
- Application configuration resource file for configuring application resources
JSF provides several mechanisms for rendering an individual component. It is upto the web page designer to pick the desired representation, and the application developer doesn't need to know which mechanism was used to render a JSF UI component.
JSF application lifecycle consist of six phases which are as follows
- Restore view phase
- Apply request values phase; process events
- Process validations phase; process events
- Update model values phase; process events
- Invoke application phase; process events
- Render response phase
Phase 1: Restore view
JSF begins the restore view phase as soon as a link or a button is clicked and JSF receives a request.During this phase, the JSF builds the view, wires event handlers and validators to UI components and saves the view in the FacesContext instance. The FacesContext instance will now contains all the information required to process a request.
Phase 2: Apply request values
After the component tree is created/restored, each component in component tree uses decode method to extract its new value from the request parameters. Component stores this value. If the conversion fails, an error message is generated and queued on FacesContext. This message will be displayed during the render response phase, along with any validation errors.If any decode methods / event listeners called renderResponse on the current FacesContext instance, the JSF moves to the render response phase.
Phase 3: Process validation
During this phase, the JSF processes all validators registered on component tree. It examines the component attribute rules for the validation and compares these rules to the local value stored for the component.If the local value is invalid, the JSF adds an error message to the FacesContext instance, and the life cycle advances to the render response phase and display the same page again with the error message.
Phase 4: Update model values
After the JSF checks that the data is valid, it walks over the component tree and set the corresponding server-side object properties to the components' local values. The JSF will update the bean properties corresponding to input component's value attribute.If any updateModels methods called renderResponse on the current FacesContext instance, the JSF moves to the render response phase.
Phase 5: Invoke application
During this phase, the JSF handles any application-level events, such as submitting a form / linking to another page.Phase 6: Render response
During this phase, the JSF asks container/application server to render the page if the application is using JSP pages. For initial request, the components represented on the page will be added to the component tree as the JSP container executes the page. If this is not an initial request, the component tree is already built so components need not to be added again. In either case, the components will render themselves as the JSP container/Application server traverses the tags in the page.After the content of the view is rendered, the response state is saved so that subsequent requests can access it and it is available to the restore view phase.
thank you.
ReplyDeletepython3 tutorial
JSF tutorial