Javaserver Faces (JSF)

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

JavaServer Faces (JSF)

‫أبيسلّوم‬
ّ .‫ م‬:‫إعداد‬
?What is JavaServer Faces
• JSF stands for Java Server Faces. It is a server-side Java
framework for web development.

• It consists of rich API and tag libraries.

• The JSF Tag libraries are used to add components on the web
pages and connect components with objects on the server.

• It is written in Java.
Benefit of JavaServer Faces

It provides clean and clear separation between behavior and


presentation of web application.

– You can write business logic and user interface separately.


JSF Features

• Component Based Framework


– It provides inbuilt components to build web application.

• Implements Facelets Technology.

• Bean Annotations.

• Integration with Expression Language.


Facelets Technology

• Facelets is an open source Web template system.

• It is a default view handler technology for JavaServer Faces


(JSF).

• Facelets supports all of the JSF UI components and focuses


completely on building the view for a JSF application.

• In short, the use of Facelets reduces the time and effort that
needs to be spent on development and deployment.
Faces Servlet

• Initializes resources
• Accepts all incoming JSF requests
• Passes requests to the request lifecycle for processing
• It validates expression language at compile-time.
• Faster compilation time.
• High-performance rendering.

– Mapping for the FacesServlet in the web.xml


• /faces/* - prefix mapping
JSF Managed Bean

• It is a pure Java class which contains set of properties and set


of getter, setter methods.

• Following are the common functions that managed bean


methods perform:

– Validating a component's data


– Handling an event fired by a component
– Performing processing to determine the next page to
which the application must navigate
Configuring beans

• You can use bean by

– using annotations.

– @ManagedBean annotation in a class automatically


registers that class as a resource with the JavaServer
Faces.
Configuring Managed Bean using Annotations

import javax.faces.bean.*;  
  
@ManagedBean    // Using ManagedBean annotation  
@RequestScoped  // Using Scope annotation  
.Request scope persists during a single HTTP request in a web application //

public class User {  
    private String name;  
    public String getName() {  
        return name;  
    }  
    public void setName(String name) {  
     this.name = name;  
}  
}  
Expression Language
• Expression Language (EL) provides an important mechanism
for creating the user interface (web pages) to communicate
with the application logic (managed beans)

<h:body>
<h:form>

> / "h:inputText value= " #{User. name}<

> / "h:outputText value= " #{User. name}<

</h:form>
</h:body>
Good luck

You might also like