Title: Introduction to Java Server Faces JSF
1Introduction to Java Server Faces (JSF)
Balazs Igli James Edmond Scott McLellan
2Agenda
-
- JSF topics to cover
- What is JSF?
- Architecture Overview
- UI Component Model
- Development Steps
3JavaServer Faces (JSF) Framework Is
- A server side user interface component framework
for Java technology-based web applications
4What Is JSF
- A specification and reference implementation
for a web application development framework - Components
- Events
- Validators converters
- Navigation
- Back-end-data integration
5Agenda
-
- JSF topics to cover
- What is JSF?
- Architecture Overview
- UI Component Model
- Development Steps
6Request Processing Lifecycle Phases
7Agenda
-
- JSF topics to cover
- What is JSF?
- Architecture Overview
- UI Component Model
- Development Steps
8User Interface Component Model
- UI components
- Event handling model
- Conversion and Validation model
- Rendering model
- Page navigation support
9UI Components
- UIComponent/UIComponentBase
- Base class for all user interface components
- Standard UIComponent Subclasses
- UICommand, UIForm, UIOutput
- UIGraphic, UIInput, UIPanel, UIParameter
- UISelectBoolean, UISelectMany, UISelectOne
- Example
10Validators and Converters
- Validators - Perform correctness checks on
UIInput values - Register one or more per component
- Enqueue one or more messages on errors
- Standard implementations for common cases
- Converters - Plug-in for conversions
- Output Object to String
- Input String to Object
- Standard implementations for common cases
11Converters and Validators
12Rendering Model
- Renderers - Adapt components to a specific
markup language - Decoding
- Encoding
- RenderKits Library of Renderers
- Map component classes to component tags
- Is a custom tag library
- Basic HTML RenderKit
13Events and Listeners
- Follows JavaBeans Specification design and
naming patterns - Standard events and listeners
- ActionEvent - UICommand component activated by
the user - ValueChangedEvent - UIInput component whose value
was just changed
14Navigation Model
- Application developer responsibility
- Defined in Application configuration file
(Facesconfig.xml) - Navigation rules
- Determine which page to go.
- Navigation case
15Navigation Model Example
16Agenda
-
- JSF topics to cover
- What is JSF?
- Architecture Overview
- UI Component Model
- Development Steps
17Steps in Development Process
- Develop model objects which hold the data
- Add model objects (managed bean) declarations to
Application Configuration File faces-config.xml - Create Pages using UI component and core tags
- Define Page Navigation in faces-config.xml
- Configure web.xml
18Step 1 Develop model Objects(Managed Bean)
- A regular JavaBeans with read/write properties
- May contain application methods and event
handlers - Use to hold data from a UI (page)
- Creation and lifetime is managed by JSF runtime
- Application, session, request
- JSF keeps the bean's data in sync with the UI
19Step 2. Managed Bean Declaration(Faces-config.xml
)
20Step 3 Create JSF Pages
- Must include JSF tag library
- HTML and core tags
- All JSF tags must enclosed between a set of view
tag - Use JSF form and form component tags
- lthinput_textgt not ltinput typetextgt
- lthcommand_buttongt not ltinput typesubmitgt
- May include validators and event listeners on any
form components
21Binding UI to Managed Bean
22Step 4 Define Page Navigation Rules(Faces-config
.xml)
23Step 5 Configure (web.xml)
24JSF Application Directory Structure
- WEB-INF/web.xml
- WEB-INF/faces-config.xml
- WEB-INF/classes/LoginFormBean.class
- login.jsp
- Required Jars
- WEB-INF/lib/jsf-api.jar
- WEB-INF/lib/jsf-ri.jar
- WEB-INF/lib/jstl.jar
- WEB-INF/lib/jsf-el.jar
- WEB-INF/lib/standard.jar
- WEB-INF/lib/commons-beanutils.jar
- WEB-INF/lib/commons-digester.jar
- WEB-INF/lib/commons-collections.jar
- WEB-INF/lib/commons-logging.jar
25Advantages and Disadvantages
- Advantages
- JSF is a specification from Sun and will be
included in future versions of the J2EE
specification. - All major vendors are pledging strong support for
JSF. - JSF has a well-defined request lifecycle allowing
for plugability at different levels. - Because JSF has a rich component model, it favors
a RAD style of development. - Disadvantages
- JSF is still quite new and evolving.
- Is not as easy to develop with compared to other
alternatives.
26Conclusion
- JSF is a server side User Interface framework
made up of its own components designed for Java
and Web Based technologies - All 6 phases of the life cycle is required and
allows for maximum customization and data
manipulation - The User Interface components allow for events,
validations, data type conversions, rendering the
components in a browser and navigation rules - We can define managed beans in the
faces-config.xml and then access public
properties ad methods from the bean and use them
on the JSF pages
27The End