Java Server Faces The Fundamentals Compiled from Sun

  • Slides: 15
Download presentation
Java. Server Faces: The Fundamentals Compiled from Sun Tech. Days workshops (JSF Basics, Web-Tier

Java. Server Faces: The Fundamentals Compiled from Sun Tech. Days workshops (JSF Basics, Web-Tier Codecamp: Java. Server Faces, Java Studio Creator; IBM RAD)

Java. Server Faces (JSF) l is a “server side user interface component framework for

Java. Server Faces (JSF) l is a “server side user interface component framework for Java™ technology-based web applications” l is a specification and reference implementation for a web application development framework ¡Components ¡Events ¡Validators ¡Back-end-data integration l is designed to be leveraged by tools ¡Net. Beans, RAD (Rational Application Developer), Eclipse, JDeveloper, etc.

Why JSF? l MVC for web applications l Easy to use l Extensible Component

Why JSF? l MVC for web applications l Easy to use l Extensible Component and Rendering architecture l Support for client device independence l Standard l Huge vendor and industry support l Built-in UI component model (unlike JSP and Servlet)

Why JSF? (cont’d) l Offers finer-grained separation of behavior and presentation than JSP ¡Component-specific

Why JSF? (cont’d) l Offers finer-grained separation of behavior and presentation than JSP ¡Component-specific event handling ¡UI elements as stateful objects on the server l UI-component and Web-tier concepts without limiting you to a particular scripting technology or markup language ¡Can work with any presentation technology including JSP

JSF is a UI Framework for Java Web Applications

JSF is a UI Framework for Java Web Applications

JSF Architecture

JSF Architecture

Important Basic Capabilities l Extensible UI component model l Flexible rendering model l Events-based

Important Basic Capabilities l Extensible UI component model l Flexible rendering model l Events-based interaction model (as opposed to the old “request/response” model) l Validation framework l Basic page navigation support l Internationalization l Accessibility

How the JSF Specification Fits In (prior to Facelets)

How the JSF Specification Fits In (prior to Facelets)

Facelets l Facelets is a powerful but lightweight page declaration language that is used

Facelets l Facelets is a powerful but lightweight page declaration language that is used to build Java. Server Faces views using HTML style templates and to build component trees. l Facelets features include the following: ¡ Use of XHTML for creating web pages ¡ Support for Facelets tag libraries in addition to Java. Server Faces and JSTL tag libraries ¡ Support for the Expression Language (EL) ¡ Templating for components and pages

Facelets (cont’d) l Advantages of Facelets for large-scale development projects include the following: ¡

Facelets (cont’d) l Advantages of Facelets for large-scale development projects include the following: ¡ Support for code reuse through templating and composite components ¡ Functional extensibility of components and other server-side objects through customization ¡ Faster compilation time ¡ Compile-time EL validation ¡ High-performance rendering l In short, the use of Facelets reduces the time and effort that needs to be spent on development and deployment. Source: Java EE 6 Tutorial

JSF Developer Roles

JSF Developer Roles

Roles Definition l Page Author ¡ Creates the user interface of a web application

Roles Definition l Page Author ¡ Creates the user interface of a web application ¡ Familiar with markup language(s) to be used ¡ Assembler of prebuilt components l Component Writer ¡ Creates reusable components, renderers, and libraries ¡ Components – Render-independent properties ¡ Renderers – Render-dependent properties

Roles Definition l Application Developer ¡ Creates the server-side functionality of a web application

Roles Definition l Application Developer ¡ Creates the server-side functionality of a web application not directly related to the user interface ¡ Business logic components implemented in standard J 2 EE ways (EJBs, Java. Beans, Connectors) ¡ Persistence tier components implemented in standard J 2 EE ways (EJBs, JDBC, Connectors) ¡ Model data exposed to user interface via Java. Bean programming model ¡ Validator, Converter, Event handler

Roles Definition l Tool Provider ¡ Creates tools to assist page authors, component writers,

Roles Definition l Tool Provider ¡ Creates tools to assist page authors, component writers, and application developers ¡ GUI-oriented page development tools ¡ IDEs to facilitate creation of components ¡ Application generators (from high level description) ¡ Web application frameworks that utilize JSF components for their user interface l JSF Implementor ¡ Provides runtime environment to execute JSF webapps J 2 EE SDK 1. 4

Criteria for choosing Struts or Java. Server Faces JSF JSP and Struts Components l.

Criteria for choosing Struts or Java. Server Faces JSF JSP and Struts Components l. Rich UI-data-bound components with events provided l. Custom components l. Standard tags (JSTL) that are non-UI and very basic l. Custom components through tag libraries l. Struts-specific tag library l. Only very basic, formbean-bound components provided Device independence l. Reader kits that provide device independence l. None Error handling and validation l. Validation framework l. Many predefined validators l. None l. Validation framework driven by an XML file (validation. xml) Scripting l. Scripts can be attached to events l. All components accessible from scripts l. Embedded Java™ in the page l. Scripts written in Java Action classes l. Form data but not components accessible Page flow l. Simple navigation file (faces-config. xml) l. None l. Sophisticated, flexible framework l. XML file based Session and object management l. Automatic l. Manual