Sunteți pe pagina 1din 21

JAVA SERVER FACES

A new face on application development in Java

What is JSF?

Java

Server Faces technology is a server side user interface component framework for java technology based web applications. It includes a set of APIs and a JSP custom tag library for expressing a java server faces interface with in a JSP page.

Outline
1. 2. 3. 4. 5. 6. 7. 8. Advantages of JSF over Struts. Java Server Faces Solutions. Key Concepts of JSF. Communication between various JSF components. Understanding JSF mvc and Event Handling. JSF Request Processing Life Cycle. Working with JSF. Limitations.

Advantages of JSF (over Struts)

Custom components JSF makes it relatively easy to combine complex GUIs into a single manageable component, Struts does not. Support for other display technologies JSF is not limited to HTML and HTTP, Struts is. Access to beans by name JSF lets you assign names to beans, then you refer to them by name in the forms. Struts has a complex process with several levels of indirection where you have to remember which form is the input for which action. Expression language The JSF expression language is more concise and powerful than the Struts bean:write tag.

Advantages of JSF (over Struts), Continued

Simpler controller and bean definitions JSF does not require the controller and bean classes to extend any particular parent class (e.g., Action) or use any particular method (e.g., execute). Struts does. Simpler config file and overall structure The faces-config.xml file is much easier to use than is the struts-config.xml file. In general, JSF is simpler. More powerful potential tool support The orientation around GUI controls and their handlers opens possibility of simple to use, drag-and-drop IDEs.

Java Server Faces Solutions


UI components State management Event handling Input validation Page navigation Custom tag library

Key JSF concepts


UI Component Renderer Validator Backing Bean Converter Events & Listeners Messages Navigation

Communication between various JSF components

Understanding jsf mvc and Event Handling

JSF Request Processing Life Cycle

JSF Request Processing Life Cycle

Working with JSF

JSF Tags .xmls Beans

Working with JSF

Tags Description
JSF Tags

HTML Tags (h)

Faces Tags (f)

HTML Tags
<h:outputText id= value= /> <h:outputLabel for= > <h:outputText id= value= /> </h:outputLabel> <h:panelGrid id=controlpanel binding=#{Bean.panel} column=20 border=1 cellspacing=0/> <h:commandButton id=command type=submit value=Display actionListner=#{Bean.controls}/> <h:inputText id=value=#{Bean.fun} required=true></h:inputText>

<h:message id=errors for=hello/>

Faces Tags
<f:view> </f:view> <f:validateLongRange minimum=1 maximum=500/> <f:validator validatorId=validatorId/> <f:valueChangeListener type=fully-qualifiedclassname/> <f:selectItem [id=componentId] [binding=componentReference] value=selectItemValue/>

Xmls

Faces_config.xml Web.xml

Beans

Managed Bean Backing Bean

Example

Limitations
Much weaker automatic validation Struts comes with validators for email address, credit card numbers, regular expressions, and more. JSF only comes with validators for missing values, length of input, and numbers in a given range. But MyFaces has several powerful validators Lack of client-side validation Struts supports JavaScript-based form-field validation; JSF does not Worse installation JSF does not have equivalent of struts-blank to start with POST only JSF does not support GET, so you cannot bookmark results pages

Thanks
Presented ByRadheshyam Rajput Shubhangi Tavse

S-ar putea să vă placă și