Professional Documents
Culture Documents
Plantilla JSF2
Plantilla JSF2
#58
CONTENTS INCLUDE:
n
JSF Overview
Development Process
Lifecycle
The JSF Expression Language
JSF Core Tags
JSF HTML Tags and more...
By Cay Horstmann
Button
JSF Overview
page.xhtml
<h:commandButton value=press me action=#{bean1.login}/>
WEB-INF/classes/com/corejsf/SampleBean.java
@ManagedBean(name=bean1)
@SessionScoped
public class SampleBean {
public String login() {
if (...) return success; else return error;
}
...
}
Development Process
www.dzone.com
Radio Buttons
page.xhtml
servlet container
client devices
<h:selectOneRadio value=#{form.condiment}>
<f:selectItems value=#{form.items}/>
</h:selectOneRadio>
web application
presentation
JSF Pages
application logic
navigation
validation
event handling
business logic
WEB-INF/classes/com/corejsf/SampleBean.java
database
Managed Beans
JSF framework
web
service
These common tasks give you a crash course into using JSF.
Text Field
page.xhtml
<h:inputText value=#{bean1.luckyNumber}>
WEB-INF/classes/com/corejsf/SampleBean.java
@ManagedBean(name=bean1)
@SessionScoped
public class SampleBean {
public int getLuckyNumber() { ... }
public void setLuckyNumber(int value) { ... }
...
}
jboss.org/jbossrichfaces/
DZone, Inc.
www.dzone.com
WEB-INF/classes/com/corejsf/SampleBean.java
Ajax 2.0
<h:commandButton value=Update>
<f:ajax execute=input1 input2 render=output1/>
</h:commandButton>
lifecycle
Error Messages
response complete
request
Restore
View
Apply Request
Values
Process
events
response complete
Process
Validations
Process
events
render response
<h:outputText value=Amount/>
<h:inputText id=amount label=Amount value=#{payment.amount}/>
<h:message for=amount/>
response complete
response
Render
Response
page.xhtml
Process
events
response complete
Invoke
Application
Process
events
Update
Model
Values
faces-config.xml
<application>
<resource-bundle>
<base-name>com.corejsf.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>
WEB-INF/classes/com/corejsf/messages.properties
goodbye=Goodbye
WEB-INF/classes/com/corejsf/messages_de.properties
goodbye=Auf Wiedersehen
resources/css/styles.css
.greeting {
font-style: italic;
font-size: 1.5em;
color: #eee;
}
page.xhtml
headerValues
param
paramValues
cookie
initParam
requestScope,
sessionScope,
applicationScope,
viewScope 2.0
facesContext
view
component 2.0
cc 2.0
resource 2.0
DZone, Inc.
header
userBean.name
pizza.choices[var]
calls pizza.getChoices().get(var) or
pizza.getChoices().put(var, ...)
www.dzone.com
f:selectItem
f:selectItems
f:ajax 2.0
f:viewParam 2.0
f:metadata 2.0
fn:substringAfter(str, separator)
fn:substringBefore(str, separator)
fn:replace(str, substr,
replacement)
fn:toLowerCase(str)
fn:toUpperCase(str)
fn:trim()
fn:escapeXml()
Description/Attributes
f:facet
f:attribute
f:param
f:actionListener
f:valueChangeListener
f:propertyAction
Listener 1.2
f:phaseListener 1.2
f:event 2.0
f:convertDateTime
and formatting
- timeZone: Time zone to use for parsing and formatting
(Default: UTC)
f:convertNumber
f:validator
f:validateDoubleRange,
f:validateLongRange,
f:validateLength
f:validateRequired 2.0
f:validateBean 2.0
f:loadBundle
DZone, Inc.
Tag
Description
h:outputStylesheet 2.0,
h:outputScript 2.0
h:inputText
h:inputTextArea
h:inputSecret
h:inputHidden
Hidden field
h:outputLabel
h:outputLink
HTML anchor.
h:outputFormat
h:outputText
h:commandButton,
h:button 2.0
h:message
h:messages
h:grapicImage
Displays an image
h:selectOneListbox
Single-select listbox
www.dzone.com
register
Attributes for
Single-select menu
h:selectOneMenu
h:selectOneRadio
h:selectBooleanCheckbox
Checkbox
h:selectManyCheckbox
Set of checkboxes
h:selectManyMenu
Multiselect menu
h:panelGrid
HTML table
h:panelGroup
h:dataTable
A feature-rich table
component
h:column
id
binding
rendered
value
valueVhangeListener
converter, validator
required
Description
Basic attributes
h:outputFormat
escape
Basic attributes
style, title
HTML 4.0
h:outputLabel
Attribute
Description
for
Basic attributes
h:graphicImage
Attribute
Description
Basic attributes
HTML 4.0
DHTML events
and
Description
Attributes for
Basic Attributes
h:outputText
Attribute
Attributes for
Multiselect listbox
h:selectManyListbox
Attribute
Description
outcome 2.0
fragment 2.0
(non-command tags)
(non-command tags)
actionListener
charset
immediate
type
DHTML events
Attributes for
h:inputText , h:inputSecret ,
h:inputTextarea , and h:inputHidden
Attribute
Description
cols
value
immediate
Basic attributes
redisplay
HTML 4.0
required
rows
Basic attributes
DZone, Inc.
Attributes for
DHTML events
h:outputLink
Attribute
Description
Basic attributes
www.dzone.com
HTML 4.0
DHTML events
h:selectBooleanCheckbox ,
h:selectManyCheckbox , h:selectOneRadio ,
h:selectOneListbox , h:selectManyListbox ,
h:selectOneMenu , h:selectManyMenu
border
cellpadding
cellspacing
columns
frame
headerClass, footerClass
rowClasses, columnClasses
rules
summary
Basic attributes
HTML 4.0
onclick, ondblclick,
onkeydown, onkeypress,
onkeyup, onmousedown,
onmousemove, onmouseout,
onmouseover, onmouseup
DHTML events
Attributes for:
Attribute
Description
enabledClass, disabledClass
selectedClass 2.0,
unselectedClass 2.0
layout
collectionType 2.0
hideNoSelectionOption 2.0
Basic attributes
Attributes for
h:message
Attributes for
DHTML events
and
Attribute
Description
Basic attributes
style, styleClass
HTML 4.0
Attributes for
h:panelGroup
h:dataTable
Attribute
Description
bgcolor
border
cellpadding
cellspacing
first
frame
headerClass, footerClass
rowClasses, columnClasses
rules
h:messages
Attribute
Description
for
summary
errorClass, fatalClass,
infoClass, warnClass
var
errorStyle, fatalStyle,
infoStyle, warnStyle
Basic attributes
globalOnly
HTML 4.0
layout
DHTML events
showDetail
onclick, ondblclick,
onkeydown, onkeypress,
onkeyup, onmousedown,
onmousemove, onmouseout,
onmouseover, onmouseup
showSummary
tooltip
Basic attributes
HTML 4.0
Attributes for
Attributes for
Description
bgcolor
Description
headerClass 1.2,
footerClass 1.2
Basic attributes
h:panelGrid
Attribute
h:column
Attribute
DZone, Inc.
Attribute
Description
ui:define
www.dzone.com
ui:insert
ui:composition
ui:component
ui:decorate,
ui:fragment
ui:include
ui:param
ui:repeat
ui:debug
ui:remove
A B O U T t h e Au t h o r
REC O MMEN D E D B oo k
http://weblogs.java.net/blog/cayhorstmann/
BUY NOW
you
by...
rns
e
t
t
n Pa
g
i
s
De
ld
ona
McD
son
a
J
By
z.co
#8
ired
Insp e
by th
GoF ller
se
Best
E:
LUD
IN C
ility
TS
EN
nsib
NT
spo
CO
f Re
o
in
d
Cha
man
Com reter
rp
Inte
tor
...
ore
Itera tor
dm
dia
d an
Me rver
tho
se
Me
S
Ob
RN
plate
TTE
Tem
Cha
Mo
ef
re R
Get
con
tinu
ed
snt
r doe
ndle
e ha
d th
st an
que
re
le a
have
to
r
ndle
e ha
ith th
st w
ue
req
ome.
in
the
e to
renc
refe listed in
ick
s
A
cta qu
s, a
s
NP
je
rn
e
b
e
IG
vid
s,
patt able O
pro
DES
ram .
ign
us
ard
UT
des
diag
le
f Re
refc
r
oF)
ABO
mp
ts o
lass
oke
erns
exa
Inv
ur (G lemen
es c
d
o
Patt
d
h
rl
F
n
f
o
ig
suc
s: E
inclu
go
al w
n
rn
Des
rn
c
D
a
e
re
e
is
je ts
tt
G
g
AN
Th
patt , and a
t ob mentin
l 23 sign Pa
M
c
a
h
u
c
M
in
tr
e
nd
Ea
tion
ple
CO
orig
ma
ons
kD
re.
rma
om
to c their im
boo Softwa
nt
teC
info
ed
cre
Clie
the
d
age
: Us d from
nd
Con
()
ente on, us
ma
r ns
ct
cute
Ori
Com )
ti
uple
atte
s
bje
(
+exe
low
eo
lana
al P e deco
is al
p
n
rg
cute
ch
x
o
la
e
. Th
s su
ati
+exe
ts.
rm
an b
bject nship
c
c
fo
Cre
je
y
an o
tio
e
to
ob
d as ed rela
ms,
t th
ed
eate
as
rith
tha
arate
: Us
be tr ject b
ts.
m.
r ns
disp
algo
c
r
it to lly ob
e
te
y
e
e
je
g
s
n
tt
g
iv
b
a
sy
win
ona
Pa
ana
allo traditi
s.
Rece
en o
ral
en m
der
uest
to m betwe
ctu
twe
nt or
req ndled in
n.
sa
sed
s
varia
Stru
s be
.
late
catio
e ha
can
s: U
or in
ilitie
psu
invo
to b llbacks
cture
that
the
times
Enca quest
nsib
ca
ttern
y.
stru
ips
ling
re
and
riant
nalit
l Pa d respo
ing
the
nsh
hand
ra
pose
uing
nctio led at va
o
ct
ur
cess be
fu
ue
ti
io
n
je
P
la
ob
pro
av
nd
ack
,a
as q
to
e
the
t re
e ha eded.
b
callb
nous nality
c
Beh nships
b
m
ed
n
ro
je
ed
to
fro
a
ne
d
y ne
ob
ynch
nctio
tio
You ne s need
at c
sts is couple
ut an is
e as the fu
st
rela
with
que
s th
it
itho
de
e th
ar
Reque y of re
litat pattern ssing w tation articul
eals
ld be
ship
or
faci
p
d
en
ce
Use
shou
tion
e: D
A hist
e.
n
ed to mman for pro implem ents its ting.
ker
rela
cop runtim
co
y us
m
type
invo
Whe
s
al
pec
S
e
el
le
e
ue
s
to
tu
p
ex
th
t
id
Th
ue
w
ac
cla
Pro
at
d im
jec
ue is
are utilizing a job q of the
C
ueue e que
Ob
ues
with
y
ged
enq
dge
th
que
s. B
en to
han
eals me.
c
roxy
Job orithm be giv knowle that is terface
D
P
e
:
g
ct
b
n
ti
e
in
S
r
le
of al ed ca to have d obje of the
er
mp
cop
pile
rato
ut
an
Exa
serv
nes
ss S at com
exec e queue comm
Deco
Ob
confi
S
Cla
e
th
B
d
the
n
. Th
for
de
nge
king
leto
ithin
invo hm w
Faca
cha
Sing
od
tory
Refcardz.com
.com
z
w. d
one
Fac
ract
Abst
r
pte
Ada
Meth
tory
Fac
t
eigh
Flyw
r
rete
rp
Inte
B
tor
Itera
algo
State
rit
y
od
Meth
plate
Tem
Stra
teg
Build
e
ridg
er
Visit
or
f
in o
ty
Cha nsibili
o
Resp
d
man
m
o
C
B
te
si
po
Com
Me
diato
Me
ento
Ob
ject
Beh
ral
avio
Y
tutorials, cheatsheets, blogs,
feature
articles, source code and more.
ILIT
NSIB
S
P
RES
succ
ess
or
O
AIN
DZone is a developers
dream, says PC Magazine.
CH
F
>>
ace
terf r
<<in andle
H
st ( )
que
lere
d
n
+ha
Upcoming Titles
Most Popular
Drupal
Grails
Core Java Concurrency
Java Performance Tuning
Eclipse RCP
HTML
Wicket
Spring Configuration
jQuery Selectors
Windows Powershell
Dependency Injection with EJB 3
Netbeans IDE JavaEditor
Getting Started with Eclipse
Very First Steps in Flex
DZone, Inc.
1251 NW Maynard
Cary, NC 27513
ISBN-13: 978-1-934238-61-5
ISBN-10: 1-934238-61-9
50795
888.678.0399
919.678.0300
Refcardz Feedback Welcome
refcardz@dzone.com
Sponsorship Opportunities
sales@dzone.com
9 781934 238615
ern
a rd
it
! V is
arz
re f c
ity,
Download Now
ibil
nd
le a
outc
ay ha
an
tial
hand
sm
hen
oten
ject
le to
.
.W
le p
le ob
tern ethod
bject
be ab
tab
pat
ultip ecific o should
cep
n M
this if the m up the
s
sp
an ac
ents
ject
ime.
see passed
d is
be a
plem ks to
de to
of ob at runt handle
e
im
t
co
b
Use
ec
se
til
ld
ch
ges
t
n A
n
ined
being
shou peats un paren
ime
ngua
erm
Whe
not
e la the runt or if it
det
ore
s re
uest
som
d
tion proces e no m
req
g in metho
cep
n A
e
e ar
a
ndlin
e ex ack th
ther
n ha rown in ndle th
ll st
until
ptio
th
e ca
Exce ion is sm to ha up th tered or
ral
pt
ni
ed
un
le
ce
ss
avio
co
ex
mp
echa n pa
Beh
.
is en
am
Exa
he
tion uest to
has ack. W
ject
q
cep
st
Ob
e re
e ex
call
le th
nd th
hand s to ha
ct
obje
e
of R
ns
spo
Con
cre
teH
1
ler
and
()
uest
+ha
ndle
re
le a
hand
uest
req
ki
by lin
ng
ww
z
w.d
one
.c o
$7.95
t to
ugh
Bro
books.dzone.com/books/jsf
Version 1.0