The course is part of this learning path
In this course, we will learn the concepts of Java EE 7 with a focus on JavaServer Faces.
- What JavaServer Faces are
- Anyone looking to get Oracle Java Certification
- Those who want to improve Java 7 EE knowledge
- Java developers
- Have at least 2 years of Java development experience
Hello, dear friends.
In this video, we will start to examine JSF on Java 7 EE. Let's begin. Java Server Faces technology is a server-side component framework for building Java technology-based web applications. Java Server Faces technology consists of two parts. Java facets are server-side files which act as a controller to redirect the client request to the correct JSF web page. JSF tags. In addition to allowing server-side scripting into the web page, JSF also provides custom tags to perform certain operations like iterations or condition check easily. Let's look at the JSF schema. A JSF application consists of web pages with JSF UI components. A JSF application also requires some configuration files like faces-config.xml and web.xml. Faces servlet and faces-config.xml. Faces servlet is the main servlet for the application and can optionally be configured by a faces-config.xml descriptor file. The faces-config.xml defines managed bean, the navigation between web pages, data validators, and data converters.
Managed bean is the data elements of the JSF application that represent a Java class, which will be created dynamically during runtime of the JSF application. Managed beans are simple Java objects which are declared in faces-config.xml and can be used in a JSF application. JSF allows multiple PDLs such as JSP or facelets. Data validators are used to check the validity of UI input. And data converters are used to translate between UI and model. Renderers are responsible for displaying a component and translating a user's input into the components value. JSF 2.0 also includes built-in Ajax support, as we will see in the videos that follow. A collection of common UI elements and an event-driven programming model are provided by JSF. JSF also provides the facility to use third-party components and the facility to reuse and extend standard UI components. Now, let's look at the life cycle of JSF. As you can see, JSF application lifecycle consists of six phases: restore view phase, apply request values phase, process validations phase, update model values phase, invoke application phase, render response phase.
Now, JSF begins the restore view phase as soon as a link or a button is clicked and JSF receives the request. During this phase, JSF builds the view, wires event handlers, and validators to UI components and saves the view in the faces context instance. The faces context instance will now contain all the information required to process a request. After the component tree is created or restored, each component in the component tree uses the decode method to extract its new value from the request parameters. Components stores this value. If the conversion fails, an error message is generated and queued on faces context. This message will be displayed during the render response phase along with any validation errors. If any decode methods, events, listeners called render response on the current faces context instance, the JSF moves to the render response phase. In process validation, the JSF processes all validators registered on the 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, JSF adds an error message to the faces context instance and the lifecycle advances to the render response phase and displays the same page again with the error message. The update model values is the fourth phase of the JSF lifecycle. In this phase, bean properties are updated using corresponding component local values. In the invoke application phase action with the business, logic is executed and returns a string which is passed to the navigation handler for navigation. The render response is the last phase of the JSF lifecycle. In this phase, the response is sent to the browser. We have not yet examined JSP. However, in the following videos, we will also cover JSP and learn the differences between JSF and JSP.
But for now, we can say that JSF uses XHTML pages. The most important advantage of JSF is that it reduces the effort required to create and maintain applications that will operate on a Java application server and render application UI on a target client. But how? JSF provides reusable UI components, makes easy data transfer between UI components, manages UI state across multiple server requests, enables implementation of custom components, and wires client-side event to server-side application code. Now, I think that's enough as theory. In the next video, we will start to use JSF in our first web application. See you in the next video.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.