15
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)

JavaServer Faces for 353

Embed Size (px)

Citation preview

Page 1: JavaServer Faces for 353

JavaServer Faces: The Fundamentals

Compiled from Sun TechDays workshops

(JSF Basics, Web-Tier Codecamp:JavaServer Faces,

Java Studio Creator; IBM RAD)

Page 2: JavaServer Faces for 353

JavaServer Faces (JSF)is a “server side user interface component

framework for Java™ technology-based web applications”

is a specification and reference implementation for a web application development frameworkComponentsEventsValidatorsBack-end-data integration

is designed to be leveraged by toolsNetBeans, RAD (Rational Application Developer),

Eclipse, JDeveloper, etc.

Page 3: JavaServer Faces for 353

Why JSF?

MVC for web applicationsEasy to useExtensible Component and Rendering

architectureSupport for client device independenceStandardHuge vendor and industry supportBuilt-in UI component model (unlike JSP and

Servlet)

Page 4: JavaServer Faces for 353

Why JSF? (cont’d)

Offers finer-grained separation of behavior and presentation than JSPComponent-specific event handlingUI elements as stateful objects on the server

UI-component and Web-tier concepts without limiting you to a particular scripting technology or markup languageCan work with any presentation technology

including JSP

Page 5: JavaServer Faces for 353

JSF is a UI Framework for Java WebApplications

Page 6: JavaServer Faces for 353

JSF Architecture

Page 7: JavaServer Faces for 353

Important Basic Capabilities

Extensible UI component modelFlexible rendering modelEvents-based interaction model (as opposed to

the old “request/response” model)Validation frameworkBasic page navigation supportInternationalizationAccessibility

Page 8: JavaServer Faces for 353

How the JSF Specification Fits In (prior to Facelets)

Page 9: JavaServer Faces for 353

Facelets

Facelets is a powerful but lightweight page declaration language that is used to build JavaServer Faces views using HTML style templates and to build component trees.

Facelets features include the following: Use of XHTML for creating web pages Support for Facelets tag libraries in addition to JavaServer

Faces and JSTL tag libraries Support for the Expression Language (EL) Templating for components and pages

Page 10: JavaServer Faces for 353

Facelets (cont’d)

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

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

Page 11: JavaServer Faces for 353

JSF Developer Roles

Page 12: JavaServer Faces for 353

Roles Definition

Page Author Creates the user interface of a web applicationFamiliar with markup language(s) to be usedAssembler of prebuilt components

Component WriterCreates reusable components, renderers, and librariesComponents – Render-independent propertiesRenderers – Render-dependent properties

Page 13: JavaServer Faces for 353

Roles Definition

Application DeveloperCreates the server-side functionality of a web

application not directly related to the user interfaceBusiness logic components implemented in standard

J2EE ways (EJBs, JavaBeans, Connectors)Persistence tier components implemented in standard

J2EE ways (EJBs, JDBC, Connectors)Model data exposed to user interface via JavaBean

programming modelValidator, Converter, Event handler

Page 14: JavaServer Faces for 353

Roles DefinitionTool Provider

Creates tools to assist page authors, component writers, and application developers

GUI-oriented page development tools IDEs to facilitate creation of componentsApplication generators (from high level description)Web application frameworks that utilize JSF

components for their user interfaceJSF Implementor

Provides runtime environment to execute JSF webapps J2EE SDK 1.4

Page 15: JavaServer Faces for 353

Criteria for choosing Struts or JavaServer Faces

JSF JSP JSP and Struts

Components Rich UI-data-bound components with events provided Custom components

Standard tags (JSTL) that are non-UI and very basicCustom components through tag libraries

Struts-specific tag library Only very basic, form-bean-bound components provided

Device independence Reader kits that provide device independence

None None

Error handling and validation

Validation frameworkMany predefined validators

None Validation framework driven by an XML file (validation.xml)

Scripting Scripts can be attached to events All components accessible from scripts

Embedded Java™ in the page

Scripts written in Java Action classesForm data but not components accessible

Page flow Simple navigation file (faces-config.xml)

None Sophisticated, flexible framework XML file based

Session and object management

Automatic Manual Manual