Java EE Development Technology Course Week sixth (JSF, Facelets)

Source: Internet
Author: User
Tags java web

1. JSF (Java Sever faces) 1.1 JSF definition:

JSF is a framework for building Java Web applications. It provides a component-centric approach to building a user interface (UI) that simplifies the development of Java server-side applications.

1.2 Main components:

To show the UI components and manage their state, manipulate events, server-side acknowledgements and data transformations, define page navigation, support internationalization and accessibility, and provide an API to all of the features for extensibility in order to represent the UI component in JSP and the dispatched component to two JSP custom tag libraries for server-side objects.

1.3 Technical Advantages:

The introduction of component-based and event-driven development patterns allows developers to develop Web applications in a way that is similar to dealing with traditional interfaces. Provides a clear separation of behavior and expression. Connect UI components and the Web layer without a special scripting language or Markup language. The JSF technology API is layered directly at the top of the Servlet API. Technology provides a rich architecture for managing component State, processing component data, confirming user input, and manipulating events.

1.4 Working methods:

The JSF application is event-driven when an event occurs (such as when a user clicks a button), the event notification is sent to the server via HTTP, and the server uses a special servlet called Facesservlet to process the notification. Every JSF application in a Web container has its own facesservlet;

In the background, each JSF request triggers 3 things:

1.4.1 Facesservlet Creates a facescontext that contains the servletcontext,servletrequest of the service method that the Web container passes to Facesservlet. Servletrespons object, in the processing process is mainly to modify this facescontext)

1.4.2 Facesservlet give control to lifecycle.

1.4.3 Lifecycle 6 stages of processing facescontext (also known as the JSF lifecycle process)

1.5 Life cycle:

1.5.1. Rebuilding views: Build the component tree, and if it is the first render, the component tree is reset to the appropriate state; if it is not the first render, the component tree is created to jump to the response stage (the JSF component tree structure and the DOM are the same, except that the client is the former server).

1.5.2. Application Request Value: Each component in the tree can extract the new value from the request parameter and store the value locally, then handle all component-related events into the queue, and if the immediate property of a component is set to True, then the validation, conversion, And the events associated with the component are handled at this stage.

1.5.3. Processing validation: The component value is converted to the corresponding data type. If the conversion fails, this phase will continue to complete all remaining converters, verify and run the required checks, but after completion, jump to the life cycle of the render response stage. If validation succeeds, check the properties of the required on the component. If the property is required and a value is entered in the component, then the validator associated with it runs. If the required property is mandatory but does not have a value entered, this phase is complete (all remaining validators will continue to execute) and then the lifecycle jumps to the render response stage. If the required property is identified as false, the validation process will not run, regardless of the input value in the component.

1.5.4. Update model: Verifies that the local value of the component is moved to the model while the local copy is discarded.

1.5.5. Invoking an application: Executing application-level logic, such as an event handler.

1.5.6. Render response: Renders a component in the tree. Subsequent requests and the restore view stage save state information.

2, Facelets

Facelets is a lightweight page-declaration language used to build JSF (JavaServer Faces) views using HTML styles.

It includes the following features:

    • It uses XHTML to create Web pages.
    • In addition to supporting the JavaServer faces and jstl tag libraries, it also supports the Facelets tag library.
    • It supports the expression language (EL).
    • It is a template that uses components and pages.

Advantages

    • It supports code reusability through templates and composite components.
    • It provides the capability extensibility of components and other server-side objects by customizing them.
    • Faster compilation times
    • It validates the 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.

The following table shows the tag libraries supported by the Facelets.

Reference Link: Https://baike.baidu.com/item/jsf/442519?fr=aladdin

Http://www.cnblogs.com/zgq0/p/8849106.html

Java EE Development Technology Course Week sixth (JSF, facelets)

Related Article

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.