Sunteți pe pagina 1din 50

JavaServer Faces 2.

0
The Complete Tour
Ed Burns
Sun Microsystems, Inc.
Ed Burns
Oracle America, Inc.
JavaServer Faces 2.0
The Complete Tour
Java Developer Conference
Agenda

Introduction: set the context

Basic Operation of JSF

Request rocessin! "ifec#cle

$hat is it%

$h# do I ha&e to understand it%

JSF '.(, from t)o &ie)points

*he Four illars of JSF

+e) Feature *ra&ersal


Java Developer Conference
Speaker Qualifications: d !urns

rincipal Staff ,em-er, Oracle America, Inc.

Since inception, co.leader of the team that


de&elops the Ja&aSer&er/ Faces 0JSF1 Specification

2o.author of the ,c3ra).4ill -oo5, Ja&aSer&er


Faces, *he 2omplete Reference and upcomin!
JSF': *he 2omplete Reference

Author of the ,c3ra).4ill -oo5: Secrets of Roc5


Star ro!rammers: Ridin! the I* 2rest

rior to JSF Ed )or5ed on the Sun Ja&a lu!.in,


,o6illa Open Ja&a7, Interface, +2SA ,osaic
Java Developer Conference
All of the Faces Spec and "untime Team at
#racle
Ed Burns
Roger Kitain
Ryan Lubke
Java Developer Conference
$ost of the Faces of the JS"%&'( )
Andy Schwartz
an A!!en
A!e"andr Smirno#
Ken $au!sen
Martin Marinschek
$ete Muir
Kito Mann
%oe &ttinger
'ed (oddard
)ei! (ri**in
%ason Lee
a#id (eary Mike +reedman
(a#in King
%eremy (re!!e
Keith ona!d
Ed Burns
%im risco!!
Roger Kitain
Ryan Lubke
Java Developer Conference
Some of the Faces of the Faces Communit*
Andy Schwartz
an A!!en
%acob ,ookom A!e"andr Smirno#
Ken $au!sen
Martin Marinschek
Matthias -eendorf
$ete Muir
A!e"ander %esse
Imre &wald
.ara Senger
Linco!n Ba"ter III
Adam -iner
/raig Mc/!anahan
Kito Mann
Rick ,ightower
%oe &ttinger
'ed (oddard
)ei! (ri**in
%ason Lee
Stan Si!#ert
a#id (eary Mike +reedman
(a#in King
,azem Sa!eh
0a1atay 0i#ici
ennis Byrne Roger Keays
Amy +ow!er
Ma" Katz
%eremy (re!!e
Keith ona!d
Ed Burns
%im risco!!
Roger Kitain
Ryan Lubke
S2ock
Ra*ae! )unes
3inny )unes
Java Developer Conference
Java Developer Conference
!asic #peration of JSF
Java Developer Conference
JSF "e+uest ,rocessing
-ifec*cle
Java Developer Conference
.ait a minute...

"ots of complexit# for 8ust a simple


thin!: 4**%

Isn9t it easier 8ust to do RES*%

:Real; $e- Frame)or5s don9t tr# to


hide the ele!ance of the )e-
Java Developer Conference

<ata 2on&ersion and 7alidation

a!e Flo)

<ata-ase inte!ration 0ersistence "a#er1


All .e/ Applications $ust 0ave...

erformance

Securit#

I=>+, "=(+, A==?

Support 2SS, ,ar5up


-ased la#out

@ser FriendlinessA

<e&eloper

End @ser
Java Developer Conference
Comple1it* $ust -ive
Some2here
2hoosin! JSF BB
2hoosin! an Architecture

<esi!ned -# industr#
experts

Refined O&er Fi&e ?ears


*ime

$idel# <eplo#ed in
roduction
Java Developer Conference
JSF 2.0 From T2o
3ie2points

Four illars of JSF

7ie)

,odel Inte!ration

+a&i!ation

"ifec#cle

+e) Feature *ra&ersal


Java Developer Conference
Four ,illars of JSF
In#ersion o* /ontro!
In#ersion o* /ontro!
Java Developer Conference
3ie2

JSF '.( 7ie)s are Facelets a!es

JS is deprecated

Still )or5s

,ost ne) features are not a&aila-le to JS


users

Facelets BB C4*," D Industr# ro&en *emplatin!

*a!li-s are C," namespaces


Java Developer Conference
4emo: Facelets in
5et!eans 6.7
Java Developer Conference
In#ersion o* /ontro!
In#ersion o* /ontro!
Java Developer Conference
$odel 8nteraction

o)erful E" Expressions


lin5 components in
7ie) to roperties in
,odel

Ja&a EE E E": Supports


Ar-itrar# ,ethod
In&ocation

*)o st#les

:-ac5in! -ean; D
OJO

OJO
Java Developer Conference
In#ersion o* /ontro!
In#ersion o* /ontro!
Java Developer Conference
5avigation

JSF'.( Implicit
+a&i!ation

+o C,"

4i!hl# <#namic

@seful )ith :flash;


o-8ect

JSF =.C Explicit


+a&i!ation

"ots of C,"

Redeplo# Required
Java Developer Conference
4emo: 8mplicit 5avigation
Java Developer Conference
In#ersion o* /ontro!
In#ersion o* /ontro!
Java Developer Conference
-ifec*cle
JSF =.(

4andles onl# 7ie)


<eclaration Request

+o Support for A8ax

hase"isteners: the
onl# )a# to o-ser&e
into the "ifec#cle
JSF '.(

4andles 7ie)
<eclaration Request D
Resource Requests

Excellent, )ell
inte!rated support for
A8ax

S#stem E&ents: fine


!rained lifec#cle
listenin!
Java Developer Conference
4emo: A9a1
'F
A9a1
4
Inspiration: RichFaces, IceFaces, <#namicFaces, A<F
Faces
4
*)o entr# points:
5
<eclarati&e: :f:a9a1; ta!, uses A9a1!ehavior
5
ro!rammatic a8ax: resource li-rar#
9ava1.faces, resource name 9sf.9s, Ja&aScript
namespace 9sf.a9a1
4
<eclarati&e a8ax: useful to a8axif# non a8ax pa!es
4
A9a1!ehavior : !reat flexi-ilit# for most needs
4
ro!rammatic a8ax AI usa!e pattern
5
9sf.a9a1.re+uest<= Ja&aScript method
R
'E
A9a1
4
artial7ie)2ontext
5
@sed to process A8axRequests on ser&er
5
2ontains useful disco&er# methods
4
artialResponse$riter
5
$rite standard A8ax response format
4
artial7ie)2ontext and artialResponse$riter are
extensi-le
R
Java Developer Conference
JSF 2.0 5e2
Feature
Traversal
Java Developer Conference
Java Developer Conference
Categories of 5e2 Features
6

Foundational

urpose -uilt to support


Large features

Large

Bi! *ic5et Stuff

Medium

7er# useful for ad&anced


users

Small

Bu! fixes and


enhancements
E
Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


JSF 2.0 3ision for Compnents

*his...
$ake components eas* to develop

Becomes this...

Or ma#-e this...
G if #ou )ant to !et fanc#

:a# as #ou !o; complexit#


$ake components eas* to develop
JSF 2.0 Component 3ision

multi.select components on a
JSF pa!e

press a :componenti6e;
-utton

#ou !et a )i6ard that lets #ou


choose ho) to expose the
content of this component to
the pa!e author

the component appears in a


palette.
4emo: Simple -ogin ,anel
Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


HI
"esources
4
A&oid need for separate Filter or Ser&let.
4
Resources are lo!icall# related to components, treat
them that )a#.
4
"oad from 2lasspath, or files#stem
4
Full support for :"i-rar#; concept, I=>+, 7ersionin!
R
H>
Resource
Renderer outputs
URL to resource
R
HJ
"esources: Java A,8
4
@ResourceDependency or @ResourceDependencies
annotation on
5
UIComponent, Renderer, Validator, Converter,
ClientBehavior
4
attri-utes for resource name, li-rar# name
4
attri-ute for tar!et: head, -od#, form
4
Built in support for 2SS, Ima!e, Ja&aScript resources
R
K(
"esources: $arkup A,8
4
<h:head>, <h:body>
4
<h:outputScript>, <h:outputStylesheet>
4
Similar attributes for resource name, library name
4
Similar attri-ute for tar!et: head, -od#, form
R
Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


K'
3ie2 ,arameters
4
Inspired -# a!e arameters from JBoss Seam
4
ro&ides a )a# to map request parameters to special
components )ithin the &ie)
4
:f:metadata;:f:vie2,aram;:>f:metadata;
4
?83ie2,arameter extends ?88nput
4
All attached o-8ects &alid for ?88nput are &alid
4
Brea5s the t#rann# of OS*
4
Ena-les Boo5mar5a-le pa!es
R
Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


KK
S*stem vents
E
4
Influenced -# JSF*emplatin!
4
u-lishLSu-scri-e e&ent -us for thin!s that happen
durin! the JSF "ifec#cle, not application specific
4
Inspired -# Solaris <trace, "inux strace, truss, etc.
4
"isteners can -e re!istered at three scopes
5
component UIComponent.subscribeo!vent"#
5
view UIVie$Root.subscribeo!vent"#
5
application %pplication.subscribeo!vent"#
4
u-lish is al)a#s )ith Application.pu/lishvent<=
KF
S*stem vents: Standard vent T*pes
E
Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


Java Developer Conference
F
o
u
n
d
a
t
i
o
n
a
l

5
e
2

F
e
a
t
u
r
e
s
-
a
r
g
e

5
e
2

F
e
a
t
u
r
e
s
0igh -evel Categories
of Features


Java Developer Conference
JavaServer Faces 2.0
The Complete Tour
Ed Burns
&rac!e America, Inc.

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