JSF managed and backing bean

JSF managed bean: A managed bean is a normal java bean class which contains data and business logic. A managed bean is managed by JSF framework and act as a model for JSF application. Before using a managed bean we have to configure it either in faces-config.xml file or using annotation. JSF backing bean: JSF … Read more

Categories JSF

jsf configuration files

A JSF application needs on the following two configuration files: 1. web.xml 2. faces-config.xml Note: Put the configuration files under WEB-INF folder. web.xml: Example: <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">   <servlet> <servlet-name>faces</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet>   <servlet-mapping> <servlet-name>faces</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping>   </web-app><?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>faces</servlet-name> … Read more

Categories JSF

JSF bean scopes

Bean Scopes: When we define a bean, we have to define its scope also in which it will be placed. JSF implementation provide us several scope for a bean. Request scope is the default scope. Commonly used bean scopes: 1. Request scope. 2. View scope. 3. Session scope. 4. Application scope. Request scope: In request … Read more

Categories JSF

JSF lifecycle phases

The JSF application consist of six distinct phases given below: 1. Restore View 2. Apply Request Values 3. Process Validations 4. Update Model Values 5. Invoke Application 6. Render Response JSF life cycle diagram:   Restore View: The Restore View is the first phase of JSF life cycle. When a request comes restore view retrieves … Read more

Categories JSF

JSF Framework architecture

In JSF application JavaBean classes are act as a model and contains data and business logic. Commonly a JSP or Facelets (XHTML) page is used for view. JSF components are used to bind the view and model. FacesServlet act as a controller and use component tree to do all task like get request, gathering, validating … Read more

Categories JSF