Вы находитесь на странице: 1из 37

JavaServer Faces Overview

Module Objectives

z At the end of this module you will be able to:


 Describe JavaServer Faces Architecture

 Describe the features of using JSF

 Chordiant support for JSF


Road Map

z JavaServer Faces
 Architecture

 JSF Lifecycle Phases

 Additional learning resources

z Chordiant Support for JSF


What is JavaServer Faces?

z JavaServer Faces (JSF) is a server side user


interface component framework for Java™
technology-based web applications
z Aims to simplify J2EE web application
development
z A comprehensive standard API for J2EE web
applications
z Based on a standard specification
JavaServer Faces

z Simplifies development of sophisticated web


application user interfaces by allowing
 Java programmers to develop the application
backend without worrying about HTTP details
 Page Authors to work on the user interface “look
and feel” without any programming knowledge
 Vendors to develop tools for frontend and
backend development
z Benefits
 Less code in the user interface template

 More modular design


JSP and Java Bean Architecture

z JSP/HTML --ÆPage Bean (Java Bean , getter


/setter methods
z Custom tag, xml like tags having some java fn
z Info abt the java fn is provided by the prefix

C.X

Input type=“text”
Name=“custno” Private String custno;
DB
Input type=submit
<jsp:usebean id=x
Classname=“C.X”>
JavaServer Faces Architecture

Render kit decides the o/p


XML
WML

HTML

Property files for


Static text MLS
z JSF is both
 A Java Web user-interface standard

 A framework that follows the Model-View-


Controller (MVC) design pattern
z User interactions are handled by a front-end
"Faces" servlet (Controller)
MVC in JSF

z Controller
 Decide the format of the o/p –Renderkit
 Decide the language of the o/p—Property files
 RequestDispatching-which view/page to display on what
action
z View
 XML Based so that o/p can be WML/HTML- Renderkit
 Display static text from property Files
(Internationalization)
 Retrive/Set data in the Page bean
z Model
 Page Bean/backing bean having getter/setter methods
and can talk to middleware/database or any third party
application
 ` and Managed by controller via config.xml
Modular Design

z JSF brings web development more inline with


MVC through cleaner separations

Model

Model

Controller
View
Component

Renderer
Listener
Model

z Represented by Java Beans Model


 Do not extend any specific class Model

 Do not implement any specific


interface
z Provide the mechanism by which
information is passed between UI
components and the back-end
application
z Model behavior is separate from
controller behavior
View

z Called Renderers in JSF View


z Usually constructed using Renderer

 JSP/HTML

 Tag Libraries

z Specified to support JSP


 But is not required to use it

z Comes with two JSP base component


libraries
 Core - For application tasks

 HTML - For rendering basic HTML

z Could also use other technologies


such as SVG, WML etc
UI Components

z With JSF applications are built


from collections of components
that can render themselves in
different ways
z The specification provides a set of
base UI Components in its
Reference Implementation
 Core - For application tasks

 HTML - For rendering basic HTML

z Additional UI Component Libraries


are available
 Apache Trinidad
Controller

z Composed of Controller

 FacesServlet - receives all request


Component

and creates (or recreates) component Listener

tree
 Components - fires events to
registered listeners
 Listener Classes - invoke Model beans
using Change and Action Listeners
JSF Technology

z A basic JSF application consists of the


following:
 JSF UI components - encapsulated in JSF tag
libraries(.xhtml)
 Navigation Model - defines rules for
navigation(faces-config.xml) controller uses this
 Managed Beans - facilitate the UI logic of the
application (Java beans)
 Helper Objects - for validation and conversion
JSF Lifecycle

z A JSF page is represented by a tree of UI


components, called a View
z When a client makes a request for the page,
the lifecycle starts
z During the lifecycle, JSF implementation
must manage the View while preserving
state saved from a previous request
JSF Lifecycle

BP

CA
JSF Specification

z The Specification for JSF can be found at


http://java.sun.com
z Includes details of downloading the
specification and implementations
z Go to:
 http://java.sun.com/javaee/javaserverfaces/do
wnload.html
Section Review

z In this section you learned:


 About JSF architecture.
Road Map

z JavaServer Faces
z Chordiant Support for JSF
 Features

 Chordiant JSF Flow

 Chordiant JSF and CAFE

 Installation and set-up


Chordiant JSF Framework

z Uses the standard JSF Framework to listen to


and process lifecycle events
 Nothing is created outside the JSF standard

z Uses Trinidad to avoid creating Chordiant


specific UI components
 Open source project formerly known as ADF
(Application Development Framework)
 Includes high quality components, a dialog
framework, as well as personalization and
skinning capabilities
 See http://myfaces.apache.org/
Chordiant JSF v CAFE

z Use of JSF tags in JSP pages


z Use of Interaction flows run by Interaction
Controller
z JSF handles many of the functions previous
handled by the CAFE framework:
 JavaWorkDispatcher

 XmlHttpService

 Field formatting and validation

 Page navigation Advisor


MVC

FS
MVC BPS
BS/SS
Chordiant JSF and CAFE

z Chordiant JSF framework co-exists with


Chordiant CAFE framework
z JSF is independent of CAFE
z JSF will continue to use the desktop
environment provided by CAFE
 Offerings are used as entry point to start a
business process
z Most new offerings and features will use a
combination of JSF framework and
Interaction Controller
Chordiant JSF Applications

z Chordiant JSF Applications are constructed


using the following
 Process flow to implement the business process
.jxw(client tasks and system tasks—Business
service)
 Implement client task using Chrd_JSF
™ Managed beans for interaction between front and back
end (UI and workflow tasks)
™ JSPs for user interface(instead of xhtml, use jspx)
™ JSF Navigation rules
Process Flow

z Represent business processes


z Composed of
 Client tasks - representing user interaction
 System tasks - execute without user interaction
ic String enterAccountnumber()
System Task
{}

Public Integer displayAccountEntries(Vector accentr

Client Tasks
Backing Beans (Model from MVC)
z Used to drive process interaction
z Acts as a caller to Interaction Controller
z Composed of an Interface and Default
implementation
z Interface specifies methods associated with
values displayed or entered on the UI
 set/get methods

z Unlike ‘standard’ JSF beans typically do not


have to hold data directly
 Class attributes need not be defined

 Instead se/get methods act as facade to the


back-end
z Registered in a configuration file
Example Backing Bean
public class MovieIdPageBean extends IcFacesBackingBeanImpl {
// value passed from process to be displayed on UI
public String getMovieId()
{
String movieId = (String)IcFacesContext.getObjectFromIoMap(
“movieId" , false) ;
return movieId ;
}

// value entered on UI to be passed back to process


public void setMovieId(String movieId)
{
IcFacesContext.putObjectInIoMap("enterMovieIdReturn" ,
movieId) ;
}

}
JSPs for UI Screens

<ui:composition>
<f:loadBundle basename="bundles.viewmovietitle.msgs.msgs“
var="movie_msgs" />
<f:view locale="#{preferLocale.locale}">
<tr:document>
<tr:form>
<tr:inputText label="#{movie_msgs.enterMovieId_label}“
value="#{enterMovieId.movieId}"
required="true"
shortDesc="#{prompts.values.Id_prompt}"/>
</tr:form>
</tr:document>
</f:view>
</ui:composition>

Navigation Rules
z Associates tasks with JSF pages
z Defined in a configuration file
z Chrd JSF Navigation file given to ChrdJSF Controller
(interaction controller)
<navigation-rule>

<navigation-case>
<from-outcome>ic$viewmovietitle_enterMovieId</from-outcome>
<to-view-id>
/xAdvisorWeb/bundles/viewmovietitle/jsf/enterMovieId.jspx
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ic$viewmovietitle_showMovieTitle</from-outcome>
<to-view-id>
/xAdvisorWeb/bundles/viewmovietitle/jsf/showmovietitle.jspx
</to-view-id>
</navigation-case>

Interaction Controller (IC)
z Set of APIs to enable the UI layer to drive
process flow
 Independent of the UI framework, process
engine and channel
 Pure Java

 Uses no XML and object conversion

z Chordiant JSF depends on IC


z The IC Service is part of Chordiant Foundation
Business Process Server (BPS)
z Also IC service is exposed as webservice
Interaction Controller Architecture
Internet
Banking
CustLocate
Call-Centre CustVerify
Cards
CustLocate SelectAccount
Division
CustVerify
CustLocate
CustVerify
SelectAccount .Net
SelectAccount

Frontend app
Request xml/web
Struts JSF
Handler services
Communicates to BP
start next() cancel reassign next(qItem)
Via
InteractionController IC
ClientAgent webservice
Service InteractionControllerService
JxwInteractionController
PFlowService executes BP

Client PFlowservice
… … Task:
SelectAccount
… … Call
JXW Flow IC
& When client task
JXW Context
JSF and IC Interaction

Please enter your account number Account Entries for 556677:


ID Amount Description
* Account Number: 556677
15 $21.50 Deposit
27 ($76.50) Debit Card Withdrawal
Prev Next 31 $1.89 Interest

2
<navigation-case>
IcFacesDispatcher <from-outcome>
IcFacesBackingBeanImpl ic$MyFlow_displayAccEntries
public String next() 4 public String next() {
</from-outcome>
<to-view-id>
/displayAccEntries.jsp
AbcPageBean extends IcFacesBackingBeanImpl 5 </to-view-id>
</navigation-case>
nextClientTask = ic.next( clientTask );
public String getAccountNumber()
3 public void setAccountNumber( String input ) return ic$ + 9
clientTask.getProcessName()+
"_" + clientTask.getName() ;
ClientTask ioMap }
String entrAccNoRetrn = “556677”;
Vector accEntries;

Service Tier
InteractionController

Ic$MyFlow.enterAccoutnnumber 6 7 8
enterAccountno.jspx

1
Setup and Configuration

z JSF components are set-up in a CAFE Bundles


project
 Foxberry bundles need to be selected

z Copied to the Advisor application


 Advisor/WebRoot/iAdvisorWeb

 Advisor/WebRoot/xAdvisorWeb

z Web.xml
 Defines JSF configuration elements

 Bean definition files

 Navigation rule definition files


Build Scripts for the Lab Environment

z The following Ant scripts have been created


specifically for the lab environment:
 _CHRD-401_BusinessObjects/build.xml
™ Package Business Objects into a jar
 _CHRD-401_BusinessServices/build.xml
™ Package Business Services into a jar
 _CHRD-401_Bundles/build.xml
™ Package Client-side and Server-side application classes
into a jar
™ Copy bundle folders to Advisor application

 _CHRD-401_Processes/build.xml
™ Package Process flows into jar
Exercise

z Running a JSF Application


 Refer to your Lab Guide and instructor for
specifics about this exercise.
Review of Exercise

z JSF Application Walk Through


 This session will investigate the various
components used to construct the application
executed in the last exercise
 We will look at the following:
™ Offering
™ Process Flow
™ Backing Bean
™ Navigation Rules
™ JSPs
Section Review

z In this section you learned:


 About Chordiant support for JSF
Module Review

z In this module you learned about:


 JavaServer Faces Architecture

 The benefits of using JSF

 Chordiant support for JSF

Вам также может понравиться