JSF Web framework and facelets presentation layer technology

Source: Internet
Author: User

JSF (JavaServer Faces)

The life cycle of a JSF application starts when the client makes an HTTP request to the page and ends when the server responds to the page.
The JSF lifecycle is divided into two major phases of the run and render phases.

Implementation phase

When you first request, build or restore the application view. For other subsequent requests, perform additional operations.
The execution phase is further divided into the following sub-stages:

    • Restore View Stage
    • Apply Request Value Stage
    • Process Validation Phase
    • Update Model Value Stage
    • Invoke the application phase
    • Render Response Phase
Rendering phase

At this stage, the requested view acts as a response to the client browser. View rendering is the process of generating output in HTML or XHTML.
Take the following steps during the rendering process:

    1. The application is compiled when the client makes an initial request to the Index.xhtml Web page.
    2. The application is executed after compilation, and a new component tree is built for the application and placed in the Facescontext.
    3. Populates a component tree with a component represented by an El expression and its associated managed bean properties.
    4. Based on the component tree. A new view is created.
    5. The view is rendered as a response to the requesting client.
    6. The component tree is automatically destroyed.
    7. In subsequent requests, the component tree is rebuilt and the saved state is applied.

The JSF implementation uses a controller servlet to process the request and then executes the JSF life cycle.
Shows event handling in the JSF life cycle.

JSF is event-driven, starting with the application request value phase, where the JSF implementation creates events and adds them to the event queue during each life cycle phase.

Event Type

(1) Action event: normal action response.
(2) Instant events (Immediate event): Process immediately, do not validate/convert/update model values (i.e. beans do not save attributes).
(3) Value changing event (Value change events): Cascade scheduling after selecting UI value changes. such as internationalization of the choice of language.
(4) Stage event (Phase event): The JSF lifecycle of the listener response.

Event listeners can affect the JSF lifecycle in one of the following three ways:
(1) Let the life cycle proceed normally.
(2) Call the Renderresponse method of the Facescontext class to skip the rest of the life cycle and jump directly to the render response stage.
(3) Call the Responsecomplete method of the Facescontext class to completely skip the other phases of the life cycle.

Reference Source:

Yi Hundred Tutorials: https://www.yiibai.com/jsf/jsf-life-cycle.html
Open source China: https://my.oschina.net/zhaoqian/blog/71866
Baidu Encyclopedia: Https://baike.baidu.com/item/jsf%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F

Facelets definition

Facelets is a lightweight page-declaration language used to build JSF views using HTML styles.
Facelets is an alternative presentation layer technique for building JSF applications.
Facelets provides a powerful templating system that uses HTML-style templates to define the performance layer of JSF, reducing the code that is redundant when components are integrated into the presentation layer.

Function
    • Create a Web page using XHTML
    • In addition to supporting JSF and jslt tag libraries, the Facelets tag library is also available
    • Support Expression Language (EL)
    • Working with components and page templates
Advantages
    • Adding code reusability through templates and composite components
    • Provides functional extensibility of components and other server-side objects by customizing
    • Faster compile times
    • Validating expression language at compile-time
    • High performance rendering capabilities

JSF (JavaServer Faces) technology supports a variety of tag libraries to add components to a Web page. To support the JavaServer Faces tag library mechanism, Facelets uses XML namespace declarations.
Facelets supports a library of JSF facelets tags, a JSF HTML tag library, a JSF core tag library, a pass-through element tag library, a delivery property tag library, a composite component tag library, a JSTL core tag library, and a JSTL function tag library.

Facelets the life cycle of an application
    1. The life cycle begins when a Web page created by a client using Facelets makes a new request. JSF creates a new component tree or Javax.faces.component.UIViewRoot and puts it in Facescontex.
    2. If the available uiviewroot are applied to facelets, the view can populate the component for rendering.
    3. The newly created view is rendered as a response to the client.
    4. When rendering, the state that stores this view is used for the next request. Stores the status of input components and form data.
    5. The client can interact with the view and request another view from the JSF application. At this point, the saved view resumes from the storage state.
    6. The recovery view passes through the JSF lifecycle again, and if there is no validation problem and no action is triggered, eventually a new view is generated or the current view is re-rendered.
    7. If the same view is requested, the stored view is rendered again.
    8. If a new view is required, proceed to step 2nd.
    9. The new view is used as a response to the client.
Reference Source:

Yi Hundred Tutorials: https://www.yiibai.com/jsf/facelets.html
Baidu Encyclopedia: Https://baike.baidu.com/item/facelets/10077801?fr=aladdin

JSF Web framework and facelets presentation layer technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.