Professional Documents
Culture Documents
Primefaces User Guide 5 0
Primefaces User Guide 5 0
5.0
Author
aatay ivici
First Edition
PrimeFaces Users Guide
Table of Contents
About the Author..................................................................................................................................9
1. Introduction....................................................................................................................................10
1.1 What i !ri"e#ace$.............................................................................................................10
%. Setu&...............................................................................................................................................11
%.1 Do'n(oad...............................................................................................................................11
%.% De&endencie.........................................................................................................................1%
%.) *on+i,uration.........................................................................................................................1)
%.- .e((o Wor(d...........................................................................................................................1)
). *o"&onent Suite............................................................................................................................1-
).1 Accordion!ane(......................................................................................................................1-
).% A/a01ehavior.........................................................................................................................12
).) A/a0E0ce&tion.and(er..........................................................................................................%0
).- A/a0Statu..............................................................................................................................%1
).- Auto*o"&(ete........................................................................................................................%-
).5 1(oc3UI.................................................................................................................................)-
).4 1read*ru"b..........................................................................................................................)5
).5 1utton....................................................................................................................................)9
).2 *ache.....................................................................................................................................-%
).9 *a(endar.................................................................................................................................--
).10 *a&tcha................................................................................................................................5-
).11 *aroue(...............................................................................................................................55
).1% *e((Editor............................................................................................................................4)
).1) *hart....................................................................................................................................4-
).1).1 !ie*hart.......................................................................................................................45
).1).% 6ine*hart.....................................................................................................................45
).1).) 1ar*hart.......................................................................................................................50
).1).- Donut*hart..................................................................................................................5%
).1).5 1ubb(e*hart.................................................................................................................5-
).1).4 7h(c *hart....................................................................................................................54
).1).5 8eterGau,e *hart.......................................................................................................52
).1).2 *o"bined *hart...........................................................................................................20
).1).9 8u(ti&(e A0i...............................................................................................................21
).1).10 Date A0i...................................................................................................................2)
).1).11 Interactive *hart........................................................................................................2-
).1).1% E0&ort........................................................................................................................25
).1).1) Static I"a,e..............................................................................................................24
).1).1- S3innin,.....................................................................................................................25
).1).15 E0tender.....................................................................................................................22
).1).14 *hart A!I...................................................................................................................29
).1- *(oc3....................................................................................................................................9-
).15 *o((ector..............................................................................................................................94
).14 *o(or !ic3er.........................................................................................................................95
2
PrimeFaces Users Guide
).15 *o(u"n..............................................................................................................................100
).12 *o(u"n.............................................................................................................................10%
).19 *o(u"nGrou&....................................................................................................................10-
).%0 *o""and1utton................................................................................................................105
).%1 *o""and6in3...................................................................................................................110
).%% *on+ir"..............................................................................................................................11-
).%% *on+ir"Dia(o,...................................................................................................................115
).%) *ontent#(o'......................................................................................................................112
).%- *onte0t8enu.....................................................................................................................1%0
).%5 Dahboard..........................................................................................................................1%)
).%4 DataE0&orter......................................................................................................................1%2
).%5 DataGrid............................................................................................................................1)1
).%2 Data6it.............................................................................................................................1)5
).%9 DataScro((er.......................................................................................................................1-1
).)0 Data9ab(e...........................................................................................................................1-5
).)1 De+au(t*o""and..............................................................................................................150
).)% Dia(o,................................................................................................................................15%
).)) Dra,:Dro&........................................................................................................................155
).)).1 Dra,,ab(e...................................................................................................................155
).)).% Dro&&ab(e..................................................................................................................121
).)- Doc3..................................................................................................................................124
).)5 Editor.................................................................................................................................122
).)4 E++ect.................................................................................................................................19%
).)5 #eedReader........................................................................................................................195
).)2 #ie(det..............................................................................................................................194
).)9 #i(eDo'n(oad....................................................................................................................199
).-0 #i(eU&(oad.........................................................................................................................%01
).-1 #ocu..................................................................................................................................%02
).-% #ra,"ent............................................................................................................................%10
).-) Ga((eria..............................................................................................................................%1%
).-- G8a&.................................................................................................................................%15
).-5 G8a&In+oWindo'.............................................................................................................%%4
).-4 Gra&hicI"a,e....................................................................................................................%%5
).-5 Gro'(.................................................................................................................................%)1
).-2 .ot;ey..............................................................................................................................%)5
).-9 Id(e8onitor........................................................................................................................%)2
).50 I"a,e*o"&are..................................................................................................................%-0
).51 I"a,e*ro&&er....................................................................................................................%-%
).5% I"a,eS'itch......................................................................................................................%-4
).5) In&(ace...............................................................................................................................%-9
).5- In&ut8a3..........................................................................................................................%5)
).55 In&ut9e0t............................................................................................................................%55
).54 In&ut9e0tarea.....................................................................................................................%40
3
PrimeFaces Users Guide
).55 ;eyboard...........................................................................................................................%45
).52 6ayout................................................................................................................................%50
).59 6ayoutUnit.........................................................................................................................%55
).40 6i,ht1o0............................................................................................................................%55
).41 6in3....................................................................................................................................%20
).4% 6o,.....................................................................................................................................%2)
).4) 8edia.................................................................................................................................%25
).4- 8e,a8enu.........................................................................................................................%25
).45 8enu..................................................................................................................................%90
).44 8enubar.............................................................................................................................%94
).45 8enu1utton.......................................................................................................................%99
).42 8enuIte"..........................................................................................................................)01
).49 8ea,e.............................................................................................................................)0-
).50 8ea,e............................................................................................................................)04
).51 8ind"a&............................................................................................................................)09
).5% 8u(tiSe(ect6itbo0............................................................................................................)1%
).5) <oti+ication1ar..................................................................................................................)15
).5- 7rder6it............................................................................................................................)15
).55 7ut&ut6abe(.......................................................................................................................)%1
).54 7ut&ut!ane(.......................................................................................................................)%-
).55 7ver(ay!ane(.....................................................................................................................)%4
).52 !ane(..................................................................................................................................)%9
).59 !ane(Grid...........................................................................................................................))%
).20 !ane(8enu.........................................................................................................................))5
).21 !a'ord............................................................................................................................))5
).2% !hoto*a"..........................................................................................................................)-%
).2) !ic36it..............................................................................................................................)--
).2- !o((.....................................................................................................................................)50
).25 !rinter................................................................................................................................)5)
).24 !ro,re1ar........................................................................................................................)5-
).25 Radio1utton.......................................................................................................................)52
).22 Ratin,................................................................................................................................)59
).29 Re"ote*o""and..............................................................................................................)4)
).90 ReetIn&ut..........................................................................................................................)45
).91 Rei=ab(e............................................................................................................................)45
).9% Rin,...................................................................................................................................)51
).9) Ro'....................................................................................................................................)5-
).9- Ro'Editor..........................................................................................................................)55
).95 Ro'E0&anion...................................................................................................................)54
).94 Ro'9o,,(er.......................................................................................................................)55
).95 Schedu(e............................................................................................................................)52
).92 Scro((!ane(.........................................................................................................................)25
).99 Se(ect1oo(ean1utton.........................................................................................................)29
4
PrimeFaces Users Guide
).100 Se(ect1oo(ean*hec3bo0..................................................................................................)91
).101 Se(ect*hec3bo08enu......................................................................................................)9)
).10% Se(ect8any1utton...........................................................................................................)95
).10) Se(ect8any*hec3bo0......................................................................................................)99
).10- Se(ect8any8enu.............................................................................................................-01
).105 Se(ect7ne1utton..............................................................................................................-05
).104 Se(ect7ne6itbo0............................................................................................................-05
).105 Se(ect7ne8enu...............................................................................................................-11
).102 Se(ect7neRadio...............................................................................................................-14
).109 Se&arator..........................................................................................................................-19
).110 S(ide8enu........................................................................................................................-%1
).111 S(ider................................................................................................................................-%-
).11% S&ot(i,ht...........................................................................................................................-%9
).11- Soc3et..............................................................................................................................-)1
).115 S&acer..............................................................................................................................-))
).114 S&inner.............................................................................................................................-)-
).115 S&(it1utton.......................................................................................................................-)9
).112 Sub"enu..........................................................................................................................--)
).119 Stac3................................................................................................................................---
).1%0 Stic3y...............................................................................................................................--4
).1%1 Sub9ab(e..........................................................................................................................--2
).1%% Su""aryRo'..................................................................................................................--9
).1%) 9ab...................................................................................................................................-50
).1%- 9ab8enu..........................................................................................................................-51
).1%5 9ab>ie'...........................................................................................................................-5)
).1%4 9a,*(oud.........................................................................................................................-52
).1%5 9er"ina(...........................................................................................................................-41
).1%2 9he"eS'itcher................................................................................................................-4%
).1%9 9iered8enu......................................................................................................................-45
).1)0 9oo(bar.............................................................................................................................-42
).1)1 9oo(barGrou& ?De&recated@.............................................................................................-50
).1)% 9oo(ti&..............................................................................................................................-51
).1)) 9ree..................................................................................................................................-5-
).1)- 9ree<ode.........................................................................................................................-25
).1)5 9ree9ab(e.........................................................................................................................-24
).1)4 Water"ar3.......................................................................................................................-90
).1)5 Wi=ard..............................................................................................................................-9%
-. !artia( Renderin, and !rocein,.................................................................................................-92
-.1 !artia( Renderin,.................................................................................................................-92
-.1.1 In+ratructure................................................................................................................-92
-.1.% Uin, ID.....................................................................................................................-92
-.1.) <oti+yin, Uer............................................................................................................500
-.1.- 1it:!iece..................................................................................................................500
5
PrimeFaces Users Guide
-.% !artia( !rocein,................................................................................................................501
-.%.1 !artia( >a(idation..........................................................................................................501
-.%.% Uin, Id......................................................................................................................50%
-.) Search E0&reion #ra"e'or3............................................................................................50)
-.).1 ;ey'ord.....................................................................................................................50)
-.).% !ri"e#ace Se(ector ?!#S@.........................................................................................50-
-.- !artia(Sub"it.......................................................................................................................504
5. Aavacri&t A!I...............................................................................................................................505
5.1 !ri"e#ace <a"e&ace.......................................................................................................505
5.% A/a0 A!I..............................................................................................................................502
4. Dia(o, #ra"e'or3........................................................................................................................510
5. *(ient Side >a(idation...................................................................................................................51-
5.1 *on+i,uration.......................................................................................................................51-
5.% A/a0 v <onBA/a0................................................................................................................51-
5.) Event..................................................................................................................................515
5.- 8ea,e..............................................................................................................................515
5.5 1ean >a(idation...................................................................................................................514
5.4 E0tendin, *S>....................................................................................................................514
2. 9he"e..........................................................................................................................................5%1
2.1 A&&(yin, a 9he"e...............................................................................................................5%%
2.% *reatin, a <e' 9he"e........................................................................................................5%)
2.) .o' 9he"e Wor3..............................................................................................................5%-
2.- 9he"in, 9i&.......................................................................................................................5%5
9. !ri"e#ace !uh...........................................................................................................................5%4
9.1 Setu&....................................................................................................................................5%4
9.% Annotation..........................................................................................................................5%5
9.) A!I.......................................................................................................................................5%9
9.- Soc3et *o"&onent...............................................................................................................5%9
9.5 !uttin, It A(( 9o,ether.........................................................................................................5)0
9.5.1 *ounter........................................................................................................................5)0
9.5.% #ace8ea,e..............................................................................................................5)%
9.4 9i& and 9ric3....................................................................................................................5)-
10. !ri"e#ace 8obi(e.....................................................................................................................5)5
10.1 Setu&..................................................................................................................................5)5
10.% !a,e..................................................................................................................................5)4
10.% <avi,ation........................................................................................................................5)5
10.) *o"&onent.......................................................................................................................5)2
10.).1 *ontent.......................................................................................................................5)2
10.).% #ie(d...........................................................................................................................5)9
10.).) #ooter.........................................................................................................................5-0
10.).- .eader........................................................................................................................5-1
10.).5 In&utS(ider.................................................................................................................5-%
10.).4 !a,e............................................................................................................................5--
6
PrimeFaces Users Guide
10.).5 Ran,eS(ider................................................................................................................5-5
10.).2 S'itch........................................................................................................................5-4
10.- Render;it..........................................................................................................................5-2
10.-.1 Accordion!ane(..........................................................................................................5-2
10.-.% Auto*o"&(ete............................................................................................................5-2
10.-.) 1utton........................................................................................................................5-2
10.-.- *a(endar.....................................................................................................................5-9
10.-.5 Data6it......................................................................................................................5-9
10.-.4 Dia(o,........................................................................................................................5-9
10.-.5 #i(eU&(oad.................................................................................................................5-9
10.-.2 Gro'(.........................................................................................................................550
10.-.9 In&ut9e0t....................................................................................................................550
10.-.10 In&ut9e0tarea...........................................................................................................550
10.-.11 6in3..........................................................................................................................550
10.-.1% 8enu........................................................................................................................550
10.-.1) !ane(........................................................................................................................550
10.-.1- !ane(Grid.................................................................................................................551
10.-.15 Se(ect1oo(ean*hec3bo0..........................................................................................551
10.-.14 Se(ect*hec3bo08enu..............................................................................................551
10.-.15 Se(ect8any1utton...................................................................................................551
10.-.12 Se(ect8any*hec3bo0..............................................................................................551
10.-.19 Se(ect7ne1utton......................................................................................................551
10.-.%0 Se(ect7ne8enu........................................................................................................551
10.-.%1 Se(ect7neRadio.......................................................................................................551
10.-.%% 9ab8enu..................................................................................................................551
10.-.%- 9ab>ie'...................................................................................................................55%
10.-.%5 9oo(bar.....................................................................................................................55%
10.5 9he"e..............................................................................................................................55)
10.4 #ra"e'or3.........................................................................................................................55-
10.4.1 A/a0 U&date..............................................................................................................55-
10.4.% !a 9hrou,h E(e"ent..............................................................................................55-
10.4.) 6a=y !a,e.................................................................................................................555
10.4.- 9ouch Event..............................................................................................................555
11. Uti(itie.......................................................................................................................................555
11.1 ReCuet*onte0t..................................................................................................................555
11.% E6 #unction......................................................................................................................540
11.) E0ce&tion .and(er.............................................................................................................541
11.- 1ean>a(idation 9ran+or"ation.........................................................................................54)
11.5 !ri"e#ace 6oca(e...........................................................................................................54-
1%. !ort(et........................................................................................................................................545
1). Ri,htB9oB6e+t..............................................................................................................................542
1-. IDE Su&&ort................................................................................................................................549
1-.1 <et1ean............................................................................................................................549
1-.% Ec(i&e...............................................................................................................................550
7
PrimeFaces Users Guide
15. !ro/ect Reource.......................................................................................................................551
14. #AD............................................................................................................................................55%
8
PrimeFaces Users Guide
About the Author
aatay ivici i a "e"ber o+ AavaServer #ace E0&ert Grou&E the +ounder o+ !ri"e#ace and
!8* "e"ber o+ o&en ource AS# i"&(e"entation A&ache 8y#ace. .e i a reco,ni=ed &ea3er in
internationa( con+erence inc(udin, Aava7neE S&rin,7neE Aa=oonE AAFE WBAAFE AS#Su""itE
AS#DayE *onB#e and "any (oca( event uch a AUG.
aatay i a(o an author and technica( revie'er o+ a cou&(e boo3 re,ardin, 'eb a&&(ication
deve(o&"ent 'ith Aava and AS#. A an e0&erienced trainerE he ha trained over )00 deve(o&er on
Aava EE techno(o,ie "ain(y AS#E S&rin,E EA1 ).0 and A!A.
aatay i a(o 3no'n a 7&ti"u !ri"e in AavaServer #ace *o""unity.
9
PrimeFaces Users Guide
1. Introduction
1.1 What is PrimeFaces?
!ri"e#ace i an o&en ource AS# co"&onent uite 'ith variou e0tenion.
G Rich et o+ co"&onent ?.t"(EditorE Dia(o,E Auto*o"&(eteE *hart and "any "ore@.
G 1ui(tBin A/a0 baed on tandard AS# %.0 A/a0 A!I.
G 6i,ht'ei,htE one /arE =eroBcon+i,uration and no reCuired de&endencie.
G !uh u&&ort via At"o&here #ra"e'or3.
G 8obi(e UI 3it to create "obi(e 'eb a&&(ication.
G S3innin, #ra"e'or3 'ith )5H bui(tBin the"e and u&&ort +or viua( the"e dei,ner too(.
G E0tenive docu"entation.
G 6ar,eE vibrant and active uer co""unity.
G Deve(o&ed 'ith I&aionI +ro" a&&(ication deve(o&er to a&&(ication deve(o&er.
10
PrimeFaces Users Guide
2. Setup
2.1 Download
!ri"e#ace ha a in,(e /ar ca((ed primefaces-{version}.jar. 9here are t'o 'ay to do'n(oad thi
/arE you can either do'n(oad +ro" !ri"e#ace ho"e&a,e or i+ you are a "aven uer you can de+ine
it a a de&endency.
Download Manually
9hree di++erent arti+act are avai(ab(e +or each !ri"e#ace verionE binaryE ource and bund(e.
1und(e contain binaryE ource and /avadoc.
http://www.primefaces.org/downloads
Download with Maen
Grou& id i org.primefaces and arti+act id i primefaces.
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
11
PrimeFaces Users Guide
2.2 Dependencies
!ri"e#ace on(y reCuire a AA>A 5H runti"e and a AS# %.0 i"&(e"entation a "andatory
de&endencie. 9herere o"e o&tiona( (ibrarie +or certain +eature. 6icene o+ a(( de&endencie and
any )rd &art 'or3 incor&orated are co"&atib(e 'ith the !ri"e#ace 6icene.
Dependency Version * Type Description
AS# runti"e %.0E %.1 or %.% ReCuired A&ache 8y#ace or 7rac(e 8o/arra
ite0t %.1.5 7&tiona( DataE0&orter ?!D#@.
a&ache &oi ).5 7&tiona( DataE0&orter ?E0ce(@.
ro"e 1.0 7&tiona( #eedReader.
co""onB+i(eu&(oad 1.) 7&tiona( #i(eU&(oad
co""onBio %.% 7&tiona( #i(eU&(oad
at"o&here %.1.) 7&tiona( !ri"e#ace !uh
J 6ited verion are teted and 3no'n to be 'or3in, 'ith !ri"e#aceE other verion o+ thee
de&endencie "ay a(o 'or3 but not teted.
!SF "untime
!ri"e#ace 5.0 u&&ort AS# %.0E %.1 and %.% runti"e at the a"e ti"e uin, +eature detection and
by not havin, co"&i(e ti"e de&endency to a &eci+ic verion. A a reu(t o"e +eature are on(y
avai(ab(e de&endin, on the runti"e.
A ,ood e0a"&(e +or runti"e co"&atibi(ity i the &athrou,h attributeE a AS# %.% &eci+ic +eature to
di&(ay dyna"ic attribute. In +o((o'in, &a,eE &a throu,h attribute &(aceho(der on(y ,et rendered
i+ the runti"e i AS# %.%.
<!DO!"#$ html>
<html &mlns'(http://www.w)c.org/*+++/&html(
&mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:p'(http://primefaces.org/ui(
&mlns:pt'(http://&mlns.,cp.org/,sf/passthrough(>
<h:head>
</h:head>
<h:-ody>
<p:input!e&t value'(./-ean.value0( pt:placeholder'(1atermar2 here(/>
</h:-ody>
</html>
12
PrimeFaces Users Guide
2.# $on%i&uration
!ri"e#ace doe not reCuire any "andatory con+i,uration and +o((o' con+i,uration by e0ce&tion
&attern o+ Aava EE. .ere i the (it o+ a(( con+i,uration o&tion de+ined 'ith a conte0B&ara" uch aK
<conte&t3param>
<param3name>primefaces.!4$5$</param3name>
<param3value>-ootstrap</param3value>
</conte&t3param>
Name Default Description
9.E8E arito 9he"e o+ the a&&(ication.
"obi(e.9.E8E nu(( 9he"e o+ the "obi(e a&&(ication.
!US.LSER>ERLUR6 nu(( *uto" erver ur( +or !ri"e#ace !uh.
SU18I9 +u(( De+ine a/a0 ub"it "odeE full or partial.
DIR (tr De+ine orientationE ltr or rtl.
RESE9L>A6UES 0 When enab(edE a/a0 u&dated in&ut are reet +irt.
SE*RE9 &ri"e+ace Secret 3ey to encry&tBdecry&t va(ue e0&reion e0&oed
in renderin, Strea"ed*ontent.
*6IE<9LSIDEL>A6IDA9I7< 0 *ontro( c(ient ide va(idatation.
U!67ADER auto De+ine u&(oader "odeK autoE native or commons.
9RA<S#7R8L8E9ADA9A +a(e 9ran+or" bean va(idation "etadata to ht"( attribute.
2.' (ello World
7nce you have added the &ri"e+ace /ar to your c(a&athE you need to add the !ri"e#ace
na"e&ace to your &a,e to be,in uin, the co"&onent. .ere i a i"&(e &a,e (i3e tet.0ht"(K
<!DO!"#$ html>
<html &mlns'(http://www.w)c.org/*+++/&html(
&mlns:h'(http://&mlns.,cp.org/,sf/html(
&mlns:p'(http://primefaces.org/ui(>
<h:head></h:head>
<h:-ody>
<p:editor />
</h:-ody>
</html>
When you run thi &a,e throu,h #ace Serv(et "a&&in, e.,. J./+E you hou(d ee a rich te0t editor
'hen you run the &a,e 'ith tet./+.
13
PrimeFaces Users Guide
#. $omponent Suite
#.1 AccordionPanel
Accordion!ane( i a container co"&onent that di&(ay content in tac3ed +or"at.
In%o
9a, accordionPanel
*o"&onent *(a org.primefaces.component.accordionpanel.Accordionpanel
*o"&onent 9y&e org.primefaces.component.AccordionPanel
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.AccordionPanelenderer
Renderer *(a org.primefaces.component.accordionpanel.AccordionPanelenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true boo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onent.
bindin, nu(( 7b/ect An E6 e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
activeInde0 +a(e Strin, Inde0 o+ the active tab or a co""a e&arated trin, o+
inde0e 'hen "u(ti&(e "ode i on.
14
PrimeFaces Users Guide
Name Default Type Description
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
on9ab*han,e nu(( Strin, *(ient ide ca((bac3 to invo3e 'hen an inactive tab i
c(ic3ed.
on9abSho' nu(( Strin, *(ient ide ca((bac3 to invo3e 'hen a tab ,et activated.
dyna"ic +a(e 1oo(ean De+ine the to,,(e "ode.
cache true 1oo(ean De+ine i+ activatin, a dyna"ic tab hou(d (oad the
content +ro" erver a,ain.
va(ue nu(( 6it 6it to iterate to di&(ay dyna"ic nu"ber o+ tab.
var nu(( Strin, <a"e o+ iterator to ue in a dyna"ic nu"ber o+ tab.
"u(ti&(e +a(e 1oo(ean *ontro( "u(ti&(e e(ection.
dir (tr Strin, De+ine te0t directionE va(id va(ue are ltr and rtl.
&re&endId true 1oo(ean Accordion!ane( i a na"in, container thu &re&end it
id to it chi(dren by de+au(tE a +a(e va(ue turn thi
behavior o++ e0ce&t +or dyna"ic tab.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
)ettin& Started with Accordion Panel
Accordion &ane( conit o+ one or "ore tab and each tab can ,rou& any content. 9it(e can a(o be
de+ined 'ith tit(e +acet.
<p:accordion#anel>
<p:ta- title'(6irst !a- !itle(>
<h:output!e&t value' (7orem(/>
...5ore content for first ta-
</p:ta->
<p:ta- title'(8econd !a- !itle(>
<h:output!e&t value'(Ipsum( />
</p:ta->
//any num-er of ta-s
</p:accordion#anel>
Dynamic $ontent *oadin&
Accordion!ane( u&&ort (a=y (oadin, o+ tab contentE 'hen dyna"ic o&tion i et trueE on(y active
tab content 'i(( be rendered to the c(ient ide and c(ic3in, an inactive tab header 'i(( do an a/a0
reCuet to (oad the tab content.
9hi +eature i ue+u( to reduce band'idth and &eed u& &a,e (oadin, ti"e. 1y de+au(t activatin, a
&reviou(y (oaded dyna"ic tab doe not initiate a reCuet to (oad the content a,ain a tab i cached.
9o contro( thi behavior ue cache o&tion.
15
PrimeFaces Users Guide
<p:accordion#anel dynamic'(true(>
//..ta-s
</p:accordion#anel>
$lient Side $allbac+s
onTabChange i ca((ed be+ore a tab i ho'n and onTabShow i ca((ed a+ter. 1oth receive container
e(e"ent o+ the tab to ho' a the &ara"eter.
<p:accordion#anel on!a-hange'(handlehange9panel:(>
//..ta-s
</p:accordion#anel>
<script type'(te&t/,avascript(>
function handlehange9panel: /
//panel: new ta- content container
0
</script>
A,a- .ehaior /ents
tabChange i the one and on(y a/a0 behavior event o+ accordion &ane( that i e0ecuted 'hen a tab i
to,,(ed.
<p:accordion#anel>
<p:a,a& event'ta-hange listener'./-ean.onhange0 />
</p:accordion#anel>
pu-lic void onhange9!a-hange$vent event: /
//!a- active!a- ' event.get!a-9:;
//...
0
Mour (itener?i+ de+ined@ 'i(( be invo3ed 'ith an org.primefaces.event.TabChangeEvent intance
that contain a re+erence to the ne' active tab and the accordion &ane( ite(+.
Dynamic 0umber o% 1abs
When the tab to di&(ay are not taticE ue the bui(tBin iteration +eature i"i(ar to uiNre&eat.
<p:accordion#anel value'./-ean.list0 var'listItem>
<p:ta- title'(./listItem.property<0(>
<h:output!e&t value' (./listItem.property=0(/>
...5ore content
</p:ta->
</p:accordion#anel>
16
PrimeFaces Users Guide
Disabled 1abs
A tab can be diab(ed by ettin, diab(ed attribute to true.
<p:accordion#anel>
<p:ta- title'(6irst !a- !itle( disa-led'true>
<h:output!e&t value' (7orem(/>
...5ore content for first ta-
</p:ta->
<p:ta- title'(8econd !a- !itle(>
<h:output!e&t value'(Ipsum( />
</p:ta->
//any num-er of ta-s
</p:accordion#anel>
Multiple Selection
1y de+au(tE on(y one tab at a ti"e can be activeE enab(e multiple "ode to activate "u(ti&(e tab.
<p:accordion#anel multiple'true>
//ta-s
</p:accordion#anel>
$lient Side API
Wid,etN PrimeFaces.widget.AccordionPanel
!et"od Params eturn Type Description
e(ect?inde0@ inde0N Inde0 o+ tab void Activate tab 'ith ,iven inde0.
une(ect?inde0@ inde0N Inde0 o+ tab void Deactivate tab 'ith ,iven inde0.
S+innin&
Accordion!ane( reide in a "ain container e(e"ent 'hich style and styleClass o&tion a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
#lass Applies
.uiBaccordion 8ain container e(e"ent
.uiBaccordionBheader 9ab header
.uiBaccordionBcontent 9ab content
17
PrimeFaces Users Guide
#.2 A,a-.ehaior
A/a01ehavior i an e0tenion to tandard +Na/a0.
In%o
9a, aja$
1ehavior Id org.primefaces.component.Aja$%e"avior
1ehavior *(a org.primefaces.component.&e"avior.aja$.Aja$%e"avior
Attributes
Name Default Type Description
(itener nu(( 8ethod
E0&r
8ethod to &roce in &artia( reCuet.
i""ediate +a(e boo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen +a(e
at invo3eLa&&(ication &hae.
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent?@ to &roce in &artia( reCuet.
u&date nu(( Strin, *o"&onent?@ to u&date 'ith a/a0.
ontart nu(( Strin, *a((bac3 to e0ecute be+ore a/a0 reCuet i be,in.
onco"&(ete nu(( Strin, *a((bac3 to e0ecute 'hen a/a0 reCuet i co"&(eted.
onucce nu(( Strin, *a((bac3 to e0ecute 'hen a/a0 reCuet ucceed.
onerror nu(( Strin, *a((bac3 to e0ecute 'hen a/a0 reCuet +ai(.
,(oba( true 1oo(ean G(oba( a/a0 reCuet are (itened by a/a0Statu co"&onentE
ettin, ,(oba( to +a(e 'i(( not tri,,er a/a0Statu.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or i+
the va(ue o+ delay i the (itera( trin, OnoneO 'ithout the
CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
diab(ed +a(e 1oo(ean Diab(e a/a0 behavior.
event nu(( Strin, *(ient ide event to tri,,er a/a0 reCuet.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
18
PrimeFaces Users Guide
Name Default Type Description
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not be
u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue i
+a(eE no uch indication i "ade.
)ettin& Started with A,a-.ehaior
A/a01ehavior i attached to the co"&onent to a/a0i+y.
<h:input!e&t value'(./-ean.te&t0(>
<p:a,a& update'(out( />
</h:input!e&t>
<h:output!e&t id'(out( value'(./-ean.te&t0( />
In the e0a"&(e aboveE each ti"e the in&ut chan,eE an a/a0 reCuet i ent to the erver. When the
re&one i received out&ut te0t 'ith id IoutI i u&dated 'ith va(ue o+ the in&ut.
*istener
In cae you need to e0ecute a "ethod on a bac3in, beanE de+ine a (itenerK
<h:input!e&t id'(counter(>
<p:a,a& update'(out( listener'(./counter=ean.increment0(/>
</h:input!e&t>
<h:output!e&t id'(out( value'(./counter=ean.count0( />
pu-lic class ounter=ean /
private int count;
//getter setter
pu-lic void increment9: /
count>>;
0
0
/ents
De+au(t c(ient ide event are de+ined by co"&onent that u&&ort c(ient behaviorE +or in&ut
co"&onent it i onchange and +or co""and co"&onent it i onclic". In order to override the do"
event to tri,,er the a/a0 reCuet ue event o&tion. In +o((o'in, e0a"&(eE a/a0 reCuet i tri,,ered
'hen 3ey i u& on in&ut +ie(d.
<h:input!e&t id'(firstname( value'(./-ean.te&t0(>
<p:a,a& update'(out( event'(2eyup(/>
</h:input!e&t>
<h:output!e&t id'(out( value'(./-ean.te&t0( />
19
PrimeFaces Users Guide
3.3 AjaxExceptionHandler
A/a0E0ce&tion.and(er i a uti(ity co"&onent +or the bui(tBin E0ce&tion.and(er.
In%o
9a, aja$'$ception(andler
*o"&onent *(a org.primefaces.component.aja$e$ception"andler.Aja$'$ception(andler
*o"&onent 9y&e org.primefaces.component.Aja$'$ception(andler
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onent.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
one0ce&tion nu(( Strin, *(ient ide ca((bac3 to e0ecute a+ter a e0ce&tion
'ith thi ty&e occured.
u&date nu(( Strin, *o"&onent to u&date a+ter a e0ce&tion 'ith thi
ty&e occured.
ty&e nu(( Strin, E0ce&tion ty&e to hand(e.
)ettin& Started with A,a-/-ception(andler
!(eae +ind the detai(ed in+or"ation about thi co"&onent at E0ce&tion.and(er ection at Uti(itie
cha&ter.
20
PrimeFaces Users Guide
#.' A,a-Status
A/a0Statu i a ,(oba( noti+ier +or a/a0 reCuet.
In%o
9a, aja$)tatus
*o"&onent *(a org.primefaces.component.aja$status.Aja$)tatus
*o"&onent 9y&e org.primefaces.component.Aja$)tatus
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Aja$)tatusenderer
Renderer *(a org.primefaces.component.aja$status.Aja$)tatusenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onent.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ontart nu(( Strin, *(ient ide ca((bac3 to e0ecute a+ter a/a0 reCuet
tart.
onco"&(ete nu(( Strin, *(ient ide ca((bac3 to e0ecute a+ter a/a0 reCuet
co"&(ete.
onucce nu(( Strin, *(ient ide ca((bac3 to e0ecute a+ter a/a0 reCuet
co"&(eted ucce+u((y.
onerror nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen an a/a0
reCuet +ai(.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
21
PrimeFaces Users Guide
)ettin& Started with A,a-Status
A/a0Statu ue +acet to re&reent the reCuet tatu. 8ot co""on ued +acet are start and
complete. Start +acet 'i(( be viib(e once a/a0 reCuet be,in and tay viib(e unti( it co"&(eted.
7nce the a/a0 re&one i received and &a,e i u&datedE tart +acet ,et hidden and co"&(ete +acet
ho' u&.
<p:a,a&8tatus>
<f:facet name'(start(>
<p:graphicImage value'(a,a&loading.gif( />
</f:facet>
<f:facet name'(complete(>
<h:output!e&t value'(Done!( />
</f:facet>
</p:a,a&8tatus>
/ents
.ere i the +u(( (it o+ avai(ab(e event na"eK
defaultN Initia((y viib(e 'hen &a,e i (oaded.
startN 1e+ore a/a0 reCuet be,in.
successN When a/a0 re&one i received 'ithout error.
errorN When a/a0 re&one i received 'ith an htt& error.
completeN When everythin, +inihe.
<p:a,a&8tatus>
<f:facet name'(error(>
<h:output!e&t value'($rror( />
</f:facet>
<f:facet name'(success(>
<h:output!e&t value'(8uccess( />
</f:facet>
<f:facet name'(default(>
<h:output!e&t value'(Idle( />
</f:facet>
<f:facet name'(start(>
<h:output!e&t value'(8ending( />
</f:facet>
<f:facet name'(complete(>
<h:output!e&t value'(Done( />
</f:facet>
</p:a,a&8tatus>
$ustom /ents
#acet are the dec(arative 'ay to ueE i+ youd (i3e to i"&(e"ent advanced cae 'ith cri&tin, you
can ta3e advanta,e o+ onJ ca((bac3 'hich are the event hand(er counter&art o+ the +acet.
<p:a,a&8tatus onstart'(alert9?8tart?:( oncomplete'(alert9?$nd?:(/>
22
PrimeFaces Users Guide
A co""an ua,e o+ &ro,ra""atic a&&roach i to i"&(e"ent a cuto" tatu dia(o,K
<p:a,a&8tatus onstart'(#69?status?:.show9:( oncomplete'(#69?status?:.hide9:(/>
<p:dialog widget@ar'(status( modal'(true( closa-le'(false(>
#lease 1ait
</p:dialog>
$lient Side API
Wid,etN PrimeFaces.widget.A#a$Status
!et"od Params eturn Type Description
tri,,er?event@ eventN <a"e o+ event. void 9ri,,er ,iven event.
S+innin&
A/a0Statu i eCui&&ed 'ith style and styleClass. Sty(in, direct(y a&&(ie to a container e(e"ent
'hich contain the +acet.
<p:a,a&8tatus style'(width:)Ap&;height:)Ap&( ... />
1ips
G Avoid u&datin, a/a0Statu ite(+ to &revent du&(icate +acetQca((bac3 bindin,.
G !rovide a +i0ed 'idthQhei,ht to an in(ine a/a0Statu to &revent &a,e (ayout +ro" chan,in,.
ur( o&tion i the 3ey +or a "enuite"E i+ it i de+inedE it 'i(( 'or3 a a i"&(e (in3. I+ you
d (i3e to
ue "enuite" to e0ecute co""and 'ith or 'ithout a/a0E do not de+ine the ur( o&tion.
38
PrimeFaces Users Guide
#.6 .utton
1utton i an e0tenion to the tandard hNbutton co"&onent 'ith 3innin, ca&abi(itie.
In%o
9a, &utton
*o"&onent *(a org.primefaces.component.&utton.%utton
*o"&onent 9y&e org.primefaces.component.%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.%uttonenderer
Renderer *(a org.primefaces.component.&utton.%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onent.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6 e0&reion
o+ a (itera( te0t.
outco"e nu(( Strin, Ued to reo(ve a navi,ation cae.
inc(ude>ie'!ara" +a(e 1oo(ean Whether to inc(ude &a,e &ara"eter in tar,et URI
+ra,"ent nu(( Strin, Identi+ier o+ the tar,et &a,e 'hich hou(d be cro((ed to.
diab(ed +a(e 1oo(ean Diab(e button.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to button.
a(t nu(( Strin, A(ternate te0tua( decri&tion.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
i"a,e nu(( Strin, Sty(e c(a +or the button icon. ?de&recatedN ue icon@
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated "ar3u&
39
PrimeFaces Users Guide
Name Default Type Description
+or thi co"&onent.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu and
it va(ue ha been "odi+ied ince ,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i doub(e
c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button receive +ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed do'n
over button.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed and
re(eaed over button.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i re(eaed over
button.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
&reed do'n over button.
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved 'ithin button
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved a'ay +ro" button.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved onto button.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
re(eaed over button.
ty(e nu(( Strin, In(ine ty(e o+ the button.
ty(e*(a nu(( Strin, Sty(e c(a o+ the button.
read7n(y +a(e 1oo(ean 8a3e button read on(y.
tabinde0 nu(( Inte,er !oition in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
hre+ nu(( Strin, Reource to (in3 direct(y to i"&(e"ent anchor behavior.
icon nu(( Strin, Icon o+ the button.
icon!o (e+t Strin, !oition o+ the button icon.
tar,et Le(+ Strin, 9he 'indo' tar,et.
eca&e true 1oo(ean De+ine 'hether (abe( 'ou(d be eca&ed or not.
in(ine +a(e Strin, Di&(ay button a in(ine intead o+ 100R 'idthE "obi(y
40
PrimeFaces Users Guide
Name Default Type Description
on(y.
diab(e*(ientWindo' +a(e 1oo(ean Diab(e a&&endin, the *(ientWindo' on the renderin, o+
thi e(e"ent.
)ettin& Started with .utton
&Nbutton ua,e i a"e a tandard hNbuttonE an outco"e i neceary to navi,ate uin, GE9
reCuet. Au"e you are at ource.0ht"( and need to navi,ate tar,et.0ht"(.
<p:-utton outcome'(target( value'(Javigate(/>
Parameters
!ara"eter in URI are de+ined 'ith neted S+N&ara" QT ta,.
<p:-utton outcome'(target( value'(Javigate(>
<f:param name'(id( value'(*0( />
</p:-utton>
Icons
Icon +or button are de+ined via c and icon attributeE i+ you ue tit(e intead o+ va(ueE on(y icon
'i(( be di&(ayed and tit(e te0t 'i(( be di&(ayed a too(ti& on "oueover. Mou can a(o ue icon
+ro" !ri"e#ace the"e uch uiBiconBchec3.
<p:-utton outcome'(target( icon'(star( value'(1ith Icon(/>
<p:-utton outcome'(target( icon'(star( title'(1ith Icon(/>
.star /
-ac2ground3image: url9(images/star.png(:;
0
S+innin&
1utton render a button ta, 'hich style and styleClass a&&(ie. A 3innin, ty(e c(ae are ,(oba(E
ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBbutton 1utton e(e"ent
.uiBbuttonBte0tBon(y 1utton e(e"ent 'hen icon i not ued
.uiBbuttonBte0t 6abe( o+ button
41
PrimeFaces Users Guide
#.7 $ache
*ache co"&onent i ued to reduce &a,e (oad ti"e by cachin, the content a+ter initia( renderin,.
In%o
9a, cac"e
*o"&onent *(a org.primefaces.component.cac"e.-.#ac"e
*o"&onent 9y&e org.primefaces.component.#ac"e
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.-.#ac"eenderer
Renderer *(a org.primefaces.component.cac"e.-.#ac"eenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean.
diab(ed +a(e 1oo(ean Diab(e cachin,.
re,ion >ie' Id Strin, UniCue id o+ the cache re,ionE de+au(t to vie' id.
3ey nu(( Strin, UniCue id o+ the cache entry in re,ionE de+au(t to c(ient id o+
co"&onent.
)ettin& Started with $ache
A cache tore i reCuired to ue the cache co"&onentE t'o di++erent &rovider are u&&orted a
cache i"&(e"entationK E.*ache and .a=e(cat. !rovider i con+i,ured via a conte0tB&ara".
<conte&t3param>
<param3name>primefaces.<4$L#CO@ID$C</param3name>
<param3value>org.primefaces.cache.$4ache#rovider</param3value>
</conte&t3param>
.ere i a a"&(e ehcache.0"( to con+i,ure cache re,ionE there are t'o re,ion in thi
con+i,uration.
42
PrimeFaces Users Guide
<M&ml version'(*.0( encoding'(K!63G(M>
<ehcache &mlns:&si'(http://www.w).org/A00*/N578chema3instance(
&si:noJamespace8chema7ocation'(ehcache.&sd(
updatehec2'(true( monitoring'(autodetect(
dynamiconfig'(true(>
<dis28tore path'(,ava.io.tmpdir(/>
<defaultache
ma&$ntries7ocal4eap'(*0000(
eternal'(false(
time!oIdle8econds'(*A0(
time!o7ive8econds'(*A0(
dis28pool=uffer8iOe5='()0(
ma&$ntries7ocalDis2'(*0000000(
dis2$&piry!hreadInterval8econds'(*A0(
memory8tore$viction#olicy'(7CK(>
<persistence strategy'(local!emp8wap(/>
</defaultache>
<cache name'(testcache(
ma&$ntries7ocal4eap'(*0000(
eternal'(false(
time!oIdle8econds'(*A0(
time!o7ive8econds'(*A0(
dis28pool=uffer8iOe5='()0(
ma&$ntries7ocalDis2'(*0000000(
dis2$&piry!hreadInterval8econds'(*A0(
memory8tore$viction#olicy'(7CK(>
<persistence strategy'(local!emp8wap(/>
</cache>
</ehcache>
A+ter the con+i,urationE at UI ideE the cached &art need to be 'ra&&ed inide the &Ncache
co"&onent.
<p:cache>
//content to cache
</p:cache>
7nce the &a,e i (oaded initia((yE content inide &Ncache co"&onent i cached inide the cache
re,ion o+ the cache &rovider. !otbac3 on the a"e &a,e or reo&enin, the &a,e retrieve the out&ut
+ro" cache intead o+ renderin, the content re,u(ar(y.
$ache Proider API
*ache!rovider can be acceed viaK
+equestConte$t.getCurrent*nstance!.getApplicationConte$t!.getCacheProvider!
#or e0a"&(e uin, thi A!IE a(( cache re,ion can be c(eaned uin, clear! "ethod. Re+er to /avadoc
o+ *ache!rovider +or the +u(( (it o+ avai(ab(e "ethod.
43
PrimeFaces Users Guide
#.8 $alendar
*a(endar i an in&ut co"&onent ued to e(ect a date +eaturin, di&(ay "odeE &a,in,E (oca(i=ationE
a/a0 e(ection and "ore.
In%o
9a, calendar
*o"&onent *(a org.primefaces.component.calendar.#alendar
*o"&onent 9y&e org.primefaces.component.#alendar
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#alendarenderer
Renderer *(a org.primefaces.component.calendar.#alendarenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onent.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( /ava.uti(
.Date
>a(ue o+ the co"&onent
converter nu(( *onvert
erQStrin
,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted
at a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
44
PrimeFaces Users Guide
Name Default Type Description
va(idator nu(( 8ethod
E0&r
A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uchan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ai(.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"indate nu(( Date or
Strin,
Set ca(endarO "ini"u" viib(e date
"a0date nu(( Date or
Strin,
Set ca(endarO "a0i"u" viib(e date
&a,e 1 Inte,er Enab(e "u(ti&(e &a,e renderin,.
diab(ed +a(e 1oo(ean Diab(e the ca(endar 'hen et to true.
"ode &o&u& Strin, De+ine ho' the ca(endar 'i(( be di&(ayed.
&attern 88QddQyyyy Strin, Date#or"at &attern +or (oca(i=ation
(oca(e nu(( 7b/ect 6oca(e to be ued +or (abe( and converion.
&o&u&Icon nu(( Strin, Icon o+ the &o&u& button
&o&u&Icon7n(y +a(e 1oo(ean When enab(edE &o&u& icon i rendered 'ithout the
button.
navi,ator +a(e 1oo(ean Enab(e "onthQyear navi,ator
ti"eUone nu(( 9i"e
Uone
Strin, or a /ava.uti(.9i"eUone intance to &eci+y
the ti"e=one ued +or date converionE de+au(t to
9i"eUone.,etDe+au(t?@
readon(yIn&ut +a(e 1oo(ean 8a3e in&ut te0t o+ a &o&u& ca(endar readon(y.
ho'1utton!ane( +a(e 1oo(ean >iibi(ity o+ button &ane( containin, today and done
button.
e++ect nu(( Strin, E++ect to ue 'hen di&(ayin, and ho'in, the
&o&u& ca(endar.
e++ectDuration nor"a( Strin, Duration o+ the e++ect.
ho'7n both Strin, *(ient ide event that di&(ay the &o&u& ca(endar.
ho'Wee3 +a(e 1oo(ean Di&(ay the 'ee3 nu"ber ne0t to each 'ee3.
diab(edWee3end +a(e 1oo(ean Diab(e 'ee3end co(u"n.
45
PrimeFaces Users Guide
Name Default Type Description
ho'7ther8onth +a(e 1oo(ean Di&(ay day be(on,in, to other "onth.
e(ect7ther8onth +a(e 1oo(ean Enab(e e(ection o+ day be(on,in, to other
"onth.
yearRan,e nu(( Strin, Mear ran,e +or the navi,atorE de+au(t IcB10NcH10I
ti"e7n(y +a(e 1oo(ean Sho' on(y ti"e&ic3er 'ithout date.
te&.our 1 Inte,er .our te&.
te&8inute 1 Inte,er 8inute te&.
te&Second 1 Inte,er Second te&.
"in.our 0 Inte,er 8ini"u" boundary +or hour e(ection.
"a0.our %) Inte,er 8a0i"u" boundary +or hour e(ection.
"in8inute 0 Inte,er 8ini"u" boundary +or "inute e(ection.
"a08inute 59 Inte,er 8a0i"u" boundary +or hour e(ection.
"inSecond 0 Inte,er 8ini"u" boundary +or econd e(ection.
"a0Second 59 Inte,er 8a0i"u" boundary +or econd e(ection.
&a,edate nu(( 7b/ect Initia( date to di&(ay i+ va(ue i nu((.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the
in&ut e(e"ent.
a(t nu(( Strin, A(ternate te0tua( decri&tion o+ the in&ut +ie(d.
autoco"&(ete nu(( Strin, *ontro( bro'er autoco"&(ete behavior.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated
"ar3u& +or thi co"&onent.
"a0(en,th nu(( Inte,er 8a0i"u" nu"ber o+ character that "ay be
entered in thi +ie(d.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
(oe +ocu.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
(oe +ocu and it va(ue ha been "odi+ied ince
,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute onc(ic3 event.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
46
PrimeFaces Users Guide
Name Default Type Description
i doub(e c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
receive +ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
&reed do'n over in&ut e(e"ent.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
&reed and re(eaed over in&ut e(e"ent.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
re(eaed over in&ut e(e"ent.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i &reed do'n over in&ut e(e"ent
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved 'ithin in&ut e(e"ent.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved a'ay +ro" in&ut e(e"ent.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved onto in&ut e(e"ent.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i re(eaed over in&ut e(e"ent.
one(ect nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen te0t 'ithin
in&ut e(e"ent i e(ected by uer.
&(aceho(der nu(( Strin, S&eci+ie a hort hint.
readon(y +a(e 1oo(ean #(a, indicatin, that thi co"&onent 'i(( &revent
chan,e by the uer.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
i=e nu(( Inte,er <u"ber o+ character ued to deter"ine the 'idth
o+ the in&ut e(e"ent.
tabinde0 nu(( Inte,er !oition o+ the in&ut e(e"ent in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
be+oreSho'Day nu(( Strin, *(ient ide ca((bac3 to e0ecute be+ore di&(ayin, a
dateE ued to cuto"i=e date di&(ay.
"a3 nu(( Strin, A&&(ie a "a3 uin, the &attern.
47
PrimeFaces Users Guide
)ettin& Started with $alendar
>a(ue o+ the ca(endar hou(d be a /ava.uti(.Date.
<p:calendar value'(./date=ean.date0(/>
pu-lic class Date=ean /
private Date date;
//Ietter and 8etter
0
Display Modes
*a(endar ha t'o "ain di&(ay "odeE popup ?de+au(t@ and inline.
In(ine
<p:calendar value'(./date=ean.date0( mode'(inline( />
!o&u&
<p:calendar value'(./date=ean.date0( mode'(popup( />
show,n o&tion de+ine the c(ient ide event to di&(ay the ca(endar. >a(id va(ue areK
G +ocuN When in&ut +ie(d receive +ocu
G buttonN When &o&u& button i c(ic3ed
bothN 1oth
focus and button cae
48
PrimeFaces Users Guide
!o&u& 1utton
<p:calendar value'(./date=ean.date0( mode'(popup( showOn'(-utton( />
!o&u& Icon 7n(y
<p:calendar value'(./date=ean.date0( mode'(popup(
showOn'(-utton( popupIconOnly'(true( />
Pa&in&
*a(endar can a(o be rendered in "u(ti&(e &a,e 'here each &a,e corre&ond to one "onth. 9hi
+eature i tuned 'ith the pages attribute.
<p:calendar value'(./dateontroller.date0( pages'()(/>
*ocali9ation
1y de+au(t (oca(e in+or"ation i retrieved +ro" the vie' (oca(e and can be overridden by the (oca(e
attribute. 6oca(e attribute can ta3e a (oca(e 3ey a a Strin, or a /ava.uti(.6oca(e intance. De+au(t
(an,ua,e o+ (abe( are En,(ih and you need to add the neceary tran(ation to your &a,e "anua((y
a !ri"e#ace doe not inc(ude (an,ua,e tran(ation. !ri"e#ace Wi3i !a,e +or
49
PrimeFaces Users Guide
!ri"e#ace6oca(e i a co""unity driven &a,e 'here you "ay +ind the tran(ation you need.
!(eae contribute to thi 'i3i 'ith your o'n tran(ation.
http://wi2i.primefaces.org/display/omponents/#rime6aces>7ocales
9ran(ation i a i"&(e /avacri&t ob/ectE 'e u,,et addin, the code to a /avacri&t +i(e and inc(ude
in your a&&(ication. #o((o'in, i a 9ur3ih ca(endar.
<h:output8cript name'pathLtoLyourLtranslations.,s />
<p:calendar value'(./dateontroller.date0( locale'(tr( navigator'(true(
show=utton#anel'(true(/>
9o override ca(cu(ated &attern +ro" (oca(eE ue the &attern o&tionK
<p:calendar value'(./dateontroller.date*0( pattern'(dd.55.yyyy(/>
<p:calendar value'(./dateontroller.dateA0( pattern'(yyH 5H d(/>
<p:calendar value'(./dateontroller.date)0( pattern'($$$H dd 555H yyyy(/>
/%%ects
>ariou e++ect can be ued 'hen ho'in, and hidin, the &o&u& ca(endarE o&tion areK ho'E
(ideDo'nE +adeInE b(indE bounceE c(i&E dro&E +o(d and (ide.
A,a- .ehaior /ents
*a(endar &rovide a dateSelect a/a0 behavior event to e0ecute an intant a/a0 e(ection 'henever a
date i e(ected. I+ you de+ine a "ethod a a (itenerE it 'i(( be invo3ed by &ain, an
org.primefaces.event.SelectEvent intance.
50
PrimeFaces Users Guide
<p:calendar value'(./calendar=ean.date0(>
<p:a,a& event'date8elect listener'./-ean.handleDate8elect0 update'msg />
</p:calendar>
<p:messages id'(msg( />
pu-lic void handleDate8elect98elect$vent event: /
Date date ' 9Date: event.getO-,ect9:;
//<dd facesmessage
0
In &o&u& "odeE ca(endar a(o u&&ort re,u(ar a/a0 behavior event (i3e b(urE 3eyu& and "ore.
Date "an&es
Uin, "indate and "a0date o&tionE e(ectab(e date can be retricted. >a(ue +or thee attribute
can either be a trin, or a /ava.uti(.Date.
<p:calendar value'(./date=ean.date0( mode'(inline(
mindate'(0P/*0/A0*0( ma&date'(0P/*5/A0*0(/>
0ai&ator
<avi,ator i an eay 'ay to /u"& bet'een "onthQyear Cuic3(y.
<p:calendar value'(./date=ean.date0( mode'(inline( navigator'(true( />
1imePic+er
9i"e!ic3er +unctiona(ity i enab(ed by addin, ti"e +or"at to your &attern.
<p:calendar value'(./date=ean.date0( pattern'55/dd/yyyy 44:mm />
51
PrimeFaces Users Guide
Adanced $ustomi9ation
Ue be+oreSho'Day /avacri&t ca((bac3 to cuto"i=e the (oo3 o+ each date. 9he +unction return an
array 'ith t'o va(ueE +irt one i +(a, to indicate i+ date 'ou(d be di&(ayed a enab(ed and econd
&ara"eter i the o&tiona( ty(e c(a to add to date ce((. #o((o'in, e0a"&(e diab(ed tueday and
+riday.
<p:calendar value'(./date=ean.date0( -efore8howDay'(tuesdays<nd6ridaysOnly( />
6unction tuesdays<nd6ridaysDisa-led9date: /
var day ' date.getDay9:;
return Q9day !' A RR day !' 5:H ??S
0
Mas+
*a(endar ha a bui(tBin "a3 +eature i"i(ar to the In&ut8a3 co"&onent. Set mas" o&tion to true to
enab(e "a3 u&&ort.
$lient Side API
Wid,etN PrimeFaces.widget.Calendar
!et"od Params eturn Type Description
,etDate?@ B Date Return e(ected date
etDate?date@ dateN Date to di&(ay void Set di&(ay date
diab(e?@ B void Diab(e ca(endar
enab(e?@ B void Enab(e ca(endar
S+innin&
*a(endar reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y.
#o((o'in, i the (it o+ tructura( ty(e c(aeK
52
PrimeFaces Users Guide
)tyle #lass Applies
.uiBdate&ic3er 8ain container
.uiBdate&ic3erBheader .eader container
.uiBdate&ic3erB&rev !reviou "onth navi,ator
.uiBdate&ic3erBne0t <e0t "onth navi,ator
.uiBdate&ic3erBtit(e 9it(e
.uiBdate&ic3erB"onth 8onth di&(ay
.uiBdate&ic3erBtab(e Date tab(e
.uiBdate&ic3erB'ee3Bend 6abe( o+ 'ee3end
.uiBdate&ic3erBotherB"onth Date be(on,in, to other "onth
.uiBdate&ic3er td Each ce(( date
.uiBdate&ic3erBbutton&ane 1utton &ane(
.uiBdate&ic3erBcurrent 9oday button
.uiBdate&ic3erBc(oe *(oe button
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
53
PrimeFaces Users Guide
#.1: $aptcha
*a&tcha i a +or" va(idation co"&onent baed on Reca&tcha A!I.
In%o
9a, captc"a
*o"&onent *(a org.primefaces.component.captc"a.#aptc"a
*o"&onent 9y&e org.primefaces.component.#aptc"a
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#aptc"aenderer
Renderer *(a org.primefaces.component.captc"a.#aptc"aenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t.
converter nu(( *onverterQStri
n,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance.
In cae it a tatic te0tE it "ut re+er to a converter
id.
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired.
54
PrimeFaces Users Guide
Name Default Type Description
va(idator nu(( 8ethodE0&r A "ethod bindin, e0&reion that re+er to a
"ethod va(idation, the in&ut.
va(ue*han,e6itener nu(( >a(ue*han,e
6itener
A "ethod bindin, e0&reion that re+er to a
"ethod +or hand(in, a va(uchan,eevent.
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
&ub(ic;ey nu(( Strin, !ub(ic reca&tcha 3ey +or a &eci+ic do"ain
?de&recated@
the"e red Strin, 9he"e o+ the ca&tcha.
(an,ua,e en Strin, ;ey o+ the u&&orted (an,ua,e.
tabinde0 nu(( Inte,er !oition o+ the in&ut e(e"ent in the tabbin, order.
(abe( nu(( Strin, Uer &reentab(e +ie(d na"e.
ecure +a(e 1oo(ean Enab(e htt& u&&ort
)ettin& Started with $aptcha
*at&cha i i"&(e"ented a an in&ut co"&onent 'ith a bui(tBin va(idator that i inte,rated 'ith
re*a&tcha. #irt thin, to do i to i,n u& to re*a&tcha to ,et &ub(ic:&rivate 3ey. 7nce you have
the 3ey +or your do"ainE add the" to 'eb.0"( a +o((o'K
<conte&t3param>
<param3name>primefaces.#CI@<!$L<#!4<LT$"</param3name>
<param3value>"OKCL#CI@<!$LT$"</param3value>
</conte&t3param>
<conte&t3param>
<param3name>primefaces.#K=7IL<#!4<LT$"</param3name>
<param3value>"OKCL#K=7ILT$"</param3value>
</conte&t3param>
9hat i itE no' you can ue ca&tcha a +o((o'K
<p:captcha />
1hemes
*a&tcha +eature +o((o'in, bui(tBin the"e +or (oo3 and +ee( cuto"i=ationK
B red ?de+au(t@
B 'hite
B b(ac3,(a
B c(ean
9he"e are a&&(ied via the the"e attribute.
55
PrimeFaces Users Guide
<p:captcha theme'(white(/>
*an&ua&es
9e0t intruction di&(ayed on ca&tcha i cuto"i=ed 'ith the language attribute. 1e(o' i a ca&tcha
'ith 9ur3ih te0t.
<p:captcha language'(tr(/>
;erridin& <alidation Messa&es
1y de+au(t ca&tcha di&(ay it o'n va(idation "ea,eE thi can be eai(y overridden by the AS#
"ea,e bund(e "echani". *orre&ondin, 3ey areK
Su""ary &ri"e+ace.ca&tcha.I<>A6ID
Detai( &ri"e+ace.ca&tcha.I<>A6IDLdetai(
1ips
G Ue (abe( o&tion to &rovide readab(e error "ea,e in cae va(idation +ai(.
Enab(e
secure o&tion to u&&ort htt& other'ie bro'er 'i(( ,ive 'arnin,.
See
htt&NQQ'''.,oo,(e.co"Qreca&tchaQ(earn"ore to (earn "ore about ho' re*a&tcha 'or3.
56
PrimeFaces Users Guide
#.11 $arousel
*aroue( i a "u(ti &ur&oe co"&onent to di&(ay a et o+ data or ,enera( content 'ith (ide e++ect.
In%o
9a, carousel
*o"&onent *(a org.primefaces.component.carousel.#arousel
*o"&onent 9y&e org.primefaces.component.#arousel
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#arouselenderer
Renderer *(a org.primefaces.component.carousel.#arouselenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect A va(ue e0&reion that re+er to a co((ection
var nu(( Strin, <a"e o+ the reCuet co&ed iterator
nu">iib(e ) Inte,er <u"ber o+ viib(e ite" &er &a,e
+irt>iib(e 0 Inte,er Inde0 o+ the +irt e(e"ent to be di&(ayed
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
circu(ar +a(e 1oo(ean Set continuou cro((in,
vertica( +a(e 1oo(ean Set vertica( cro((in,
auto!(ayInterva( 0 Inte,er Set the ti"e in "i((iecond to have *aroue( tart
57
PrimeFaces Users Guide
Name Default Type Description
cro((in, auto"atica((y a+ter bein, initia(i=ed
&a,e6in3 ) Inte,er De+ine the nu"ber o+ &a,e (in3 o+ &a,inator.
e++ect (ide Strin, <a"e o+ the ani"ationE cou(d be +ade or (ide.
eain, eaeIn7ut*irc Strin, <a"e o+ the eain, ani"ation.
e++ectDuration 500 Inte,er Duration o+ the ani"ation in "i((iecond.
dro&do'n9e"&(ate. V&a,eW Strin, 9e"&(ate trin, +or dro&do'n o+ &a,inator.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent..
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent..
ite"Sty(e nu(( Strin, In(ine ty(e o+ each ite".
ite"Sty(e*(a nu(( Strin, Sty(e c(a o+ each ite".
header9e0t nu(( Strin, 6abe( +or header.
+ooter9e0t nu(( Strin, 6abe( +or +ooter.
)ettin& Started with $arousel
*aroue( ha t'o "ain ueBcaeK data and ,enera( content di&(ay. 9o be,in 'ith data iteration (et
ue a (it o+ car to di&(ay 'ith caroue(.
pu-lic class ar /
private 8tring model;
private int year;
private 8tring manufacturer;
private 8tring color;
...
0
pu-lic class ar=ean /
private 7ist<ar> cars;
pu-lic ar7istontroller9: /
cars ' new <rray7ist<ar>9:;
cars.add9new ar9(my5odel(H A005H (5anufacturerN(H (-lue(::;
//add more cars
0
//getter setter
0
58
PrimeFaces Users Guide
<p:carousel value'(./car=ean.cars0( var'(car( item8tyle'(width:A00p&(>
<p:graphicImage value'(/images/cars/./car.manufacturer0.,pg(/>
<h:output!e&t value'(5odel: ./car.model0( />
<h:output!e&t value'("ear: ./car.year0( />
<h:output!e&t value'(olor: ./car.color0( />
</p:carousel>
*aroue( iterate throu,h the car co((ection and render it chi(dren +or each carE note that you a(o
need to de+ine a 'idth +or each ite".
*imitin& <isible Items
1u de+au(t caroue( (it it ite" in &a,e 'ith i=e ). 9hi i cuto"i=ab(e 'ith the ro' attribute.
<p:carousel value'(./car=ean.cars0( var'(car( num@isi-le'(*(
item8tyle'(width:A00p&( >
...
</p:carousel>
/%%ects
!a,in, ha&&en 'ith a (ider e++ect by de+au(t and +o((o'in, eain, o&tion are u&&orted.
G bac31oth
G bac3In
G bac37ut
G bounce1oth
G bounceIn
G bounce7ut
G eae1oth
G eae1othStron,
G eaeIn
G eaeInStron,
G eae<one
G eae7ut
G eaeIn7ut*irc
G eae7utStron,
G e(atic1oth
G e(aticIn
G e(atic7ut
59
PrimeFaces Users Guide
SlideShow
*aroue( can di&(ay the content in a (ideho'E +or thi &ur&oe autoPlay*nterval and circular
attribute are ued. #o((o'in, caroue( di&(ay a co((ection o+ i"a,e a a (ideho'.
<p:carousel auto#layInterval'(A000( rows'(*( effect'(easeIn8trong( circular'(true(
item8tyle'width:A00p& >
<p:graphicImage value'(/images/nature*.,pg(/>
<p:graphicImage value'(/images/natureA.,pg(/>
<p:graphicImage value'(/images/nature).,pg(/>
<p:graphicImage value'(/images/natureE.,pg(/>
</p:carousel>
$ontent Display
Another ue cae o+ caroue( i tab baed content di&(ay.
<p:carousel rows'(*( item8tyle'(height:A00p&;width:U00p&;(>
<p:ta- title'(Iodfather #art I(>
<h:panelIrid columns'(A( cellpadding'(*0(>
<p:graphicImage value'(/images/godfather/godfather*.,pg( />
<h:output!e&t value'(!he story -egins as Don @ito ...( />
</h:panelIrid>
</p:ta->
<p:ta- title'(Iodfather #art II(>
<h:panelIrid columns'(A( cellpadding'(*0(>
<p:graphicImage value'(/images/godfather/godfatherA.,pg( />
<h:output!e&t value'(6rancis 6ord oppola?s ...(/>
</h:panelIrid>
</p:ta->
<p:ta- title'(Iodfather #art III(>
<h:panelIrid columns'(A( cellpadding'(*0(>
<p:graphicImage value'(/images/godfather/godfather).,pg( />
<h:output!e&t value'(<fter a -rea2 of ...( />
</h:panelIrid>
</p:ta->
</p:carousel>
60
PrimeFaces Users Guide
Item Selection
Sa"&(e be(o' e(ect an ite" +ro" the caroue( and di&(ay detai( 'ithin a dia(o,.
<h:form id'form(>
<p:carousel value'(./car=ean.cars0( var'(car( item8tyle'width:A00p& >
<p:graphicImage value'(/images/cars/./car.manufacturer0.,pg(/>
<p:command7in2 update'(:form:detail( oncomplete'(#69?dlg?:.show9:(>
<h:output!e&t value'(5odel: ./car.model0( />
<f:set#roperty<ction7istener value'(./car0( target'(./car=ean.selected0( />
</p:command7in2>
</p:carousel>
<p:dialog widget@ar'(dlg(>
<h:output!e&t id'(detail( value'(./car=ean.selected0( />
</p:dialog>
</h:form>
pu-lic class ar=ean /
private 7ist<ar> cars;
private ar selected;
//getters and setters
0
(eader and Footer
.eader and #ooter o+ caroue( can be de+ined in t'o 'ay eitherE uin, headerTe$t and footerTe$t
o&tion that ta3e i"&(e trin, a (abe( or by header and footer +acet that can ta3e any cuto"
content.
$lient Side API
Wid,etN PrimeFaces.widget.Carousel
!et"od Params eturn Type Description
ne0t?@ B void Di&(ay ne0t &a,e.
&rev?@ B void Di&(ay &reviou &a,e.
et!a,e?@ inde0 void Di&(ay &a,e 'ith ,iven inde0.
tartAuto&(ay?@ B void Start (ideho'.
to&Auto&(ay?@ B void Sto& (ideho'.
61
PrimeFaces Users Guide
S+innin&
*aroue( reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. itemStyle and
itemStyleClass attribute a&&(y to each ite" di&(ayed by caroue(. #o((o'in, i the (it o+ tructura(
ty(e c(aeK
)tyle #lass Applies
.uiBcaroue( 8ain container
.uiBcaroue(Bheader .eader container
.uiBcaroue(BheaderBtit(e .eader content
.uiBcaroue(Bvie'&ort *ontent container
.uiBcaroue(Bbutton <avi,ation button
.uiBcaroue(Bne0tBbutton <e0t navi,ation button o+ &a,inator
.uiBcaroue(B&revBbutton !rev navi,ation button o+ &a,inator
.uiBcaroue(B&a,eB(in3 !a,e (in3 o+ &a,inator.
.uiBcaroue(B&a,eB(in3 Each &a,e (in3 o+ &a,inator.
.uiBcaroue(Bite" Each ite".
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
62
PrimeFaces Users Guide
#.12 $ell/ditor
*e((Editor i a he(&er co"&onent o+ datatab(e ued +or ince(( editin,.
In%o
9a, cell'ditor
*o"&onent *(a org.primefaces.component.celleditor.#ell'ditor
*o"&onent 9y&e org.primefaces.component.#ell'ditor
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#ell'ditorenderer
Renderer *(a org.primefaces.component.celleditor.#ell'ditorenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
)ettin& Started with $ell/ditor
See in(ine editin, ection in datatab(e docu"entation +or "ore in+or"ation about ua,e.
63
PrimeFaces Users Guide
#.1# $hart
*hart co"&onent i a ,eneric ,ra&h co"&onent to create variou ty&e o+ chart uin, /C&(ot (ibrary.
Each chart ty&e ha it o'n ubection 'ith code e0a"&(e and ection ).1%.10 docu"ent the +u((
chartin, A!I.
In%o
9a, c"art
*o"&onent *(a org.primefaces.component.c"art.#"art
*o"&onent 9y&e org.primefaces.component.#"art
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#"artenderer
Renderer *(a org.primefaces.component.c"art.#"artenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty&e nu(( Strin, 9y&e o+ the chart.
"ode( nu(( *hart8ode( 8ode( ob/ect o+ data and ettin,.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
64
PrimeFaces Users Guide
3.13.1 PieChart
!ie*hart i created 'ith !ie*hart8ode(.
.asic
<p:chart type'(pie( value'(./-ean.model0( />
pu-lic class =ean /
private #iehart5odel model;
pu-lic =ean9: /
model ' new #iehart5odel9:;
model.set9(=rand *(H 5E0:;
model.set9(=rand A(H )A5:;
model.set9(=rand )(H P0A:;
model.set9(=rand E(H EA*:;
model.set!itle9(8imple #ie(:;
model.set7egend#osition9(w(:;
0
pu-lic #iehart5odel get5odel9: /
return model;
0
0
$ustomi9ed
<p:chart type'(pie( value'(./-ean.model0( />
65
PrimeFaces Users Guide
pu-lic class =ean /
private #iehart5odel model;
pu-lic =ean9: /
model ' new #iehart5odel9:;
model.set9(=rand *(H 5E0:;
model.set9(=rand A(H )A5:;
model.set9(=rand )(H P0A:;
model.set9(=rand E(H EA*:;
model.set!itle9(ustom #ie(:;
model.set7egend#osition9(e(:;
model.set6ill9false:;
model.set8howData7a-els9true:;
model.setDiameter9*50:;
0
pu-lic #iehart5odel get5odel9: /
return model;
0
0
66
PrimeFaces Users Guide
3.13.2 LineChart
6ine*hart8ode( i ued to create a (ine chart.
.asic
<p:chart type'(line( value'(./-ean.model0( />
pu-lic class =ean /
private 7inehart5odel model;
pu-lic =ean9: /
model ' new 7inehart5odel9:;
7inehart8eries series* ' new 7inehart8eries9:;
series*.set7a-el9(8eries *(:;
series*.set9*H A:;
series*.set9AH *:;
series*.set9)H ):;
series*.set9EH U:;
series*.set95H G:;
7inehart8eries seriesA ' new 7inehart8eries9:;
seriesA.set7a-el9(8eries A(:;
seriesA.set9*H U:;
seriesA.set9AH ):;
seriesA.set9)H A:;
seriesA.set9EH P:;
seriesA.set95H +:;
model.add8eries9series*:;
model.add8eries9seriesA:;
model.set!itle9(7inear hart(:;
model.set7egend#osition9(e(:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set5in90:;
y<&is.set5a&9*0:;
0
pu-lic 7inehart5odel get5odel9: /
return model;
0
0
67
PrimeFaces Users Guide
$ustomi9ed
<p:chart type'(line( value'(./-ean.model0( />
pu-lic class =ean /
private 7inehart5odel model;
pu-lic =ean9: /
model ' new 7inehart5odel9:;
hart8eries -oys ' new hart8eries9:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H *A0:;
-oys.set9(A005(H *00:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H *50:;
-oys.set9(A00G(H A5:;
hart8eries girls ' new hart8eries9:;
girls.set7a-el9(Iirls(:;
girls.set9(A00E(H 5A:;
girls.set9(A005(H U0:;
girls.set9(A00U(H **0:;
girls.set9(A00P(H +0:;
girls.set9(A00G(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(ategory hart(:;
model.set7egend#osition9(e(:;
model.set8how#oint7a-els9true:;
model.get<&es9:.put9<&is!ype.NH new ategory<&is9("ears(::;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set7a-el9(=irths(:;
y<&is.set5in90:;
y<&is.set5a&9A00:;
0
pu-lic 7inehart5odel get5odel9: /
return model;
0
0
68
PrimeFaces Users Guide
Area
<p:chart type'(line( value'(./-ean.model0( />
pu-lic class =ean /
private 7inehart5odel model;
pu-lic =ean9: /
model ' new 7inehart5odel9:;
7inehart8eries -oys ' new 7inehart8eries9:;
-oys.set6ill9true:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H *A0:;
-oys.set9(A005(H *00:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H *50:;
-oys.set9(A00G(H A5:;
7inehart8eries girls ' new 7inehart8eries9:;
girls.set6ill9true:;
girls.set7a-el9(Iirls(:;
girls.set9(A00E(H 5A:;
girls.set9(A005(H U0:;
girls.set9(A00U(H **0:;
girls.set9(A00P(H +0:;
girls.set9(A00G(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(<rea hart(:;
model.set7egend#osition9(ne(:;
model.set8tac2ed9true:;
model.set8how#oint7a-els9true:;
model.get<&is9<&is!ype.N:.set7a-el9("ears(:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set7a-el9(=irths(:;
y<&is.set5in90:;
y<&is.set5a&9)00:;
0
pu-lic artesianhart5odel get5odel9: /
return model;
0
0
69
PrimeFaces Users Guide
3.13.3 BarChart
1ar*hart8ode( i ued to created a 1ar*hart.
.asic
<p:chart type'(-ar( value'(./-ean.model0( />
pu-lic class =ean /
private =arhart5odel model;
pu-lic hart=ean9: /
model ' new =arhart5odel9:;
hart8eries -oys ' new hart8eries9:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H *A0:;
-oys.set9(A005(H *00:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H *50:;
-oys.set9(A00G(H A5:;
hart8eries girls ' new hart8eries9:;
girls.set7a-el9(Iirls(:;
girls.set9(A00E(H 5A:;
girls.set9(A005(H U0:;
girls.set9(A00U(H **0:;
girls.set9(A00P(H *)5:;
girls.set9(A00G(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(=ar hart(:;
model.set7egend#osition9(ne(:;
<&is &<&is ' model.get<&is9<&is!ype.N:;
&<&is.set7a-el9(Iender(:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set7a-el9(=irths(:;
y<&is.set5in90:;
y<&is.set5a&9A00:;
0
pu-lic =arhart5odel get5odel9: / return model; 0
0
70
PrimeFaces Users Guide
(ori9ontal and Stac+ed
<p:chart type'(-ar( value'(./-ean.model0( />
pu-lic class =ean /
private 4oriOontal=arhart5odel model;
pu-lic hart=ean9: /
model ' new 4oriOontal=arhart5odel9:;
hart8eries -oys ' new hart8eries9:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H 50:;
-oys.set9(A005(H +U:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H 55:;
-oys.set9(A00G(H A5:;
hart8eries girls ' new hart8eries9:;
girls.set7a-el9(Iirls(:;
girls.set9(A00E(H 5A:;
girls.set9(A005(H U0:;
girls.set9(A00U(H GA:;
girls.set9(A00P(H )5:;
girls.set9(A00G(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(4oriOontal and 8tac2ed(:;
model.set7egend#osition9(e(:;
model.set8tac2ed9true:;
<&is &<&is ' model.get<&is9<&is!ype.N:;
&<&is.set7a-el9(=irths(:;
&<&is.set5in90:;
&<&is.set5a&9A00:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set7a-el9(Iender(:;
0
pu-lic 4oriOontal=arhart5odel get5odel9: / return model; 0
0
71
PrimeFaces Users Guide
3.13.4 DonutChart
Donut*hart i ,enerated uin, Donut*hart8ode(.
.asic
<p:chart type'(donut( value'(./-ean.model0( />
pu-lic class =ean /
private Donuthart5odel model;
pu-lic hart=ean9: /
model ' new Donuthart5odel9:;
5ap<8tringH Jum-er> circle* ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circle*.put9(=rand *(H *50:;
circle*.put9(=rand A(H E00:;
circle*.put9(=rand )(H A00:;
circle*.put9(=rand E(H *0:;
model.addircle9circle*:;
5ap<8tringH Jum-er> circleA ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circleA.put9(=rand *(H 5E0:;
circleA.put9(=rand A(H *A5:;
circleA.put9(=rand )(H P0A:;
circleA.put9(=rand E(H EA*:;
model.addircle9circleA:;
5ap<8tringH Jum-er> circle) ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circle).put9(=rand *(H E0:;
circle).put9(=rand A(H )A5:;
circle).put9(=rand )(H E0A:;
circle).put9(=rand E(H EA*:;
model.addircle9circle):;
model.set!itle9(Donut hart(:;
model.set7egend#osition9(w(:;
0
pu-lic Donuthart5odel get5odel9: / return model; 0
0
72
PrimeFaces Users Guide
$ustomi9ed
<p:chart type'(donut( value'(./-ean.model0( />
pu-lic class =ean /
private Donuthart5odel model;
pu-lic hart=ean9: /
model ' new Donuthart5odel9:;
5ap<8tringH Jum-er> circle* ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circle*.put9(=rand *(H *50:;
circle*.put9(=rand A(H E00:;
circle*.put9(=rand )(H A00:;
circle*.put9(=rand E(H *0:;
model.addircle9circle*:;
5ap<8tringH Jum-er> circleA ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circleA.put9(=rand *(H 5E0:;
circleA.put9(=rand A(H *A5:;
circleA.put9(=rand )(H P0A:;
circleA.put9(=rand E(H EA*:;
model.addircle9circleA:;
5ap<8tringH Jum-er> circle) ' new 7in2ed4ash5ap<8tringH Jum-er>9:;
circle).put9(=rand *(H E0:;
circle).put9(=rand A(H )A5:;
circle).put9(=rand )(H E0A:;
circle).put9(=rand E(H EA*:;
model.addircle9circle):;
model.set!itle9(Donut hart(:;
model.set7egend#osition9(w(:;
model.set!itle9(ustom Options(:;
model.set7egend#osition9(e(:;
model.set8lice5argin95:;
model.set8howData7a-els9true:;
model.setData6ormat9(value(:;
model.set8hadow9false:;
0
pu-lic Donuthart5odel get5odel9: / return model; 0
0
73
PrimeFaces Users Guide
3.13.5 BubbleChart
1ubb(e*hart i created 'ith a 1ubb(e*hart8ode(.
.asic
<p:chart type'(-u--le( value'(./-ean.model0( />
pu-lic class =ean /
private =u--lehart5odel model;
pu-lic hart=ean9: /
model ' new =u--lehart5odel9:;
model.add9new =u--lehart8eries9(<cura(H P0H *G)H55::;
model.add9new =u--lehart8eries9(<lfa Comeo(H E5H +AH )U::;
model.add9new =u--lehart8eries9(<5 Ieneral(H AEH *0EH E0::;
model.add9new =u--lehart8eries9(=ugatti(H 50H *A)H U0::;
model.add9new =u--lehart8eries9(=51(H *5H G+H A5::;
model.add9new =u--lehart8eries9(<udi(H E0H *G0H G0::;
model.add9new =u--lehart8eries9(<ston 5artin(H P0H P0H EG::;
model.set!itle9(=u--le hart(:;
model.get<&is9<&is!ype.N:.set7a-el9(#rice(:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set5in90:;
y<&is.set5a&9A50:;
y<&is.set7a-el9(7a-els(:;
0
pu-lic =u--lehart5odel get5odel9: / return model; 0
0
74
PrimeFaces Users Guide
$ustomi9ed
<p:chart type'(-u--le( value'(./-ean.model0( />
pu-lic class =ean /
private =u--lehart5odel model;
pu-lic hart=ean9: /
model ' new =u--lehart5odel9:;
model.add9new =u--lehart8eries9(<cura(H P0H *G)H55::;
model.add9new =u--lehart8eries9(<lfa Comeo(H E5H +AH )U::;
model.add9new =u--lehart8eries9(<5 Ieneral(H AEH *0EH E0::;
model.add9new =u--lehart8eries9(=ugatti(H 50H *A)H U0::;
model.add9new =u--lehart8eries9(=51(H *5H G+H A5::;
model.add9new =u--lehart8eries9(<udi(H E0H *G0H G0::;
model.add9new =u--lehart8eries9(<ston 5artin(H P0H P0H EG::;
model ' init=u--le5odel9:;
model.set!itle9(ustom Options(:;
model.set8hadow9false:;
model.set=u--leIradients9true:;
model.set=u--le<lpha90.G:;
model.get<&is9<&is!ype.N:.set!ic2<ngle9350:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set5in90:;
y<&is.set5a&9A50:;
y<&is.set!ic2<ngle950:;
0
pu-lic =u--lehart5odel get5odel9: / return model; 0
0
75
PrimeFaces Users Guide
3.13. !hlc Chart
7h(c*hart8ode( i ued to di&(ay 7h(c *hart.
.asic
<p:chart type'(ohlc( value'(./-ean.model0( />
pu-lic class =ean /
private Ohlchart5odel model;
pu-lic hart=ean9: /
ohlc5odel ' new Ohlchart5odel9:;
ohlc5odel.add9new Ohlchart8eries9A00PH *E).GAH *EE.5UH *)U.0EH *)U.+P::;
ohlc5odel.add9new Ohlchart8eries9A00GH *)G.PH *)+.UGH *)5.*GH *)5.E::;
ohlc5odel.add9new Ohlchart8eries9A00+H *E).EUH *EE.UUH *)+.P+H *E0.0A::;
ohlc5odel.add9new Ohlchart8eries9A0*0H *E0.UPH *E).5UH *)A.GGH *EA.EE::;
ohlc5odel.add9new Ohlchart8eries9A0**H *)U.0*H *)+.5H *)E.5)H *)+.EG::;
ohlc5odel.add9new Ohlchart8eries9A0*AH *AE.PUH *)5.+H *AE.55H *)5.G*::;
ohlc5odel.add9new Ohlchart8eries9A0*AH *A).P)H *A+.)*H *A*.5PH *AA.5::;
ohlc5odel.set!itle9(O47 hart(:;
ohlc5odel.get<&is9<&is!ype.N:.set7a-el9("ear(:;
ohlc5odel.get<&is9<&is!ype.":.set7a-el9(#rice hange VT/Knit(:;
0
pu-lic Ohlchart5odel get5odel9: / return model; 0
0
76
PrimeFaces Users Guide
$andlestic+
<p:chart type'(ohlc( value'(./-ean.model0( />
pu-lic class =ean /
private Ohlchart5odel model;
pu-lic hart=ean9: /
model ' new Ohlchart5odel9:;
for9 int i'* ; i < E* ; i>>: /
ohlc5odelA.add9new Ohlchart8eries9iH 5ath.random9: W G0 > G0H
5ath.random9: W 50 > **0H 5ath.random9: W A0 > G0H 5ath.random9: W G0 > G0::;
0
model.set!itle9(andlestic2(:;
model.setandle8tic29true:;
model.get<&is9<&is!ype.N:.set7a-el9(8ector(:;
model.get<&is9<&is!ype.":.set7a-el9(Inde& @alue(:;
0
pu-lic Ohlchart5odel get5odel9: / return model; 0
0
77
PrimeFaces Users Guide
3.13." #eter$au%e Chart
8eterGau,e *hart i created uin, 8eterGau,e*hart8ode(.
.asic
<p:chart type'(metergauge( value'(./-ean.model0( />
pu-lic class =ean /
private 5eterIaugehart5odel model;
pu-lic hart=ean9: /
7ist<Jum-er> intervals ' new <rray7ist<Jum-er>9://
add9A0:;
add950:;
add9*A0:;
add9AA0:;
00;
model ' new 5eterIaugehart5odel9*E0H intervals:;
model.set!itle9(5eterIauge hart(:;
model.setIauge7a-el9(2m/h(:;
0
pu-lic 5eterIaugehart5odel get5odel9: / return model; 0
0
$ustomi9ed
<p:chart type'(metergauge( value'(./-ean.model0( />
78
PrimeFaces Users Guide
pu-lic class =ean /
private 5eterIaugehart5odel model;
pu-lic hart=ean9: /
7ist<Jum-er> intervals ' new <rray7ist<Jum-er>9://
add9A0:;
add950:;
add9*A0:;
add9AA0:;
00;
model ' new 5eterIaugehart5odel9*E0H intervals:;
model.set!itle9(ustom Options(:;
model.set8eriesolors9(UUccUUH+)-P5fH$P$U5GHccUUUU(:;
model.setIauge7a-el9(2m/h(:;
model.setIauge7a-el#osition9(-ottom(:;
model.set8how!ic27a-els9false:;
model.set7a-el4eight<d,ust9**0:;
model.setIntervalOuterCadius9*)0:;
0
pu-lic 5eterIaugehart5odel get5odel9: / return model; 0
0
79
PrimeFaces Users Guide
3.13.& Co'bined Chart
7n a"e ,ra&hE di++erent erie ty&e can be di&(ayed to,ether.
.asic
<p:chart type'(-ar( value'(./-ean.model0( />
pu-lic class =ean /
private =arhart5odel model;
pu-lic hart=ean9: /
com-ined5odel ' new =arhart5odel9:;
=arhart8eries -oys ' new =arhart8eries9:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H *A0:;
-oys.set9(A005(H *00:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H *50:;
-oys.set9(A00G(H A5:;
7inehart8eries girls ' new 7inehart8eries9:;
girls.set7a-el9(Iirls(:;
girls.set9(A00E(H 5A:;
girls.set9(A005(H U0:;
girls.set9(A00U(H **0:;
girls.set9(A00P(H *)5:;
girls.set9(A00G(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(=ar and 7ine(:;
model.set7egend#osition9(ne(:;
model.set5ouseover4ighlight9false:;
model.set8howDatatip9false:;
model.set8how#oint7a-els9true:;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set5in90:;
y<&is.set5a&9A00:;
0
pu-lic =arhart5odel get5odel9: / return model; 0
0
80
PrimeFaces Users Guide
3.13.( #ultiple Axi)
U& to 9 a0e ?0a0iB09a0iE ya0iBy9a0i@ can be di&(ayed on the a"e chart.
.asic
<p:chart type'(line( value'(./-ean.model0( />
pu-lic class =ean /
private 7inehart5odel model;
pu-lic hart=ean9: /
model ' new 7inehart5odel9:;
=arhart8eries -oys ' new =arhart8eries9:;
-oys.set7a-el9(=oys(:;
-oys.set9(A00E(H *A0:;
-oys.set9(A005(H *00:;
-oys.set9(A00U(H EE:;
-oys.set9(A00P(H *50:;
-oys.set9(A00G(H A5:;
7inehart8eries girls ' new 7inehart8eries9:;
girls.set7a-el9(Iirls(:;
girls.setNa&is9<&is!ype.NA:;
girls.set"a&is9<&is!ype."A:;
girls.set9(<(H 5A:;
girls.set9(=(H U0:;
girls.set9((H **0:;
girls.set9(D(H *)5:;
girls.set9($(H *A0:;
model.add8eries9-oys:;
model.add8eries9girls:;
model.set!itle9(5ulti <&is hart(:;
model.set5ouseover4ighlight9false:;
model.get<&es9:.put9<&is!ype.NH new ategory<&is9("ears(::;
model.get<&es9:.put9<&is!ype.NAH new ategory<&is9(#eriod(::;
<&is y<&is ' model.get<&is9<&is!ype.":;
y<&is.set7a-el9(=irth(:;
y<&is.set5in90:;
y<&is.set5a&9A00:;
<&is yA<&is ' new 7inear<&is9(Jum-er(:;
yA<&is.set5in90:;
yA<&is.set5a&9A00:;
model.get<&es9:.put9<&is!ype."AH yA<&is:;
0
pu-lic 7inehart5odel get5odel9: / return model; 0
0
81
PrimeFaces Users Guide
82
PrimeFaces Users Guide
3.13.1* Date Axi)
Ue DateA0i i+ you are di&(ayin, date in an a0i.
.asic
<p:chart type'(line( value'(./-ean.model0( />
pu-lic class =ean /
private 7inehart5odel model;
pu-lic hart=ean9: /
date5odel ' new 7inehart5odel9:;
7inehart8eries series* ' new 7inehart8eries9:;
series*.set7a-el9(8eries *(:;
series*.set9(A0*E30*30*(H 5*:;
series*.set9(A0*E30*30U(H AA:;
series*.set9(A0*E30*3*A(H U5:;
series*.set9(A0*E30*3*G(H PE:;
series*.set9(A0*E30*3AE(H AE:;
series*.set9(A0*E30*3)0(H 5*:;
7inehart8eries seriesA ' new 7inehart8eries9:;
seriesA.set7a-el9(8eries A(:;
seriesA.set9(A0*E30*30*(H )A:;
seriesA.set9(A0*E30*30U(H P):;
seriesA.set9(A0*E30*3*A(H AE:;
seriesA.set9(A0*E30*3*G(H *A:;
seriesA.set9(A0*E30*3AE(H PE:;
seriesA.set9(A0*E30*3)0(H UA:;
date5odel.add8eries9series*:;
date5odel.add8eries9seriesA:;
date5odel.set!itle9(Xoom for Details(:;
date5odel.setXoom9true:;
date5odel.get<&is9<&is!ype.":.set7a-el9(@alues(:;
Date<&is a&is ' new Date<&is9(Dates(:;
a&is.set!ic2<ngle9350:;
a&is.set5a&9(A0*E30A30*(:;
a&is.set!ic26ormat9(F- F.dH Fy(:;
date5odel.get<&es9:.put9<&is!ype.NH a&is:;
0
pu-lic 7inehart5odel get5odel9: / return model; 0
0
83
PrimeFaces Users Guide
3.13.11 +nteracti,e Chart
*hart are interactive co"&onentE in+or"ation about e(ected erie and ite" can be &aed via
a/a0 to a AS# bac3in, bean uin, Ite"Se(ectEvent.
.asic
<p:chart type'(pie( value'(./-ean.model0(>
<p:a,a& event'(item8elect( listener'(./-ean.item8elect0( />
</p:chart>
pu-lic class =ean /
private #iehart5odel model;
pu-lic hart=ean9: /
model ' new #iehart5odel9:;
model.set9(=rand *(H 5E0:;
model.set9(=rand A(H )A5:;
model.set9(=rand )(H P0A:;
model.set9(=rand E(H EA*:;
model.set!itle9(8imple #ie(:;
model.set7egend#osition9(w(:;
0
pu-lic #iehart5odel get5odel9: / return model; 0
pu-lic void item8elect9Item8elect$vent event: /
6aces5essage msg ' new 6aces5essage96aces5essage.8$@$CI!"LIJ6OH
(Item selected(H (Item Inde&: ( > event.getItemInde&9: >
(H 8eries Inde&:( > event.get8eriesInde&9::;
6acesonte&t.geturrentInstance9:.add5essage9nullH msg:;
0
0
84
PrimeFaces Users Guide
3.13.12 Export
*hart co"&onent &rovide a c(ient ide "ethod to convert the ,ra&h to an i"a,e. E0a"&(e be(o'
de"ontrate ho' to ue a button c(ic3 to e0&ort the chart a an i"a,e and di&(ay it in a dia(o, o
that uer can do'n(oad it a a re,u(ar i"a,e.
<p:chart type'(line( value'(./-ean.model0( style'(width:500p&;height:)00p&(
widget@ar'(chart(/>
<p:command=utton type'(-utton( value'($&port( icon'(ui3icon3e&tlin2(
onclic2'(e&porthart9:(/>
<p:dialog widget@ar'(dlg( show$ffect'(fade( modal'(true( header'(hart as an Image(>
<p:output#anel id'(output( layout'(-loc2( style'(width:500p&;height:)00p&(/>
</p:dialog>
function e&porthart9: /
//e&port image
V9?.output?:.empty9:.append9#69?chart?:.e&port<sImage9::;
//show the dialog
#69?dlg?:.show9:;
0
85
PrimeFaces Users Guide
3.13.13 -tatic +'a%e)
A#ree*hart 'ith Gra&hicI"a,e co"&onent i an a(ternative to the chart co"&onent.
.asic
<p:graphicImage value'(./-ean.chart0( />
pu-lic class =ean /
private 8treamedontent chart;
pu-lic =ean9: /
Y6reehart ,freechart ' hart6actory.create#iehart9(ities(H
createDataset9:H trueH trueH false:;
6ile chart6ile ' new 6ile9(dynamichart(:;
hartKtilities.savehart<s#JI9chart6ileH ,freechartH )P5H )00:;
chart ' new Default8treamedontent9new 6ileInput8tream9chart6ile:H
(image/png(:;
0
pu-lic 8treamedontent gethart9: / return model; 0
private #ieDataset createDataset9: /
Default#ieDataset dataset ' new Default#ieDataset9:;
dataset.set@alue9(Jew "or2(H new Dou-le9E5.0::;
dataset.set@alue9(7ondon(H new Dou-le9*5.0::;
dataset.set@alue9(#aris(H new Dou-le9A5.A::;
dataset.set@alue9(=erlin(H new Dou-le9*E.G::;
return dataset;
0
0
86
PrimeFaces Users Guide
3.13.14 -.innin%
*hart can be ty(ed uin, re,u(ar c. #o((o'in, i the (it o+ ty(e c(aeK
)tyle #lass Applies
./C&(otBtar,et !(ot tar,et container.
./C&(otBa0i A0e.
./C&(otB0a0i !ri"ary 0Ba0i.
./C&(otBya0i !ri"ary yBa0i.
./C&(otB0%a0iE ./C&(otB0)a0i ... %ndE )rd ... 0Ba0i.
./C&(otBy%a0iE ./C&(otBy)a0i ... %ndE )rd ... yBa0i.
./C&(otBa0iBtic3 A0i tic3.
./C&(otB0a0iBtic3 !ri"ary 0Ba0i tic3.
./C&(otB0%a0iBtic3 Secondary 0Ba0i tic3.
./C&(otBya0iBtic3 !ri"ary yBa0iBtic3.
./C&(otBy%a0iBtic3 Seconday yBa0iBtic3.
tab(e./C&(otBtab(eB(e,end 6e,end tab(e.
./C&(otBtit(e 9it(e o+ the chart.
./C&(otBcurorBtoo(ti& *uror too(ti&.
./C&(otBhi,h(i,hterBtoo(ti& .i,h(i,hter too(ti&.
div./C&(otBtab(eB(e,endB'atch *o(or 'atch o+ the (e,end.
Additiona((y style and styleClass o&tion o+ chart co"&onent a&&(y to the container e(e"ent o+
chartE ue thee attribute to &eci+y the di"enion o+ a chart.
<p:piehart value'(./-ean.model0( style'width:)A0p&;height:A00p& />
In cae youd (i3e to chan,e the co(or o+ erieE ue the seriesColors o&tion in *hart8ode( A!I.
87
PrimeFaces Users Guide
3.13.15 Extender
*hart A!I &rovide hi,h (eve( acce to co""on(y ued /C&(ot o&tion ho'ever there are "any "ore
cuto"i=ation o&tion avai(ab(e in /C&(ot. E0tender +eature &rovide acce to (o' (eve( a&i to do
advanced cuto"i=ation by enhancin, the con+i,uration ob/ectE here i an e0a"&(e to increae
hado' de&th o+ the (ine erie 'here "ode(O e0tender &ro&erty i et to Ie0tI.
<p:chart type'(line( value'(./-ean.model0( />
function e&t9: /
//this ' chart widget instance
//this.cfg ' options
this.cfg.seriesDefaults ' /
shadowDepth: 5
0;
0
Re+er to /C!(ot doc +or avai(ab(e o&tion.
88
PrimeFaces Users Guide
3.13.1 Chart AP+
A-is
org.primefaces.model.chart.A$is
Property Default Type Description
(abe( nu(( Strin, 9it(e o+ the a0i.
"in nu(( 7b/ect 8ini"u" boundary va(ue.
"a0 nu(( 7b/ect 8a0i"u" boundary va(ue.
tic3An,(e nu(( Inte,er An,(e o+ te0tE "eaured c(oc3'ie.
tic3#or"at nu(( Strin, #or"at trin, to ue 'ith the a0i tic3 +or"atter
tic3Interva( nu(( Strin, <u"ber o+ unit bet'een tic3.
tic3*ount nu(( Inte,er Deired nu"ber o+ tic3.
A-is1ype
org.primefaces.model.chart.A$isType
A0i9y&e i an enu" to de+ine the ty&e o+ the a0i +ro" FBM to F9BM9.
.ar$hartModel
org.primefaces.model.chart.)arChart-odel e0tend org.primefaces.model.chart.Chart-odel
Property Default Type Description
bar!addin, 2 Inte,er !addin, bet'een bar.
bar8ar,in 10 Inte,er 8ar,in bet'een bar.
tac3ed +a(e 1oo(ean Di&(ay erie in tac3ed +or"at.
.ar$hartSeries
org.primefaces.model.chart.)arChartSeries e0tend org.primefaces.model.chart.ChartSeries
Property Default Type Description
diab(eStac3 +a(e 1oo(ean When trueE erie data i not inc(uded in a tac3ed chart.
.ubble$hartModel
org.primefaces.model.chart.)ubbleChart-odel e0tend org.primefaces.model.chart.Chart-odel
Property Default Type Description
data nu(( 6itS1ubb(e*hartSerieT Data a a (it o+ 1ubb(e*hartSerie.
bubb(eGradient +a(e 1oo(ean Di&(ay bubb(e 'ith ,radient.
bubb(eA(&ha 1.0 Doub(e 7&acity o+ bubb(e.
ho'6abe( true 1oo(ean Di&(ay (abe( o+ a erie inide a bubb(e.
89
PrimeFaces Users Guide
.ubble$hartSeries
org.primefaces.model.chart.)arChartSeries e0tend org.primefaces.model.chart.ChartSeries
Property Default Type Description
0 nu(( Inte,er FBA0i va(ue o+ the bubb(e.
y nu(( Inte,er MBA0i va(ue o+ the bubb(e.
radiu nu(( Inte,er Radiu o+ the bubb(e.
(abe( nu(( Strin, 6abe( te0t o+ the bubb(e.
$artesian$hartModel
org.primefaces.model.chart.CartesianChart-odel
Property Default Type Description
erie nu(( 6itS*hartSerieT 6it o+ erie.
a0e .ah8a& 8a&SA0i9y&eEA0iT 8a& o+ chart a0i.
=oo" +a(e 1oo(ean Add =oo" +eature 'hen enab(ed.
ani"ate +a(e 1oo(ean When enab(edE erie are dra'n 'ith an e++ect.
ho'Datati& true 1oo(ean Di&(ay a too(ti& on hover.
datati&#or"at nu(( Strin, #or"at o+ the data too(ti&.
ho'!oint6abe( +a(e 1oo(ean Di&(ay data in(ine in &(ot.
$ate&oryA-is
org.primefaces.model.chart.CategoryA$is e0tend org.primefaces.model.chart.A$is
*ate,oryA0i i ued 'hen data on the a0i doe not conit o+ nu"ber.
$hartModel
org.primefaces.model.chart.Chart-odel
Property Default Type Description
tit(e nu(( Strin, 9it(e te0t +or the &(ot
hado' true 1oo(ean 9o ho' hado' or not on erie.
erie*o(or nu(( Strin, *o""a e&arated (it o+ erie co(or e.,. IX-11%*5IE
I*****I
(e,end!oition nu(( Strin, !oition o+ the (e,end (i3e InI or IneI.
(e,end*o( 0 Inte,er 8a0i"u" nu"ber o+ co(u"n in the (e,end.
(e,endRo' 0 Inte,er 8a0i"u" nu"ber o+ ro' in the (e,end.
"oueover.i,h(i,ht true 1oo(ean .i,h(i,ht erie on hover.
e0tender nu(( Strin, <a"e o+ /avacri&t +unction to e0tend chart 'ith.
$hartSeries
org.primefaces.model.chart.ChartSeries
Property Default Type Description
(abe( nu(( Strin, 9it(e te0t o+ the erie.
90
PrimeFaces Users Guide
Property Default Type Description
data nu(( 8a&S7b/ectE<u"berT Data o+ the erie a a "a&.
0a0i nu(( A0i9y&e FBA0i o+ the erie.
ya0i nu(( A0i9y&e MBA0i o+ the erie.
DateA-is
org.primefaces.model.chart.'ateA$is e0tend org.primefaces.model.chart.A$is
DateA0i i ued 'hen data on the a0i conit o+ trin, re&reentation o+ date va(ue.
Donut$hartModel
org.primefaces.model.chart.'onutChart-odel e0tend org.primefaces.model.chart.Chart-odel
Property Default Type Description
data nu(( 6itT8a&SStrin,E7b/ectTT Data a a (it o+ "a& intance.
(ice8ar,in 0 Inte,er An,u(ar &acin, bet'een &ie (ice in de,ree.
+i(( true 1oo(ean 9rue or #a(e to +i(( the (ice.
ho'Data6abe( +a(e 1oo(ean 9rue to #a(e ho' data (abe( on (ice.
data#or"at &ercent Strin, Either Y(abe(ZE Yva(ueZE Y&ercentZ or an array o+
(abe( to &(ace on the &ie (ice.
(ori9ontal.ar$hartModel
org.primefaces.model.chart..ori/ontal)arChart-odel e0tend
org.primefaces.model.chart.)arChart-odel
.ori=onta(1ar*hart8ode( i an e0tenion to 1ar*hart8ode( 'ith yBa0i ued +or the cate,orie and
0Ba0i +or the data va(ue.
*ine$hartSeries
org.primefaces.model.chart.&ineChartSeries e0tend org.primefaces.model.chart.ChartSeries
Property Default Type Description
"ar3erSty(e +i((ed*irc(e Strin, Sty(e o+ the "ar3erE va(id va(ue are diamondE circleE squareE
$E plusE dashE filled'iamondE filledCircleE filledSquare.
ho'6ine true 1oo(ean Whether to actua((y dra' the (ine or not.
ho'8ar3er true 1oo(ean Di&(ay "ar3e at data &oint.
+i(( +a(e 1oo(ean #i(( the area bet'een (ine.
+i((A(&ha 1 Doub(e 7&acity o+ the +i((ed area.
diab(eStac3 +a(e 1oo(ean When trueE erie data i not inc(uded in a tac3ed chart.
*inearA-is
org.primefaces.model.chart.&inearA$is e0tend org.primefaces.model.chart.A$is
6inearA0i i the A0i i"&(e"entation ued to di&(ay nu"ber.
*ine$hartModel
org.primefaces.model.chart.&ineChart-odel e0tend
org.primefaces.model.chart.CartesianChart-odel
91
PrimeFaces Users Guide
Property Default Type Description
tac3ed nu(( 6itS*hartSerieT Di&(ay erie in tac3ed +or"at.
brea37n<u(( .ah8a& 8a&SA0i9y&eEA0iT Dicontinue (ine &(ot +or nu(( va(ue.
Meter)au&e$hartModel
org.primefaces.model.chart.-eter0augeChart-odel e0tend
org.primefaces.model.chart.Chart-odel
Property Default Type Description
va(ue nu(( <u"ber >a(ue o+ the ,au,e.
interva( nu(( 6itS<u"berT 6it o+ ran,e to be dra'n around the ,au,e.
tic3 0 6itS<u"berT 6it o+ tic3 va(ue.
,au,e6abe( true Strin, 6abe( te0t o+ the ,au,e.
,au,e6abe(!oition +a(e Strin, Where to &oition the (abe(E either YinideZ or Ybotto"Z.
"in nu(( Doub(e 8ini"u" va(ue on the ,au,e.
"a0 nu(( Doub(e 8ini"u" va(ue on the ,au,e.
ho'9ic36abe( true 1oo(ean Di&(ay tic3 (abe( ne0t to tic3.
interva(7uterRadiu 25 Inte,er Radiu o+ the outer circ(e o+ the interva( rin,.
(abe(.ei,htAd/ut B%5 Inte,er <u"ber o+ !i0e( to o++et the (abe( u& ?B@ or do'n ?H@
+ro" it de+au(t &oition.
;hlc$hartModel
org.primefaces.model.chart.,hlcChart-odel e0tend org.primefaces.model.chart.Chart-odel
Property Default Type Description
data nu(( 6itS7h(c*hartSerieT Data a a (it o+ 7h(*hartSerie.
cand(eStic3 +a(e 1oo(ean Di&(ay erie a cand(etic3.
;hlc$hartSeries
org.primefaces.model.chart.,hlcChartSeries e0tend org.primefaces.model.chart.ChartSeries
Property Default Type Description
va(ue nu(( 6itS7h(c*hartSerieT Data a a (it o+ 7h(*hartSerie.
o&en nu(( Doub(e 7&en va(ue.
hi,h nu(( Doub(e .i,h va(ue.
(o' nu(( Doub(e 6o' va(ue.
c(oe nu(( Doub(e *(oe va(ue.
Pie$hartModel
org.primefaces.model.chart.PieChart-odel e0tend org.primefaces.model.chart.Chart-odel
Property Default Type Description
data nu(( 8a&SStrin,E7b/ectT Data a a 8a& intance.
dia"eter nu(( Inte,er 7uter dia"eter o+ the &ieE auto co"&uted by de+au(t
92
PrimeFaces Users Guide
Property Default Type Description
(ice8ar,in 0 Inte,er An,u(ar &acin, bet'een &ie (ice in de,ree.
+i(( true 1oo(ean 9rue or #a(e to +i(( the (ice.
ho'Data6abe( +a(e 1oo(ean 9rue to #a(e ho' data (abe( on (ice.
data#or"at &ercent Strin, Either Y(abe(ZE Yva(ueZE Y&ercentZ or an array o+ (abe(
to &(ace on the &ie (ice.
93
PrimeFaces Users Guide
#.1' $loc+
*(oc3 di&(ay erver or c(ient dateti"e (ive.
In%o
9a, cloc,
*o"&onent *(a org.primefaces.component.cloc,.#loc,
*o"&onent 9y&e org.primefaces.component.#loc,
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#loc,enderer
Renderer *(a org.primefaces.component.cloc,.#loc,enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
&attern nu(( Strin, Dateti"e +or"at.
"ode c(ient Strin, 8ode va(ueE va(id va(ue are c(ient and erver.
autoSync +a(e 1oo(ean Sync ti"e &eriodica((y in erver "ode.
yncInterva( 40000 Inte,er De+ine the ync in " interva( in autoSync ettin,.
)ettin& Started with $loc+
*(oc3 ha t'o "odeE client ?de+au(t@ and server. In i"&(e "odeE dateti"e i di&(ayed by /ut
addin, co"&onent on &a,e. 7n &a,e (oadE c(oc3 i initia(i=ed and tart runnin, baed on c(ient ti"e.
<p:cloc2 />
94
PrimeFaces Users Guide
Serer Mode
In erver "odeE c(oc3 initia(i=ed ite(+ 'ith the erver dateti"e and tart runnin, on c(ient ide.
9o "a3e ure c(ient c(oc3 and erver c(oc3 i yncedE you can enab(e autoSync o&tion that "a3e an
a/a0 ca(( to the erver &eriodica((y to re+reh the erver ti"e 'ith c(ient.
Date1ime Format
Dateti"e +or"at ued can be chan,ed uin, &attern attribute.
<p:cloc2 pattern'(44:mm:ss dd.55.yyyy( />
S+innin&
*(oc3 reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. #o((o'in, i the (it
o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBc(oc3 *ontainer e(e"ent.
95
PrimeFaces Users Guide
3.15 Collector
*o((ector i a i"&(e uti(ity to "ana,e co((ection dec(arative(y.
In%o
9a, collector
Action6itener *(a org.primefaces.component.collector.#ollector
Attributes
Name Default Type Description
va(ue nu(( 7b/ect >a(ue to be ued in co((ection o&eration
add9o nu(( /ava.uti(.*o((ection Re+erence to the *o((ection intance
re"ove#ro" nu(( /ava.uti(.*o((ection Re+erence to the *o((ection intance
uniCue true 1oo(ean When enab(edE re/ect du&(icate ite" on addition.
)ettin& started with $ollector
*o((ector reCuire a co((ection and a va(ue to 'or3 'ith. It i"&ortant to override eCua( and
hah*ode "ethod o+ the va(ue ob/ect to "a3e co((ector 'or3.
pu-lic class =oo2=ean /
private =oo2 -oo2 ' new =oo29:;
private 7ist<=oo2> -oo2s;
pu-lic reate=oo2=ean9: /
-oo2s ' new <rray7ist<=oo2>9:;
0
//getters and setters
0
<p:command=utton value'(<dd(>
<p:collector value'(./-oo2=ean.-oo20( add!o'(./-oo2=ean.-oo2s0( />
</p:command=utton>
<p:command7in2 value'(Cemove(>
<p value'(./-oo20( remove6rom'(./create=oo2=ean.-oo2s0( />
</p:command7in2>
96
PrimeFaces Users Guide
#.15 $olor Pic+er
*o(or!ic3er i an in&ut co"&onent 'ith a co(or &a(ette.
In%o
9a, colorPic,er
*o"&onent *(a org.primefaces.component.colorpic,er.#olorPic,er
*o"&onent 9y&e org.primefaces.component.#olorPic,er
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#olorPic,erenderer
Renderer *(a org.primefaces.component.colorpic,er.#olorPic,erenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent.
converter nu(( *onverterQStr
in,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired.
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
va(idation the in&ut.
97
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( >a(ue*han,e
6itener
A "ethod bindin, e0&reion that re+er to a
"ethod +or hand(in, a va(uchan,eevent.
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ode &o&u& Strin, Di&(ay "odeE va(id va(ue are &o&u& and
in(ine.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
)ettin& started with $olorPic+er
*o(or!ic3er va(ue hou(d be a he0 trin,.
pu-lic class =ean /
private 8tring color;
pu-lic 8tring getolor9: /
return this.color;
0
pu-lic void setolor98tring color: /
this.color ' color;
0
0
<p:color#ic2er value'(./-ean.color0( />
Display Mode
*o(or!ic3er ha t'o "odeE de+au(t "ode i popup and other avai(ab(e o&tion i inline.
<p:color#ic2er value'(./-ean.color0( mode'(inline(/>
98
PrimeFaces Users Guide
S+innin&
*o(or!ic3er reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBco(or&ic3er *ontainer e(e"ent.
.uiBco(or&ic3erLco(or 1ac3,round o+ ,radient.
.uiBco(or&ic3erLhue .ue e(e"ent.
.uiBco(or&ic3erLne'Lco(or <e' co(or di&(ay.
.uiBco(or&ic3erLcurrentLco(or *urrent co(or di&(ay.
.uiBco(or&ic3erBr,bBr Red in&ut.
.uiBco(or&ic3erBr,bB, Greed in&ut.
.uiBco(or&ic3erBr,bBb 1(ue in&ut.
.uiBco(or&ic3erBr,bBh .ue in&ut.
.uiBco(or&ic3erBr,bB Saturation in&ut.
.uiBco(or&ic3erBr,bBb 1ri,htne in&ut.
.uiBco(or&ic3erBr,bBhe0 .e0 in&ut.
99
PrimeFaces Users Guide
#.16 $olumn
*o(u"n i an e0tended verion o+ the tandard co(u"n ued by variou co"&onent (i3e datatab(eE
treetab(e and "ore.
In%o
9a, column
*o"&onent *(a org.primefaces.component.column.#olumn
*o"&onent 9y&e org.primefaces.component.#olumn
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the co(u"n.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co(u"n.
ort1y nu(( >a(ueE0&r >a(ueE0&reion to be ued +or ortin,.
ort#unction nu(( 8ethodE0&r *uto" &(u,,ab(e ort#unction.
+i(ter1y nu(( >a(ueE0&r >a(ueE0&reion to be ued +or +i(terin,.
+i(terSty(e nu(( Strin, In(ine ty(e o+ the +i(ter e(e"ent
+i(terSty(e*(a nu(( Strin, Sty(e c(a o+ the +i(ter e(e"ent
+i(ter7&tion nu(( 7b/ect A co((ection o+ e(ectite" +or +i(ter dro&do'n.
+i(ter8atch8ode tartWith Strin, 8atch "ode +or +i(terin,.
ro'&an 1 Inte,er De+ine the nu"ber o+ ro' the co(u"n &an.
co(&an 1 Inte,er De+ine the nu"ber o+ co(u"n the co(u"n &an.
header9e0t nu(( Strin, Shortcut +or header +acet.
+ooter9e0t nu(( Strin, Shortcut +or +ooter +acet.
e(ection8ode nu(( Strin, Enab(e e(ection "ode.
diab(edSe(ection +a(e 1oo(ean Diab(e ro' e(ection.
100
PrimeFaces Users Guide
Name Default Type Description
+i(ter8a06en,th nu(( Inte,er 8a0i"u" nu"ber o+ character +or an in&ut +i(ter.
rei=ab(e true 1oo(ean S&eci+ie rei=ab(e +eature at co(u"n (eve(. Datatab(eO
rei=ab(e*o(u"n "ut be enab(ed to ue thi o&tion.
'idth nu(( Strin, Width in &i0e( or &ercenta,e.
e0&ortab(e true 1oo(ean De+ine i+ the co(u"n hou(d be e0&orted by
datae0&orter.
+i(ter>a(ue nu(( 7b/ect >a(ue o+ the +i(ter +ie(d.
to,,(eab(e true 1oo(ean De+ine i+ &ane( i to,,(eab(e by co(u"n9o,,(er
co"&onent. De+au(t va(ue i true and a +a(e va(ue "ar3
the co(u"n a tatic.
+i(ter#unction nu(( 8ethodE0&r *uto" i"&(e"entation to +i(ter a va(ue a,aint a
contraint.
+ie(d nu(( Strin, <a"e o+ the +ie(d to &a (a=y (oad "ethod +or +i(terin,
and ortin,. I+ not &eci+iedE +i(ter1yBort1y va(ue are
ued to identi+y the +ie(d na"e.
)ettin& Started with $olumn
A co(u"n i a reued co"&onentE ee docu"entation o+ co"&onent that ue a co(u"n.
0ote
<ot a(( attribute o+ co(u"n are i"&(e"ented by the co"&onent that uti(i=e co(u"n.
101
PrimeFaces Users Guide
#.17 $olumns
*o(u"n i ued by datatab(e to create co(u"n dyna"ica((y.
In%o
9a, columns
*o"&onent *(a org.primefaces.component.column.#olumns
*o"&onent 9y&e org.primefaces.component.#olumns
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect Data to re&reent co(u"n.
var nu(( Strin, <a"e o+ iterator to acce a co(u"n.
ty(e nu(( Strin, In(ine ty(e o+ the co(u"n.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co(u"n.
ort1y nu(( >a(ueE0&r >a(ueE0&reion to be ued +or ortin,.
ort#unction nu(( 8ethodE0&r *uto" &(u,,ab(e ort#unction.
+i(ter1y nu(( >a(ueE0&r >a(ueE0&reion to be ued +or +i(terin,.
+i(terSty(e nu(( Strin, In(ine ty(e o+ the +i(ter e(e"ent
+i(terSty(e*(a nu(( Strin, Sty(e c(a o+ the +i(ter e(e"ent
+i(ter7&tion nu(( 7b/ect A co((ection o+ e(ectite" +or +i(ter dro&do'n.
+i(ter8atch8ode tartWith Strin, 8atch "ode +or +i(terin,.
ro'&an 1 Inte,er De+ine the nu"ber o+ ro' the co(u"n &an.
co(&an 1 Inte,er De+ine the nu"ber o+ co(u"n the co(u"n &an.
header9e0t nu(( Strin, Shortcut +or header +acet.
102
PrimeFaces Users Guide
Name Default Type Description
+ooter9e0t nu(( Strin, Shortcut +or +ooter +acet.
+i(ter8a06en,th nu(( Inte,er 8a0i"u" nu"ber o+ character +or an in&ut +i(ter.
rei=ab(e true 1oo(ean S&eci+ie rei=ab(e +eature at co(u"n (eve(. Datatab(eO
rei=ab(e*o(u"n "ut be enab(ed to ue thi o&tion.
'idth nu(( Strin, Width in &i0e( or &ercenta,e.
e0&ortab(e true 1oo(ean De+ine i+ the co(u"n hou(d be e0&orted by
datae0&orter.
co(u"nInde0>ar nu(( Strin, <a"e o+ iterator to re+er each inde0.
+i(ter>a(ue nu(( 7b/ect >a(ue o+ the +i(ter +ie(d.
to,,(eab(e true 1oo(ean De+ine i+ &ane( i to,,(eab(e by co(u"n9o,,(er
co"&onent. De+au(t va(ue i true and a +a(e va(ue "ar3
the co(u"n a tatic.
+i(ter#unction nu(( 8ethodE0&r *uto" i"&(e"entation to +i(ter a va(ue a,aint a
contraint.
+ie(d nu(( Strin, <a"e o+ the +ie(d to &a (a=y (oad "ethod +or +i(terin,
and ortin,. I+ not &eci+iedE +i(ter1yBort1y va(ue are
ued to identi+y the +ie(d na"e.
)ettin& Started with $olumns
See dyna"ic co(u"n ection in datatab(e docu"entation +or detai(ed in+or"ation.
103
PrimeFaces Users Guide
#.18 $olumn)roup
*o(u"nGrou& i ued by datatab(e +or co(u"n ,rou&in,.
In%o
9a, column/roup
*o"&onent *(a org.primefaces.component.columngroup.#olumn/roup
*o"&onent 9y&e org.primefaces.component. #olumn/roup
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty&e nu(( Strin, 9y&e o+ ,rou&E va(id va(ue are header and +ooter.
)ettin& Started with $olumn)roup
See ,rou&in, ection in datatab(e docu"entation +or detai(ed in+or"ation.
104
PrimeFaces Users Guide
#.2: $ommand.utton
*o""and1utton i an e0tended verion o+ tandard co""and1utton 'ith a/a0 and the"in,.
In%o
9a, command%utton
*o"&onent *(a org.primefaces.component.command&utton.#ommand%utton
*o"&onent 9y&e org.primefaces.component.#ommand%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#ommand%uttonenderer
Renderer *(a org.primefaces.component.command&utton.#ommand%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
va(ue nu(( Strin, 6abe( +or the button
action nu(( 8ethodE0&rQ
Strin,
A "ethod e0&reion or a Strin, outco"e thatd be
&roceed 'hen button i c(ic3ed.
action6itener nu(( 8ethodE0&r An action(itener thatd be &roceed 'hen button i
c(ic3ed.
i""ediate +a(e 1oo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen
+a(e at invo3eLa&&(ication &hae.
ty&e ub"it Strin, Set the behavior o+ the button.
a/a0 true 1oo(ean S&eci+ie the ub"it "odeE 'hen et to true?de+au(t@E
ub"it 'ou(d be "ade 'ith A/a0.
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent?@ to &roce &artia((y intead o+ 'ho(e vie'.
u&date nu(( Strin, *o"&onent?@ to be u&dated 'ith a/a0.
105
PrimeFaces Users Guide
Name Default Type Description
ontart nu(( Strin, *(ient ide ca((bac3 to e0ecute be+ore a/a0 reCuet i
be,in.
onco"&(ete nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet i
co"&(eted.
onucce nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet
ucceed.
onerror nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet +ai(.
,(oba( true 1oo(ean De+ine 'hether to tri,,er a/a0Statu or not.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or i+
the va(ue o+ delay i the (itera( trin, OnoneO 'ithout the
CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not be
u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue i
+a(eE no uch indication i "ade.
ty(e nu(( Strin, In(ine ty(e o+ the button e(e"ent.
ty(e*(a nu(( Strin, Sty(e*(a o+ the button e(e"ent.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu
and it va(ue ha been "odi+ied ince ,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i doub(e
c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button receive
+ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed
do'n over button.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed and
re(eaed over button.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i re(eaed
over button.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
&reed do'n over button.
106
PrimeFaces Users Guide
Name Default Type Description
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved 'ithin button.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved a'ay +ro" button.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved onto button.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
re(eaed over button.
one(ect nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen te0t 'ithin button i
e(ected by uer.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the
button.
a(t nu(( Strin, A(ternate te0tua( decri&tion o+ the button.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
diab(ed +a(e 1oo(ean Diab(e the button.
i"a,e nu(( Strin, Sty(e c(a +or the button icon. ?de&recatedN ue icon@
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated
"ar3u& +or thi co"&onent.
tabinde0 nu(( Inte,er !oition o+ the button e(e"ent in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"ation.
readon(y +a(e 1oo(ean #(a, indicatin, that thi co"&onent 'i(( &revent chan,e
by the uer.
icon nu(( Strin, Icon o+ the button a a c c(a.
icon!o (e+t Strin, !oition o+ the icon.
in(ine +a(e Strin, Ued by !ri"e#ace "obi(e on(y.
eca&e true 1oo(ean De+ine 'hether (abe( 'ou(d be eca&ed or not.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
)ettin& started with $ommand.utton
*o""and1utton ua,e i i"i(ar to tandard co""and1uttonE by de+au(t co""and1utton ub"it
it enc(oin, +or" 'ith a/a0.
107
PrimeFaces Users Guide
<p:command=utton value'(8ave( action7istener'(./-oo2=ean.save=oo20( />
pu-lic class =oo2=ean /
pu-lic void save=oo29: /
//8ave -oo2
0
0
"eset .uttons
Reet button do not ub"it the +or"E /ut reet the +or" content.
<p:command=utton type'(reset( value'(Ceset( />
Push .uttons
!uh button are ued to e0ecute cuto" /avacri&t 'ithout cauin, an a/a0QnonBa/a0 reCuet. 9o
create a &uh button et ty&e a IbuttonI.
<p:command=utton type'(-utton( value'(<lert( onclic2'(alert9!#rime:( />
A!A= and 0on>A!A=
*o""and1utton ha bui(tBin a/a0 ca&abi(itieE a/a0 ub"it i enab(ed by de+au(t and con+i,ured
uin, a#a$ attribute. When a/a0 attribute i et to +a(eE +or" i ub"itted 'ith a re,u(ar +u(( &a,e
re+reh.
9he update attribute i ued to &artia((y u&date other co"&onent?@ a+ter the a/a0 re&one i
received. U&date attribute ta3e a co""a or 'hiteB&ace e&arated (it o+ AS# co"&onent id to be
u&dated. 1aica((y any AS# co"&onentE not /ut !ri"e#ace co"&onent hou(d be u&dated 'ith the
A/a0 re&one. In the +o((o'in, e0a"&(eE +or" i ub"itted 'ith a/a0 and display out&ut9e0t i
u&dated 'ith the a/a0 re&one.
<h:form>
<h:input!e&t value'(./-ean.te&t0( />
<p:command=utton value'(8u-mit( update'(display(/>
<h:output!e&t value'(./-ean.te&t0( id'(display( />
</h:form>
!ip: "ou can use the a,a&8tatus component to notify users a-out the a,a& reBuest.
108
PrimeFaces Users Guide
Icons
An icon on a button i &rovided uin, icon o&tion. icon!o i ued to de+ine the &oition o+ the
button 'hich can be (e+t or ri,ht.
<p:command=utton value'(1ith Icon( icon'(dis2(/>
<p:command=utton icon'(dis2(/>
.di3 i a i"&(e c c(a 'ith a bac3,round &ro&ertyK
.dis2 /
-ac2ground3image: url9!dis2.png: !important;
0
Mou can a(o ue the &reBde+ined icon +ro" 9he"eRo((er (i3e ui1icon1search.
$lient Side API
Wid,etN PrimeFaces.widget.Command)utton
!et"od Params eturn Type Description
diab(e?@ B void Diab(e button
enab(e?@ B void Enab(e button
S+innin&
*o""and1utton render a button ta, 'hich style and styleClass a&&(ie. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBbutton 1utton e(e"ent
.uiBbuttonBte0tBon(y 1utton e(e"ent 'hen icon i not ued
.uiBbuttonBte0t 6abe( o+ button
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
109
PrimeFaces Users Guide
#.21 $ommand*in+
*o""and6in3 e0tend tandard AS# co""and6in3 'ith A/a0 ca&abi(itie.
In%o
9a, command*in,
*o"&onent *(a org.primefaces.component.commandlin,.#ommand*in,
*o"&onent 9y&e org.primefaces.component.#ommand*in,
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#ommand*in,enderer
Renderer *(a org.primefaces.component. commandlin,.#ommand*in,enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( Strin, .re+ va(ue o+ the rendered anchor.
action nu(( 8ethodE0&rQ
Strin,
A "ethod e0&reion or a Strin, outco"e thatd be
&roceed 'hen (in3 i c(ic3ed.
action6itener nu(( 8ethodE0&r An action(itener thatd be &roceed 'hen (in3 i
c(ic3ed.
i""ediate +a(e 1oo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen
+a(e at invo3eLa&&(ication &hae.
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent?@ to &roce &artia((y intead o+ 'ho(e
vie'.
a/a0 true 1oo(ean S&eci+ie the ub"it "odeE 'hen et to true?de+au(t@E
ub"it 'ou(d be "ade 'ith A/a0.
u&date nu(( Strin, *o"&onent?@ to be u&dated 'ith a/a0.
ontart nu(( Strin, *(ient ide ca((bac3 to e0ecute be+ore a/a0 reCuet i
be,in.
110
PrimeFaces Users Guide
Name Default Type Description
onco"&(ete nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet i
co"&(eted.
onucce nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet
ucceed.
onerror nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet +ai(.
,(oba( true 1oo(ean De+ine 'hether to tri,,er a/a0Statu or not.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or
i+ the va(ue o+ delay i the (itera( trin, OnoneO 'ithout
the CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not
be u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue
i +a(eE no uch indication i "ade.
ty(e nu(( Strin, Sty(e to be a&&(ied on the anchor e(e"ent
ty(e*(a nu(( Strin, Sty(e*(a to be a&&(ied on the anchor e(e"ent
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (in3 (oe +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (in3 i c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (in3 i doub(e
c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (in3 receive +ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed
do'n over (in3.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed
and re(eaed over (in3.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i re(eaed
over (in3.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
&reed do'n over (in3.
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved 'ithin (in3.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved a'ay +ro" (in3.
111
PrimeFaces Users Guide
Name Default Type Description
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved onto (in3.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
re(eaed over (in3.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the (in3.
charet nu(( Strin, *haracter encodin, o+ the reource dei,nated by thi
hy&er(in3.
coord nu(( Strin, !oition and ha&e o+ the hot &ot on the creen +or
c(ient ue in i"a,e "a&.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
diab(ed nu(( 1oo(ean Diab(e the (in3
hre+(an, nu(( Strin, 6an,uae code o+ the reource dei,nated by the (in3.
re( nu(( Strin, Re(ationhi& +ro" the current docu"ent to the anchor
&eci+ied by the (in3E va(ue are &rovided by a &aceB
e&arated (it o+ (in3 ty&e.
rev nu(( Strin, A revere (in3 +ro" the anchor &eci+ied by thi (in3 to
the current docu"entE va(ue are &rovided by a &aceB
e&arated (it o+ (in3 ty&e.
ha&e nu(( Strin, Sha&e o+ hot &ot on the creenE va(id va(ue are de+au(tE
rectE circ(e and &o(y.
tabinde0 nu(( Inte,er !oition o+ the button e(e"ent in the tabbin, order.
tar,et nu(( Strin, <a"e o+ a +ra"e 'here the reource tar,eted by thi
(in3 'i(( be di&(ayed.
tit(e nu(( Strin, Adviory too(ti& in+or"ation.
ty&e nu(( Strin, 9y&e o+ reource re+erenced by the (in3.
)ettin& Started with $ommand*in+
*o""and6in3 i ued /ut (i3e the tandard hNco""and6in3E di++erence i +or" i ub"itted 'ith
a/a0 by de+au(t.
pu-lic class =oo2=ean /
pu-lic void save=oo29: /
//8ave -oo2
0
0
112
PrimeFaces Users Guide
<p:command7in2 action7istener'(./-oo2=ean.save=oo20(>
<h:output!e&t value'(8ave( />
</p:command7in2>
S+innin&
*o""and6in3 render an ht"( anchor e(e"ent that style and styleClass attribute a&&(y.
113
PrimeFaces Users Guide
#.22 $on%irm
*on+ir" i a behavior e(e"ent ued to inte,rate 'ith ,(oba( con+ir" dia(o,.
In%o
9a, confirm
1ehavior Id org.primefaces.&e"avior.#onfirm%e"avior
Attributes
Name Default Type Description
header nu(( Strin, .eader o+ con+ir" dia(o,.
"ea,e nu(( Strin, 8ea,e to di&(ay in con+ir" dia(o,.
icon nu(( Strin, Icon to di&(ay ne0t to "ea,e.
)ettin& started with $on%irm
See ,(oba( con+ir" dia(o, to&ic in ne0t ection +or detai(.
114
PrimeFaces Users Guide
#.22 $on%irmDialo&
*on+ir"Dia(o, i a re&(ace"ent to the (e,acy /avacri&t con+ir"ation bo0. S3innin,E cuto"i=ation
and avoidin, &o&u& b(oc3er are notab(e advanta,e over c(aic /avacri&t con+ir"ation.
In%o
9a, confirmDialog
*o"&onent *(a org.primefaces.component.confirmdialog.#onfirmDialog
*o"&onent 9y&e org.primefaces.component.#onfirmDialog
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#onfirmDialogenderer
Renderer *(a org.primefaces.component.confirmdialog.#onfirmDialogenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ea,e nu(( Strin, 9e0t to be di&(ayed in body.
header nu(( Strin, 9e0t +or the header.
everity nu(( Strin, 8ea,e everity +or the di&(ayed icon.
'idth auto Inte,er Width o+ the dia(o, in &i0e(
hei,ht auto Inte,er Width o+ the dia(o, in &i0e(
ty(e nu(( Strin, In(ine ty(e o+ the dia(o, container.
ty(e*(a nu(( Strin, Sty(e c(a o+ the dia(o, container
115
PrimeFaces Users Guide
Name Default Type Description
c(oab(e true 1oo(ean De+ine i+ c(oe icon hou(d be di&(ayed or not
a&&end9o +a(e 1oo(ean A&&end the dia(o, to the e(e"ent de+ined by the ,iven
earch e0&reion.
viib(e +a(e 1oo(ean Whether to di&(ay con+ir" dia(o, on (oad.
ho'E++ect nu(( Strin, E++ect to ue on ho'in, dia(o,.
hideE++ect nu(( Strin, E++ect to ue on hidin, dia(o,.
c(oe7nEca&e +a(e 1oo(ean De+ine i+ dia(o, hou(d hide on eca&e 3ey.
dir (tr Strin, De+ine te0t directionE va(id va(ue are ltr and rtl.
,(oba( +a(e 1oo(ean When enab(edE con+ir"Dia(o, beco"e a hared +or other
co"&onent that reCuire con+ir"ation.
)ettin& started with $on%irmDialo&
*on+ir"Dia(o, ha t'o "odeK ,(oba( and nonB,(oba(. <onBG(oba( "ode i a("ot a"e a the
dia(o, co"&onent ued 'ith a i"&(e c(ient ide a&iE show! and hide!.
<h:form>
<p:command=utton type'(-utton( onclic2'(#69?cd?:.show9:( />
<p:confirmDialog message'(<re you sure a-out destroying the worldM(
header'(Initiating destroy process( severity'(alert(
widget@ar'(cd(>
<p:command=utton value'("es 8ure( action7istener'(./-utton=ean.destroy1orld0(
update'(messages( oncomplete'(#69?cd?:.hide9:(/>
<p:command=utton value'(Jot "et( onclic2'(#69?cd?:.hide9:;( type'(-utton( />
</p:confirmDialog>
</h:form>
Messa&e and Seerity
8ea,e can be de+ined in t'o 'ayE either via "ea,e o&tion or "ea,e +acet. 8ea,e +acet i
ue+u( i+ you need to &(ace cuto" content intead o+ i"&(e te0t. <ote that header can a(o be
de+ined uin, the header attribute or the header +acet. Severity de+ine the icon to di&(ay ne0t to
the "ea,eE de+au(t everity i alert and the other o&tion i info.
<p:confirmDialog widget@ar'(cd( header'onfirm>
<f:facet name'(message(>
<h:output!e&t value'(<re you sureM( />
</f:facet>
//content
</p:confirmDialog>
)lobal
*reatin, a con+ir"Dia(o, +or a &eci+ic action i a re&etitive ta3E to o(ve thi ,(oba( con+ir"Dia(o,
'hich i a in,(eton ha been introduced. 9ri,,er co"&onent need to have &Ncon+ir" behavior to
116
PrimeFaces Users Guide
ue the con+ir" dia(o,. *o"&onent that tri,,er the actua( co""and in dia(o, "ut have ui1confirm1
dialog1yes ty(e c(aE i"i(ar(y co"&onent to cance( the co""and "ut have ui1confirm1dialog1no.
At the "o"ent &Ncon+ir" i u&&orted by &Nco""and1utton and &Nco""and6in3.
<p:growl id'(messages( />
<p:command=utton value'(8ave( action7istener'(./-ean.save0( update'(messages(>
<p:confirm header'(onfirmation( message'(8ureM( icon'(ui3icon3alert(/>
</p:command=utton>
<p:confirmDialog glo-al'(true(>
<p:command=utton value'("es( type'(-utton( stylelass'(ui3confirmdialog3yes(
icon'(ui3icon3chec2(/>
<p:command=utton value'(Jo( type'(-utton( stylelass'(ui3confirmdialog3no(
icon'(ui3icon3close(/>
</p:confirmDialog>
$lient Side API
Wid,etN PrimeFaces.widget.Confirm'ialog
!et"od Params eturn Type Description
ho'?@ B void Di&(ay dia(o,.
hide?@ B void *(oe dia(o,.
S+innin&
*on+ir"Dia(o, reide in a "ain container e(e"ent 'hich style and styleClass o&tion a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBdia(o, *ontainer e(e"ent o+ dia(o,
.uiBdia(o,Btit(ebar 9it(e bar
.uiBdia(o,Btit(e .eader te0t
.uiBdia(o,Btit(ebarBc(oe *(oe icon
.uiBdia(o,Bcontent Dia(o, body
.uiBdia(o,Bbutton&ane #ooter button &ane(
117
PrimeFaces Users Guide
#.2# $ontentFlow
*ontent#(o' i a hori=onta( content ,a((ery co"&onent 'ith a (ide ani"ation.
In%o
9a, content+lo0
*o"&onent *(a org.primefaces.component.contentflo0.#ontent+lo0
*o"&onent 9y&e org.primefaces.component.#ontent+lo0
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#ontent+lo0enderer
Renderer *(a org.primefaces.component.contentflo0.#ontent+lo0enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
va(ue nu(( Strin, *o((ection o+ ite" to di&(ay.
var nu(( Strin, <a"e o+ the iterator to di&(ay an ite".
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
118
PrimeFaces Users Guide
)ettin& Started with $ontentFlow
*ontent#(o' reCuire content a chi(dren that can either be de+ined dyna"ica((y uin, iteration or
one by one. Each ite" "ut have the content ty(e c(a a&&(ied a 'e((.
Static I"a,e
<p:content6low>
<p:graphicImage value'(/images/photo*.,pg( stylelass'(content( />
<p:graphicImage value'(/images/photoA.,pg( stylelass'(content( />
<p:graphicImage value'(/images/photoA.,pg( stylelass'(content( />
</p:content6low>
Dyna"ic I"a,e
<p:content6low var'(image( value'(./-ean.images0(>
<p:graphicImage value'(/images/./image0( stylelass'(content( />
</p:content6low>
$aption
9o &reent a ca&tion a(on, 'ith an ite"E e"bed a div 'ith Ica&tionI ty(e c(a inide.
<p:content6low var'(image( value'(./-ean.images0(>
<p:graphicImage value'(./image.path0( stylelass'(content( />
<div class'(caption(>./image.title0</div>
</p:content6low>
S+innin&
*ontent#(o' reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. A 3innin,
ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBcontent+(o' *ontainer e(e"ent.
.+(o' *ontainer o+ ite" (it
.ite" Ite" container
.ca&tion *a&tion e(e"ent
119
PrimeFaces Users Guide
#.2' $onte-tMenu
*onte0t8enu &rovide an over(ay "enu di&(ayed on "oue ri,htBc(ic3 event.
In%o
9a, conte$t!enu
*o"&onent *(a org.primefaces.component.conte$tmenu.#onte$t!enu
*o"&onent 9y&e org.primefaces.component.#onte$t!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.#onte$t!enuenderer
Renderer *(a org.primefaces.component.conte$tmenu.#onte$t!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
+or nu(( Strin, Id o+ the co"&onent to attach to
ty(e nu(( Strin, Sty(e o+ the "ain container e(e"ent
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container e(e"ent
"ode( nu(( 8enu8ode( 8enu "ode( intance to create "enu &ro,ra""atica((y.
node9y&e nu(( Strin, S&eci+ic ty&e o+ tree node to attach to.
event nu(( Strin, Event to bind conte0t8enu di&(ayE de+au(t i
conte0t"enu a3a ri,ht c(ic3.
be+oreSho' nu(( Strin, *(ient ide ca((bac3 to e0ecute be+ore ho'in,.
120
PrimeFaces Users Guide
)ettin& started with $onte-tMenu
*onte0t8enu i created 'ith ub"enu and "enuite". 7&tiona( +or attribute de+ine 'hich
co"&onent the conte0t8enu i attached to. When +or i not de+inedE conte0t8enu i attached to the
&a,e "eanin,E ri,htBc(ic3 on any'here on &a,e 'i(( di&(ay the "enu.
<p:conte&t5enu>
<p:menuitem value'(8ave( action7istener'(./-ean.save0( update'(msg(/>
<p:menuitem value'(Delete( action7istener'(./-ean.delete0( a,a&'(false(/>
<p:menuitem value'(Io 4ome( url'( www.primefaces.org( target'(L-lan2(/>
</p:conte&t5enu
*onte0t8enu e0a"&(e above i attached to the 'ho(e &a,e and conit o+ three di++erent
"enuite" 'ith di++erent ue cae. #irt "enuite" tri,,er an a/a0 actionE econd one tri,,er a
nonBa/a0 action and third one i ued +or navi,ation.
Attachment
*onte0t8enu can be attached to any AS# co"&onentE thi "ean ri,ht c(ic3in, on the attached
co"&onent 'i(( di&(ay the conte0t8enu. #o((o'in, e0a"&(e de"ontrate an inte,ration bet'een
conte0t8enu and i"a,eS'itcherE conte0t8enu here i ued to navi,ate bet'een i"a,e.
<p:image8witch id'(images( widget@ar'(gallery( slideshow<uto'(false(>
<p:graphicImage value'(/images/nature*.,pg( />
<p:graphicImage value'(/images/natureA.,pg( />
<p:graphicImage value'(/images/nature).,pg( />
<p:graphicImage value'(/images/natureE.,pg( />
</p:image8witch>
<p:conte&t5enu for'(images(>
<p:menuitem value'(#revious( url'(.( onclic2'(#69?gallery?:.previous9:( />
<p:menuitem value'(Je&t( url'(.( onclic2'(#69?gallery?:.ne&t9:( />
</p:conte&t5enu>
<o' ri,htBc(ic3in, any'here on an i"a,e 'i(( di&(ay the conte0t8enu (i3eK
Data $omponents
Data co"&onent (i3e datatab(eE tree and tree9ab(e ha &ecia( inte,ration 'ith conte0t "enuE ee
the docu"entation o+ thee co"&onent +or "ore in+or"ation.
121
PrimeFaces Users Guide
Dynamic Menus
*onte0t8enu can be created &ro,ra""atica((y a 'e((E ee the dyna"ic "enu &art in "enu
co"&onent ection +or "ore in+or"ation and an e0a"&(e.
S+innin&
*onte0t8enu reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBconte0t"enu *ontainer e(e"ent o+ "enu
.uiB"enuB(it 6it container
.uiB"enuite" Each "enu ite"
.uiB"enuite"B(in3 Anchor e(e"ent in a (in3 ite"
.uiB"enuite"Bte0t 9e0t e(e"ent in an ite"
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
122
PrimeFaces Users Guide
#.23 Dashboard
Dahboard &rovide a &orta( (i3e (ayout 'ith dra,:dro& baed reorder ca&abi(itie.
In%o
9a, das"&oard
*o"&onent *(a org.primefaces.component.das"&oard.Das"&oard
*o"&onent 9y&e org.primefaces.component.Das"&oard
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Das"&oardenderer
Renderer *(a org.primefaces.component.das"&oard.Das"&oardenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et
"ode( nu(( Dahboard
8ode(
Dahboard "ode( intance re&reentin, the (ayout o+
the UI.
diab(ed +a(e 1oo(ean Diab(e reorderin, +eature.
ty(e nu(( Strin, In(ine ty(e o+ the dahboard container
ty(e*(a nu(( Strin, Sty(e c(a o+ the dahboard container
123
PrimeFaces Users Guide
)ettin& started with Dashboard
Dahboard i bac3ed by a Dahboard8ode( and conit o+ &ane( co"&onent.
<p:dash-oard model'(./-ean.model0(>
<p:panel id'(sports(>
//8ports ontent
</p:panel>
<p:panel id'(finance(>
//6inance ontent
</p:panel>
//more panels li2e lifestyleH weatherH politics...
</p:dash-oard>
Dahboard "ode( i"&(y de+ine the nu"ber o+ co(u"n and the 'id,et to be &(aced in each
co(u"n. See the end o+ thi ection +or the detai(ed Dahboard A!I.
pu-lic class =ean /
private Dash-oard5odel model;
pu-lic =ean9: /
model ' new DefaultDash-oard5odel9:;
Dash-oardolumn column* ' new DefaultDash-oardolumn9:;
Dash-oardolumn columnA ' new DefaultDash-oardolumn9:;
Dash-oardolumn column) ' new DefaultDash-oardolumn9:;
column*.add1idget9(sports(:;
column*.add1idget9(finance(:;
columnA.add1idget9(lifestyle(:;
columnA.add1idget9(weather(:;
column).add1idget9(politics(:;
model.addolumn9column*:;
model.addolumn9columnA:;
model.addolumn9column):;
0
0
State
Dahboard i a tate+u( co"&onentE 'henever a 'id,et i reordered dahboard "ode( 'i(( be
u&datedE by &eritin, the uer chan,e o you can eai(y create a tate+u( dahboard.
A,a- .ehaior /ents
reorder i the one and on(y a/a0 behavior event &rovided by dahboardE thi event i +ired 'hen
dahboard &ane( are reordered. A de+ined (itener 'i(( be invo3ed by &ain, an
org.primefaces.event.'ashboard+eorderEvent intance containin, in+or"ation about reorder.
#o((o'in, dahboard di&(ay a "ea,e about the reorder event
124
PrimeFaces Users Guide
<p:dash-oard model'(./-ean.model0(>
<p:a,a& event'reorder update'messages listener'./-ean.handleCeorder0 />
//panels
</p:dash-oard>
<p:growl id'(messages( />
pu-lic class =ean /
...
pu-lic void handleCeorder9Dash-oardCeorder$vent event: /
8tring widgetId ' event.get1idgetId9:;
int widgetInde& ' event.getItemInde&9:;
int columnInde& ' event.getolumnInde&9:;
int senderolumnInde& ' event.get8enderolumnInde&9:;
//<dd facesmessage
0
0
I+ a 'id,et i reordered in the a"e co(u"nE senderColumn*nde$ 'i(( be nu((. 9hi +ie(d i
&o&u(ated on(y 'hen a 'id,et i tran+erred to a co(u"n +ro" another co(u"n. A(o 'hen the
(itener i invo3edE dahboard ha a(ready u&dated it "ode(.
Disablin& Dashboard
I+ youd (i3e to diab(e reorderin, +eatureE et disabled o&tion to true.
<p:dash-oard disa-led'(true( ...>
//panels
</p:dash-oard>
1o&&le? $lose and ;ptions Menu
Wid,et &reented in dahboard can be c(oab(eE to,,(eab(e and have o&tion "enu a 'e((E
dahboard doent i"&(e"ent thee by ite(+ a thee +eature are a(ready &rovided by the &ane(
co"&onent. See &ane( co"&onent ection +or "ore in+or"ation.
<p:dash-oard model'(./dash-oard=ean.model0(>
<p:panel id'(sports( closa-le'(true( togglea-le'(true(>
//8ports ontent
</p:panel>
</p:dash-oard>
0ew Wid&ets
Dra,,ab(e co"&onent i ued to add ne' 'id,et to the dahboard. 9hi 'ay you can add ne'
&ane( +ro" outide o+ the dahboard.
125
PrimeFaces Users Guide
<p:dash-oard model'(./dash-oard=ean.model0( id'(-oard(>
//panels
</p:dash-oard>
<p:panel id'(newwidget( />
<p:dragga-le for'(newwidget( helper'(clone( dash-oard'(-oard( />
S+innin&
Dahboard reide in a container e(e"ent 'hich ty(e and ty(e*(a o&tion a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBdahboard *ontainer e(e"ent o+ dahboard
.uiBdahboardBco(u"n Each co(u"n in dahboard
div.uiBtateBhover !(aceho(der
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. .ere i an
e0a"&(e baed on a di++erent the"eK
1ips
I+ there i a co"&onent 'ith a &o&u& (i3e ca(endarE autoco"&(ete &(aced inide the over(ay &ane(E
&o&u& &art "i,ht e0ceed the boundarie o+ &ane( and c(ic3in, the outide hide the &ane(. 9hi i
undeirab(e o in cae (i3e thi ue over(ay!ane( 'ith
dismissable +a(e and o&tiona(
showClose*con ettin,.
328
PrimeFaces Users Guide
#.67 Panel
!ane( i a ,rou&in, co"&onent 'ith content to,,(eE c(oe and "enu inte,ration.
In%o
9a, panel
*o"&onent *(a org.primefaces.component.panel.Panel
*o"&onent 9y&e org.primefaces.component.Panel
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Panelenderer
Renderer *(a org.primefaces.component.panel.Panelenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
header nu(( Strin, .eader te0t
+ooter nu(( Strin, #ooter te0t
to,,(eab(e +a(e 1oo(ean 8a3e &ane( to,,(eab(e.
to,,(eS&eed 1000 Inte,er S&eed o+ to,,(in, in "i((iecond
co((a&ed +a(e 1oo(ean Render a to,,(eab(e &ane( a co((a&ed.
ty(e nu(( Strin, Sty(e o+ the &ane(
ty(e*(a nu(( Strin, Sty(e c(a o+ the &ane(
329
PrimeFaces Users Guide
Name Default Type Description
c(oab(e +a(e 1oo(ean 8a3e &ane( c(oab(e.
c(oeS&eed 1000 Inte,er S&eed o+ c(oin, e++ect in "i((iecond
viib(e true 1oo(ean Render &ane( a viib(e.
c(oe9it(e nu(( Strin, 9oo(ti& +or the c(oe button.
to,,(e9it(e nu(( Strin, 9oo(ti& +or the to,,(e button.
"enu9it(e nu(( Strin, 9oo(ti& +or the "enu button.
to,,(e7rientation vertica( Strin, De+ine the orientation o+ the to,,(in,E va(id
va(ue are vertica( and hori=onta(.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et
)ettin& started with Panel
!ane( enca&u(ate other co"&onent.
<p:panel>
//hild components here...
</p:panel>
(eader and Footer
.eader and #ooter te0t can be &rovided by header and footer attribute or the corre&ondin, +acet.
When a"e attribute and +acet na"e are uedE +acet 'i(( be ued.
<p:panel header'(4eader !e&t(>
<f:facet name'(footer(>
<h:output!e&t value'(6ooter !e&t( />
</f:facet>
//hild components here...
</p:panel>
A,a- .ehaior /ents
!ane( &rovide cuto" a/a0 behavior event +or to,,(in, and c(oin, +eature.
'vent *istener Parameter +ired
to,,(e or,.&ri"e+ace.event.9o,,(eEvent When &ane( i e0&anded or co((a&ed.
c(oe or,.&ri"e+ace.event.*(oeEvent When &ane( i c(oed.
330
PrimeFaces Users Guide
Popup Menu
!ane( ha bui(tBin u&&ort to di&(ay a +u((y cuto"i=ab(e &o&u& "enuE an icon to di&(ay the "enu
i &(aced at to&Bri,ht corner. 9hi +eature i enab(ed by de+inin, a "enu co"&onent and de+inin, it
a the o&tion +acet.
<p:panel closa-le'(true(>
//hild components here...
<f:facet name'(options(>
<p:menu>
//5enuitems
</p:menu>
</f:facet>
</p:panel>
$ustom Action
I+ youd (i3e to add cuto" action to &ane( tit(ebarE ue action +acet 'ith icon "ar3u&K
<p:panel>
<f:facet name'(actions(>
<h:command7in2 stylelass'(ui3panel3title-ar3icon
ui3corner3all ui3state3default(>
<h:output!e&t stylelass'(ui3icon ui3icon3help( />
</h:command7in2>
</f:facet>
//content
</p:panel>
S+innin& Panel
!ane( reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&ane( 8ain container e(e"ent o+ &ane(
.uiB&ane(Btit(ebar .eader container
.uiB&ane(Btit(e .eader te0t
.uiB&ane(Btit(ebarBicon 7&tion icon in header
.uiB&ane(Bcontent !ane( content
.uiB&ane(B+ooter !ane( +ooter
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
331
PrimeFaces Users Guide
#.68 Panel)rid
!ane(Grid i an e0tenion to the tandard &ane(Grid co"&onent 'ith additiona( +eature uch a
the"in, and co(&anBro'&an.
In%o
9a, panel/rid
*o"&onent *(a org.primefaces.component.panelgrid.Panel/ridenderer
*o"&onent 9y&e org.primefaces.component.Panel/rid
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Panel/ridenderer
Renderer *(a org.primefaces.component.panelgrid.Panel/ridenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
co(u"n +a(e Inte,er <u"ber o+ co(u"n in ,rid.
332
PrimeFaces Users Guide
Name Default Type Description
ty(e nu(( Strin, In(ine ty(e o+ the &ane(.
ty(e*(a nu(( Strin, Sty(e c(a o+ the &ane(.
co(u"n*(ae nu(( Strin, *o""a e&arated (it o+ co(u"n ty(e c(ae.
)ettin& started with Panel)rid
1aic ua,e o+ &ane(Grid i a"e a the tandard one.
<p:panelIrid columns'(A(>
<h:output7a-el for'(firstname( value'(6irstname:( />
<p:input!e&t id'(firstname( value'(./-ean.firstname0( la-el'(6irstname( />
<h:output7a-el for'(surname( value'(8urname:( />
<p:input!e&t id'(surname( value'(./-ean.surname0( la-el'(8urname(/>
</p:panelIrid>
(eader and Footer
!ane(Grid &rovide +acet +or header and +ooter content.
<p:panelIrid columns'(A(>
<f:facet name'(header(>
=asic #anelIrid
</f:facet>
<h:output7a-el for'(firstname( value'(6irstname: W( />
<p:input!e&t id'(firstname( value'(./-ean.firstname0( la-el'(6irstname( />
<h:output7a-el for'(surname( value'(8urname: W( />
<p:input!e&t id'(surname( value'(./-ean.surname0( la-el'(8urname(/>
<f:facet name'(footer(>
<p:command=utton type'(-utton( value'(8ave( icon'(ui3icon3chec2( />
</f:facet>
</p:panelIrid>
"owspan and $olspan
!ane(Grid u&&ort ro'&an and co(&an o&tion a 'e((E in thi cae ro' and co(u"n "ar3u&
hou(d be de+ined "anua((y.
333
PrimeFaces Users Guide
<p:panelIrid>
<p:row>
<p:column rowspan'()(><<<</p:column>
<p:column colspan'(E(>===</p:column>
</p:row>
<p:row>
<p:column colspan'(A(></p:column>
<p:column colspan'(A(>DDD</p:column>
</p:row>
<p:row>
<p:column>$$$</p:column>
<p:column>666</p:column>
<p:column>III</p:column>
<p:column>444</p:column>
</p:row>
</p:panelIrid>
S+innin&
!ane(Grid reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&ane(,rid 8ain container e(e"ent o+ &ane(Grid.
.uiB&ane(,ridBheader .eader.
.uiB&ane(,ridB+ooter #ooter.
.uiB&ane(,ridBeven Even nu"bered ro'.
.uiB&ane(,ridBodd 7dd nu"bered ro'.
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
334
PrimeFaces Users Guide
#.7: PanelMenu
!ane(8enu i a hybrid co"&onent o+ accordion!ane( and tree co"&onent.
In%o
9a, panel!enu
*o"&onent *(a org.primefaces.component.panelmenu.Panel!enu
*o"&onent 9y&e org.primefaces.component.Panel!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Panel!enuenderer
Renderer *(a org.primefaces.component.panelmenu.Panel!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
"ode( nu(( 8enu8ode( 8enu8ode( intance to bui(d "enu dyna"ica((y.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
335
PrimeFaces Users Guide
)ettin& started with PanelMenu
!ane(8enu conit o+ ub"enu and "enuite". #irt (eve( o+ ub"enu are rendered a accordion
&ane( and decendant ub"enu are rendered a tree node. Aut (i3e in any other "enu co"&onentE
"enuite" can be uti(i=ed to do a/a0 reCuetE nonBa/a0 reCuet and i"&(e GE9 navi,ation.
<p:panel5enu style'(width:A00p&(>
<p:su-menu la-el'(<,a& 5enuitems(>
<p:menuitem value'(8ave( action7istener'(./-utton=ean.save0( />
<p:menuitem value'(Kpdate( action7istener'(./-utton=ean.update0( />
</p:su-menu>
<p:su-menu la-el'(Jon3<,a& 5enuitem(>
<p:menuitem value'(Delete( action7istener'(./-utton=ean.delete0(
a,a&'(false(/>
</p:su-menu>
<p:su-menu la-el'(Javigations( >
<p:su-menu la-el'(7in2s( icon'(ui3icon3e&tlin2(>
<p:su-menu la-el'(#rime6aces( icon'(ui3icon3heart(>
<p:menuitem value'(4ome( url'(http://www.primefaces.org( />
<p:menuitem value'(Docs( url'(http://www.primefaces.org/...( />
<p:menuitem value'(8upport( url'(http://www.primefaces.org/...( />
</p:su-menu>
</p:su-menu>
<p:menuitem value'(5o-ile( outcome'(/mo-ile/inde&( />
</p:su-menu>
</p:panel5enu>
S+innin&
!ane(8enu reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&ane("enu 8ain container e(e"ent.
.uiB&ane("enuBheader .eader o+ a &ane(.
.uiB&ane("enuBcontent #ooter o+ a &ane(.
.uiB&ane("enu .uiB"enuB(it 9ree container.
.uiB&ane("enu .uiB"enuite" A "enuite" in tree.
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
336
PrimeFaces Users Guide
#.71 Password
Password component is an extended version of standard inputSecret component with theme
integration and strength indicator.
In%o
9a, pass0ord
*o"&onent *(a org.primefaces.component.pass0ord.Pass0ord
*o"&onent 9y&e org.primefaces.component.Pass0ord
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Pass0ordenderer
Renderer *(a org.primefaces.component.pass0ord.Pass0ordenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverter
QStrin,
An e( e0&reion or a (itera( te0t that de+ine a converter
+or the co"&onent. When it an E6 e0&reionE it
reo(ved to a converter intance. In cae it a tatic te0tE it
"ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e boo(ean 8ar3 co"&onent a reCuired
337
PrimeFaces Users Guide
Name Default Type Description
va(idator nu(( 8ethod
E0&r
A "ethod e0&reion that re+er to a "ethod va(idation,
the in&ut.
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
+eedbac3 +a(e 1oo(ean Enab(e tren,th indicator.
in(ine +a(e boo(ean Di&(ay +eedbac3 in(ine rather than uin, a &o&u&.
&ro"&t6abe( !(eae
enter a
&a'ord
Strin, 6abe( o+ &ro"&t.
(eve( 1 Inte,er 6eve( o+ ecurity.
'ea36abe( Wea3 Strin, 6abe( o+ 'ea3 &a'ord.
,ood6abe( Good Strin, 6abe( o+ ,ood &a'ord.
tron,6abe( Stron, Strin, 6abe( o+ tron, &a'ord.
redi&(ay +a(e 1oo(ean Whether or not to di&(ay &reviou va(ue.
"atch nu(( Strin, Id o+ another &a'ord co"&onent to "atch va(ue a,aint.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the in&ut
e(e"ent.
a(t nu(( Strin, A(ternate te0tua( decri&tion o+ the in&ut +ie(d.
autoco"&(ete nu(( Strin, *ontro( bro'er autoco"&(ete behavior.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
diab(ed +a(e 1oo(ean Diab(e in&ut +ie(d
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated
"ar3u& +or thi co"&onent.
"a0(en,th nu(( Inte,er 8a0i"u" nu"ber o+ character that "ay be entered in
thi +ie(d.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent (oe
+ocu.
338
PrimeFaces Users Guide
Name Default Type Description
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent (oe
+ocu and it va(ue ha been "odi+ied ince ,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent i
c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent i
doub(e c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
receive +ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed
do'n over in&ut e(e"ent.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed and
re(eaed over in&ut e(e"ent.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i re(eaed
over in&ut e(e"ent.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
&reed do'n over in&ut e(e"ent
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved 'ithin in&ut e(e"ent.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved a'ay +ro" in&ut e(e"ent.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved onto in&ut e(e"ent.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
re(eaed over in&ut e(e"ent.
one(ect nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen te0t 'ithin in&ut
e(e"ent i e(ected by uer.
&(aceho(der nu(( Strin, S&eci+ie a hort hint.
readon(y +a(e 1oo(ean #(a, indicatin, that thi co"&onent 'i(( &revent chan,e
by the uer.
i=e nu(( Inte,er <u"ber o+ character ued to deter"ine the 'idth o+ the
in&ut e(e"ent.
ty(e nu(( Strin, In(ine ty(e o+ the in&ut e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the in&ut e(e"ent.
tabinde0 nu(( Inte,er !oition o+ the in&ut e(e"ent in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
339
PrimeFaces Users Guide
)ettin& Started with Password
!a'ord i an in&ut co"&onent and ued /ut (i3e a tandard in&ut te0t. When feedbac" o&tion i
enab(ed a &a'ord tren,th indicator i di&(ayed.
<p:password value'(./-ean.password0( feed-ac2'(true[false( />
pu-lic class =ean /
private 8tring password;
pu-lic 8tring get#assword9: / return password; 0
pu-lic void set#assword98tring password: / this.password ' password;0
0
I170
A(thou,h a(( (abe( are in En,(ih by de+au(tE you can &rovide cuto" (abe( a 'e((. #o((o'in,
&a'ord ,ive +eedbac3 in 9ur3ih.
<p:password value'(./-ean.password0( prompt7a-el'(7"tfen #ifre giriniO(
wea27a-el'(Xay$f( good7a-el'(Orta seviye( strong7a-el'(I"%l"( feed-ac2' (true(/>
Inline Stren&th Indicator
1y de+au(t tren,th indicator i ho'n in an over(ayE i+ you &re+er an in(ine indicator /ut enab(e
in(ine "ode.
<p:password value'(./my-ean.password0( inline'(true( feed-ac2' (true(/>
$on%irmation
!a'ord con+ir"ation i a co""on cae and &a'ord &rovide an eay 'ay to i"&(e"ent. 9he
other &a'ord co"&onent id hou(d be ued to de+ine the match o&tion.
<p:password id'(pwd*( value'(./password=ean.passwordU0( feed-ac2'(false(
match'(pwdA( la-el'(#assword *( reBuired'(true(/>
<p:password id'(pwdA( value'(./password=ean.passwordU0( feed-ac2'(false(
la-el'(#assword A( reBuired'(true(/>
S+innin&
Structura( e(ector +or &a'ord areK
Name Applies
.uiB&a'ord In&ut e(e"ent.
.uiB&a'ordB&ane( 7ver(ay &ane( o+ tren,th indicator.
.uiB&a'ordB"eter Stren,th "eter.
340
PrimeFaces Users Guide
Name Applies
.uiB&a'ordBin+o Stren,th (abe(.
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
341
PrimeFaces Users Guide
#.72 Photo$am
!hoto*a" i ued to ta3e &hoto 'ith 'ebca" and end the" to the AS# bac3end "ode(.
In%o
9a, p"oto#am
*o"&onent *(a org.primefaces.component.p"otocam.P"oto#am
*o"&onent 9y&e org.primefaces.component.P"oto#am
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.P"oto#amenderer
Renderer *(a org.primefaces.component.p"otocam.P"oto#amenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered +a(e 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a converter
+or the co"&onent. When it an E6 e0&reionE it
reo(ved to a converter intance. In cae it a tatic te0tE
it "ut re+er to a converter id
i""ediate 0 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired 0 boo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
342
PrimeFaces Users Guide
Name Default Type Description
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
&roce nu(( Strin, Identi+ier o+ co"&onent to &roce durin, ca&ture.
u&date nu(( Strin, Identi+ier o+ co"&onent to u&date durin, ca&ture.
(itener nu(( 8ethod
E0&r
8ethod e0&reion to (iten to ca&ture event.
)ettin& started with Photo$am
*a&ture i tri,,ered via c(ient ide a&i capture "ethod. A(o a "ethod e0&reion i neceary to
invo3e 'hen an i"a,e i ca&tured. Sa"&(e be(o' ca&ture an i"a,e and ave it to a directory.
<h:form>
<p:photoam widget@ar'(pc( listener'(./photoam=ean.oncapture0(update'(photos(/>
<p:command=utton type'(-utton( value'(apture( onclic2'(#69?pc?:.capture9:(/>
</h:form>
pu-lic class #hotoam=ean /
pu-lic void oncapture9apture$vent capture$vent: /
-yteQS data ' capture$vent.getData9:;
8ervletonte&t servletonte&t ' 98ervletonte&t:
6acesonte&t.geturrentInstance9:.get$&ternalonte&t9:.getonte&t9:;
8tring new6ileJame ' servletonte&t.getCeal#ath9((: > 6ile.separator >
(photocam( > 6ile.separator > (captured.png(;
6ileImageOutput8tream imageOutput;
try /
imageOutput ' new 6ileImageOutput8tream9new 6ile9new6ileJame::;
imageOutput.write9dataH 0H data.length:;
imageOutput.close9:;
0
catch9$&ception e: /
throw new 6aces$&ception9($rror in writing captured image.(:;
0
0
0
0otes
G !hoto*a" i a +(ahE canva and /avacri&t o(ution.
G It i not u&&orted in IE at the "o"ent and thi 'i(( be 'or3ed on in +uture verion.
343
PrimeFaces Users Guide
#.7# Pic+*ist
!ic36it i ued +or tran+errin, data bet'een t'o di++erent co((ection.
In%o
9a, pic,*ist
*o"&onent *(a org.primefaces.component.pic,list.Panel
*o"&onent 9y&e org.primefaces.component.Pic,*ist
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Pic,*istenderer
Renderer *(a org.primefaces.component.pic,list.Pic,*istenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted
at a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a "ethod
va(idation, the in&ut
344
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a "ethod
+or hand(in, a va(uchan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
var nu(( Strin, <a"e o+ the iterator.
ite"6abe( nu(( Strin, 6abe( o+ an ite".
ite">a(ue nu(( 7b/ect >a(ue o+ an ite".
ty(e nu(( Strin, Sty(e o+ the "ain container.
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
e++ect nu(( Strin, <a"e o+ the ani"ation to di&(ay.
e++ectS&eed nu(( Strin, S&eed o+ the ani"ation.
add6abe( Add Strin, 9it(e o+ add button.
addA((6abe( Add A(( Strin, 9it(e o+ add a(( button.
re"ove6abe( Re"ove Strin, 9it(e o+ re"ove button.
re"oveA((6abe( Re"ove A(( Strin, 9it(e o+ re"ove a(( button.
"oveU&6abe( 8ove U& Strin, 9it(e o+ "ove u& button.
"ove9o&6abe( 8ove 9o& Strin, 9it(e o+ "ove to& button.
"oveDo'n6abe( 8ove Do'n Strin, 9it(e o+ "ove do'n button.
"ove1utto"6abe( 8ove
1utto"
Strin, 9it(e o+ "ove botto" button.
ho'Source*ontro( +a(e Strin, S&eci+ie viibi(ity o+ reorder button o+ ource (it.
ho'9ar,et*ontro( +a(e Strin, S&eci+ie viibi(ity o+ reorder button o+ tar,et (it.
on9ran+er nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen an ite" i
tran+erred +ro" one (it to another.
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
ite"Diab(ed +a(e 1oo(ean S&eci+ied i+ an ite" can be &ic3ed or not.
ho'Source#i(ter +a(e 1oo(ean Di&(ay and in&ut +i(ter +or ource (it.
345
PrimeFaces Users Guide
Name Default Type Description
ho'9ar,et#i(ter +a(e 1oo(ean Di&(ay and in&ut +i(ter +or tar,et (it.
+i(ter8atch8ode tartWith Strin, 8atch "ode +or +i(terin,E va(id va(ue are
tartWithE containE endWith and cuto".
+i(ter#unction nu(( Strin, <a"e o+ the /avacri&t +unction +or cuto" +i(terin,.
ho'*hec3bo0 +a(e 1oo(ean When trueE a chec3bo0 i di&(ayed ne0t to each
ite".
(abe(Di&(ay too(ti& Strin, De+ine ho' the button (abe( di&(ayedE va(id
va(ue are Itoo(ti&I ?de+au(t@ and Iin(ineI.
)ettin& started with Pic+*ist
Mou need to create cuto" "ode( ca((ed org.primefaces.model.'ual&ist-odel to ue !ic36it. A
the na"e u,,et it conit o+ t'o (itE one i the ource (it and the other i the tar,et. A the +irt
e0a"&(e 'e(( create a Dua(6it8ode( that contain baic Strin,.
pu-lic class #ic27ist=ean /
private Dual7ist5odel<8tring> cities;
pu-lic #ic27ist=ean9: /
7ist<8tring> source ' new <rray7ist<8tring>9:;
7ist<8tring> target ' new <rray7ist<8tring>9:;
cities8ource.add9(Istan-ul(:;
cities8ource.add9(<n2ara(:;
cities8ource.add9(IOmir(:;
cities8ource.add9(<ntalya(:;
cities8ource.add9(=ursa(:;
//more cities
cities ' new Dual7ist5odel<8tring>9cities8ourceH cities!arget:;
0
pu-lic Dual7ist5odel<8tring> getities9: /
return cities;
0
pu-lic void setities9Dual7ist5odel<8tring> cities: /
this.cities ' cities;
0
0
And bind the citie dua( (it to the &ic3(itK
<p:pic27ist value'(./pic27ist=ean.cities0( var'(city(
item7a-el'(./city0( item@alue'(./city0(>
346
PrimeFaces Users Guide
When the enc(oed +or" i ub"ittedE the dua( (it re+erence i &o&u(ated 'ith the ne' va(ue and
you can acce thee va(ue 'ith Dua(6it8ode(.,etSource?@ and Dua(6it8ode(.,et9ar,et?@ a&i.
P;!;s
8ot o+ the ti"e you 'ou(d dea( 'ith co"&(e0 &o/o rather than i"&(e ty&e (i3e Strin,.
9hi ue cae i no di++erent e0ce&t the addition o+ a converter. #o((o'in, &ic36it di&(ay a (it o+
&(ayer?na"eE a,e ...@.
<p:pic27ist value'(./pic27ist=ean.players0( var'(player(
item7a-el'(./player.name0( item@alue'(./player0( converter'(player(>
!(ayer*onverter in thi cae hou(d i"&(e"ent #ava$.faces.convert.Converter contract and
i"&(e"ent ,etAStrin,E ,etA7b/ect "ethod. <ote that a converter i a('ay neceary +or
&ri"itive ty&e (i3e (on,E inte,erE boo(ean a 'e((.
In addition cuto" content intead o+ i"&(e trin, can be di&(ayed by uin, co(u"n.
<p:pic27ist value'(./pic27ist=ean.players0(
var'(player( iconOnly'(true( effect'(-ounce(
item@alue'(./player0( converter'(player(
show8ourceontrols'(true( show!argetontrols'(true(>
<p:column style'(width:A5F(>
<p:graphicImage value'(/images/-arca/./player.photo0(/>
</p:column>
<p:column style'(width:P5F(;>
./player.name0 3 ./player.num-er0
</p:column>
</p:pic27ist>
"eorderin&
!ic36it u&&ort reorderin, o+ ource and tar,et (itE thee are enab(ed by showSourceControls and
showTargetControls o&tion.
/%%ects
An ani"ation i di&(ayed 'hen tran+errin, 'hen ite" to another or reorderin, a (itE de+au(t e++ect
i +ade and +o((o'in, o&tion are avai(ab(e to be a&&(ied uin, effect attributeK b(indE bounceE c(i&E
dro&E e0&(odeE +o(dE hi,h(i,htE &u++E &u(ateE ca(eE ha3eE i=e and (ide. effectSpeed attribute i ued
to cuto"i=e the ani"ation &eedE va(id va(ue are slowE normal and fast.
$aptions
*a&tion te0t +or (it are de+ined 'ith +acet na"ed sourceCaption and targetCaptionK
<p:pic27ist value'(./pic27ist=ean.cities0( var'(city(
item7a-el'(./city0( item@alue'(./city0( on!ransfer'(handle!ransfer9e:(>
<f:facet name'(sourceaption(><vaila-le</f:facet>
<f:facet name'(targetaption(>8elected</f:facet>
</p:pic27ist>
347
PrimeFaces Users Guide
Filterin&
!ic36it &rovide bui(tBin c(ient ide +i(terin,. #i(terin, i enab(ed by ettin, the corre&ondin,
+i(terin, attribute o+ a (it. #or ource (it thi i showSourceFilter and +or tar,et (it it i
showTargetFilter. De+au(t "atch "ode i tartWith and containE endWith are a(o avai(ab(e
o&tion.
When you need to a cuto" "atch "ode et filter-atch-ode to cuto" and 'rite a /avacri&t
+unction that ta3e ite"6abe( and +i(ter>a(ue a &ara"eter. Return +a(e to hide an ite" and true to
di&(ay.
<p:pic27ist value'(./pic27ist=ean.cities0( var'(city(
item7a-el'(./city0( item@alue'(./city0(
show8ource6ilter'(true( show!arget6ilter'(true(
filter5atch5ode'(custom( filter6unction'(myfilter(>
</p:pic27ist>
function myfilter9item7a-elH filter@alue: /
//return true or false
0
on1rans%er
I+ youd (i3e to e0ecute cuto" /avacri&t 'hen an ite" i tran+erredE bind your /avacri&t +unction
to onTransfer attribute.
<p:pic27ist value'(./pic27ist=ean.cities0( var'(city(
item7a-el'(./city0( item@alue'(./city0( on!ransfer'(handle!ransfer9e:(>
<script type'(te&t/,avascript(>
function handle!ransfer9e: /
//item ' e.item
//from7ist ' e.from
//to7ist ' e.to7ist
//type ' e.type 9type of transfer; commandH d-lclic2 or dragdrop:
0
</script>
A,a- .ehaior /ents
!ic36it &rovide transfer a the de+au(t and on(y a/a0 behavior event that i +ired 'hen an ite" i
"oved +ro" one (it to the other. E0a"&(e be(o' de"ontrate ho' to ue thi event.
<p:pic27ist value'(./pic27ist=ean.cities0( var'(city(
item7a-el'(./city0( item@alue'(./city0(>
<p:a,a& event'(transfer( listener'(./pic27ist=ean.handle!ransfer0( />
</p:pic27ist>
348
PrimeFaces Users Guide
pu-lic class #ic27ist=ean /
//Dual7ist5odel code
pu-lic void handle!ransfer9!ransfer$vent event: /
//event.getItems9: : 7ist of items transferred
//event.is<dd9: : Is transfer from source to target
//event.isCemove9: : Is transfer from target to source
0
0
S+innin&
!ic36it reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the (it
o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&ic3(it 8ain container e(e"ent?tab(e@ o+ &ic3(it
.uiB&ic3(itB(it 6it o+ a &ic3(it
.uiB&ic3(itB(itBource Source (it
.uiB&ic3(itB(itBtar,et 9ar,et (it
.uiB&ic3(itBourceBcontro( *ontainer e(e"ent o+ ource (it reorderin, contro(
.uiB&ic3(itBtar,etBcontro( *ontainer e(e"ent o+ tar,et (it reorderin, contro(
.uiB&ic3(itBbutton 1utton o+ a &ic3(it
.uiB&ic3(itBbuttonB"oveBu& 8ove u& button
.uiB&ic3(itBbuttonB"oveBto& 8ove to& button
.uiB&ic3(itBbuttonB"oveBdo'n 8ove do'n button
.uiB&ic3(itBbuttonB"oveBbotto" 8ove botto" button
.uiB&ic3(itBbuttonBadd Add button
.uiB&ic3(itBbuttonBaddBa(( Add a(( button
.uiB&ic3(itBbuttonBre"oveBa(( Re"ove a(( button
.uiB&ic3(itBbuttonBadd Add button
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
349
PrimeFaces Users Guide
#.7' Poll
!o(( i an a/a0 co"&onent that ha the abi(ity to end &eriodica( a/a0 reCuet.
In%o
9a, poll
*o"&onent *(a org.primefaces.component.poll.Poll
*o"&onent 9y&e org.primefaces.component.Poll
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Pollenderer
Renderer *(a org.primefaces.component.poll.Pollenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
interva( % Inte,er Interva( in econd to do &eriodic a/a0 reCuet.
u&date nu(( Strin, *o"&onent?@ to be u&dated 'ith a/a0.
(itener nu(( 8ethodE0&r A "ethod e0&reion to invo3e by &o((in,.
i""ediate +a(e 1oo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen +a(e
at invo3eLa&&(ication &hae.
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent id?@ to &roce &artia((y intead o+ 'ho(e
vie'.
ontart nu(( Strin, Aavacri&t hand(er to e0ecute be+ore a/a0 reCuet i be,in.
onco"&(ete nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet i
co"&(eted.
onucce nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet ucceed.
onerror nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet +ai(.
350
PrimeFaces Users Guide
Name Default Type Description
,(oba( true 1oo(ean G(oba( a/a0 reCuet are (itened by a/a0Statu
co"&onentE ettin, ,(oba( to +a(e 'i(( not tri,,er
a/a0Statu.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or i+
the va(ue o+ delay i the (itera( trin, OnoneO 'ithout the
CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
autoStart true 1oo(ean In autoStart "odeE &o((in, tart auto"atica((y on &a,e
(oadE to tart &o((in, on de"and et to +a(e.
to& +a(e 1oo(ean Sto& &o((in, 'hen true.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not be
u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue i
+a(eE no uch indication i "ade.
)ettin& started with Poll
!o(( be(o' invo3e incre"ent "ethod on *ounter1ean every % econd and t$t>count i u&dated
'ith the ne' va(ue o+ the count variab(e. <ote that &o(( "ut be neted inide a +or".
<h:output!e&t id'(t&tLcount( value'(./counter=ean.count0( />
<p:poll listener'(./counter=ean.increment0( update'(t&tLcount( />
pu-lic class ounter=ean /
private int count;
pu-lic void increment9: /
count>>;
0
pu-lic int getount9: /
return this.count;
0
pu-lic void setount9int count: /
this.count ' count;
0
0
351
PrimeFaces Users Guide
1unin& timin&
1y de+au(t the &eriodic interva( i % econdE thi i chan,ed 'ith the interva( attribute. #o((o'in,
&o(( 'or3 every 5 econd.
<h:output!e&t id'(t&tLcount( value'(./counter=ean.count0( />
<p:poll listener'(./counter=ean.increment0( update'(t&tLcount( interval'(5( />
Start and Stop
!o(( can be tarted and to&&ed uin, c(ient ide a&iK
<h:form>
<h:output!e&t id'(t&tLcount( value'(./counter=ean.count0( />
<p:poll interval'(5( action7istener'(./counter=ean.increment0(
update'(t&tLcount( widget@ar'(my#oll( auto8tart'(false( />
<a href'(.( onclic2'(#69?my#oll?:.start9:;(>8tart</a>
<a href'(.( onclic2'(#69?my#oll?:.stop9:;(>8top</a>
</h:form>
7r bind a boo(ean variab(e to the stop attribute and et it to +a(e at any arbitrary ti"e.
352
PrimeFaces Users Guide
#.73 Printer
!rinter a((o' endin, a &eci+ic AS# co"&onent to the &rinterE not the 'ho(e &a,e.
In%o
9a, printer
1ehavior *(a org.primefaces.component.&e"avior.Printer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
tar,et nu(( Strin, 9ar,et co"&onent to &rint.
)ettin& started with the Printer
!rinter i attached to any co""and co"&onent (i3e a button or a (in3. E0a"&(e be(o'
de"ontrate ho' to &rint a i"&(e out&ut te0t or a &articu(ar i"a,e on &a,eK
<h:command=utton id'(-tn( value'(#rint(>
<p:printer target'(output( />
</h:command=utton>
<h:output!e&t id'(output( value'(#rime6aces Coc2s!( />
<h:output7in2 id'(ln2( value'(.(>
<p:printer target'(image( />
<h:output!e&t value'(#rint Image( />
</h:output7in2>
<p:graphicImage id'(image( value'(/images/nature*.,pg( />
353
PrimeFaces Users Guide
#.75 Pro&ress.ar
!ro,re1ar i a &roce tatu indicator that can either 'or3 &ure(y on c(ient ide or interact 'ith
erver ide uin, a/a0.
In%o
9a, propress%ar
*o"&onent *(a org.primefaces.component.progress&ar.Progress%ar
*o"&onent 9y&e org.primefaces.component.Progress&ar
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Progress%arenderer
Renderer *(a org.primefaces.component.progress&ar.Progress%arenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et
va(ue 0 Inte,er >a(ue o+ the &ro,re bar
diab(ed +a(e 1oo(ean Diab(e or enab(e the &ro,rebar
a/a0 +a(e 1oo(ean S&eci+ie the "ode o+ &ro,re1arE in a/a0 "ode
&ro,re va(ue i retrieved +ro" a bac3in, bean.
interva( )000 Inte,er Interva( in econd to do &eriodic reCuet in a/a0
"ode.
354
PrimeFaces Users Guide
Name Default Type Description
ty(e nu(( Strin, In(ine ty(e o+ the "ain container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container e(e"ent.
(abe(9e"&(ate Vva(ueW Strin, 9e"&(ate o+ the &ro,re (abe(.
di&(ay7n(y +a(e 1oo(ean Enab(e tatic di&(ay "ode.
,(oba( true 1oo(ean G(oba( a/a0 reCuet are (itened by a/a0Statu
co"&onentE ettin, ,(oba( to +a(e 'i(( not tri,,er
a/a0Statu.
)ettin& started with the Pro&ress.ar
!ro,re1ar ha t'o "odeE Ic(ientI?de+au(t@ or Ia/a0I. #o((o'in, i a &ure c(ient ide &ro,re1ar.
<p:progress=ar widget@ar'(p-( />
<p:command=utton value'(8tart( type'(-utton( onclic2'(start9:( />
<p:command=utton value'(ancel( type'(-utton( onclic2'(cancel9:( />
<script type'(te&t/,avascript(>
function start9: /
this.progressInterval ' setInterval9function9:/
#69?p-?:.set@alue9#69?p-?:.get@alue9: > *0:;
0H A000:;
0
function cancel9: /
clearInterval9this.progressInterval:;
#69?p-?:.set@alue90:;
0
</script>
A,a- Pro&ress
A/a0 "ode i enab(ed by ettin, a/a0 attribute to trueE in thi cae the va(ue de+ined on a "ana,ed
bean i retrieved &eriodica((y and ued to u&date the &ro,re.
<p:progress=ar a,a&'(true( value'(./progress=ean.progress0( />
pu-lic class #rogress=ean /
private int progress;
//getter3setter
0
355
PrimeFaces Users Guide
Interal
!ro,re1ar i baed on &o((in, and )000 "i((iecond i the de+au(t interva( +or a/a0 &ro,re bar
"eanin, every ) econd &ro,re va(ue 'i(( be reca(cu(ated. In order to et a di++erent va(ueE ue
the interva( attribute.
<p:progress=ar interval'(5000( />
A,a- .ehaior /ents
!ro,re1ar &rovide complete a the de+au(t and on(y a/a0 behavior event that i +ired 'hen the
&ro,re i co"&(eted. E0a"&(e be(o' de"ontrate ho' to ue thi event.
pu-lic class #rogress=ean /
private int progress;
pu-lic void handleomplete9: /
//<dd a faces message
0
pu-lic int get#rogress9: /
return progress;
0
pu-lic void set#rogress9int progress: /
this.progress ' progress;
0
0
<p:progress=ar value'(./progress=ean.progress0( a,a&'(true(>
<p:a,a& event'(complete( listener'(./progress=ean.handleomplete0(
update'(messages( />
</p:progress=ar>
<p:growl id'(messages( />
Display ;nly
Au"e you have a &roce (i3e a tic3et &urchae that &an variou &a,e 'here each &a,e ha
di++erent ue cae uch a cuto"er in+oE eat e(ectionE bi((in,E &ay"ent and "ore. In order to
di&(ay tatic va(ue o+ the &roce on each &a,eE you can ue a tatic &ro,re1ar.
<p:progress=ar value'(50( displayOnly'(true( />
$lient Side API
Wid,etN PrimeFaces.widget.Progress)ar
!et"od Params eturn Type Description
,et>a(ue?@ B <u"ber Return current va(ue
356
PrimeFaces Users Guide
!et"od Params eturn Type Description
et>a(ue?va(ue@ va(ueN >a(ue to di&(ay void Set current va(ue
tart?@ B void Start a/a0 &ro,re bar
cance(?@ B void Sto& a/a0 &ro,re bar
S+innin&
!ro,re1ar reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&ro,rebar 8ain container.
.uiB&ro,rebarBva(ue >a(ue o+ the &ro,rebar
.uiB&ro,rebarB(abe( !ro,re (abe(.
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
357
PrimeFaces Users Guide
#.76 "adio.utton
Radio1utton i a he(&er co"&onent o+ Se(ect7neRadio to i"&(e"ent cuto" (ayout.
In%o
9a, radio%utton
*o"&onent *(a org.primefaces.component.radio&utton.adio%utton
*o"&onent 9y&e org.primefaces.component.adio%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.adio%uttonenderer
Renderer *(a org.primefaces.component.radio&utton.adio%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
diab(ed +a(e 1oo(ean Diab(ed the co"&onent.
ite"Inde0 nu(( Inte,er Inde0 o+ the e(ectIte" o+ e(ect7neRadio.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute on tate chan,e.
+or nu(( Strin, Id o+ the e(ect7neRadio to attach to.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
tabinde0 nu(( Strin, S&eci+ie the tab order o+ e(e"ent in tab navi,ation.
)ettin& started with "adio.utton
See cuto" (ayout &art in Se(ect7neRadio ection +or "ore in+or"ation.
358
PrimeFaces Users Guide
#.77 "atin&
Ratin, co"&onent +eature a tar baed ratin, yte".
In%o
9a, rating
*o"&onent *(a org.primefaces.component.rating.ating
*o"&onent 9y&e org.primefaces.component.ating
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.atingenderer
Renderer *(a org.primefaces.component.rating.atingenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate 0 1oo(ean 1oo(ean va(ue that &eci+ie the (i+ecyc(e &hae
the va(ue*han,eEvent hou(d be &roceedE
'hen true the event 'i(( be +ired at Ia&&(y reCuet
va(ueIE i+ i""ediate i et to +a(eE va(ue*han,e
Event are +ired in I&roce va(idationI
&hae
359
PrimeFaces Users Guide
Name Default Type Description
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod bindin, e0&reion that re+er to a
"ethod va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod bindin, e0&reion that re+er to a
"ethod +or hand(in, a va(uchan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
tar 5 Inte,er <u"ber o+ tar to di&(ay
diab(ed +a(e 1oo(ean Diab(e uer interaction
readon(y +a(e 1oo(ean Diab(e uer interaction 'ithout diab(ed viua(.
onRate nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen rate ha&&en.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
cance( true 1oo(ean When enab(edE di&(ay a cance( icon to reet.
)ettin& Started with "atin&
Ratin, i an in&ut co"&onent that ta3e a doub(e variab(e a it va(ue.
pu-lic class Cating=ean /
private Integer rating;
//getter3setter
0
<p:rating value'(./rating=ean.rating0( />
0umber o% Stars
De+au(t nu"ber o+ tar i 5E i+ you need (e or "ore tar ue the tar attribute. #o((o'in, ratin,
conit o+ 10 tar.
<p:rating value'(./rating=ean.rating0( stars'(*0(/>
360
PrimeFaces Users Guide
Display <alue ;nly
In cae 'here you on(y 'ant to ue the ratin, co"&onent to di&(ay the ratin, va(ue and dia((o'
uer interactionE et readonly to true. Uin, disabled attribute doe the a"e but add diab(ed
viua( ty(e.
A,a- .ehaior /ents
Ratin, &rovide rate and cancel a a/a0 behavior event. A de+ined (itener +or rate event 'i(( be
e0ecuted by &ain, an org.primefaces.event.+ateEvent a a &ara"eter and cance( event 'i(( be
invo3ed 'ith no &ara"eter.
<p:rating value'(./rating=ean.rating0(>
<p:a,a& event'(rate( listener'(./rating=ean.handleCate0( update'(msgs( />
<p:a,a& event'(cancel( listener'(./rating=ean.handleancel0( update'(msgs( />
</p:rating>
<p:messages id'(msgs( />
pu-lic class Cating=ean /
private Integer rating;
pu-lic void handleCate9Cate$vent rate$vent: /
Integer rate ' 9Integer: rate$vent.getCating9:;
//<dd facesmessage
0
pu-lic void handleancel9: /
//<dd facesmessage
0
//getter3setter
0
$lient Side $allbac+s
on+ate i ca((ed 'hen a tar i e(ected 'ith value a the on(y &ara"eter.
<p:rating value'(./rating=ean.rating0( onCate'(alert9?"ou rated: ? > value:( />
$lient Side API
Wid,etN PrimeFaces.widget.+ating
!et"od Params eturn Type Description
,et>a(ue?@ B <u"ber Return the current va(ue
et>a(ue?va(ue@ va(ueN >a(ue to et void U&date ratin, va(ue 'ith &rovided one.
diab(e?@ B void Diab(e co"&onent.
enab(e?@ B void Enab(e co"&onent.
361
PrimeFaces Users Guide
!et"od Params eturn Type Description
reet?@ B void *(ear the ratin,.
S+innin&
Ratin, reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the (it
o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBratin, 8ain container e(e"ent.
.uiBratin,Bcance( *ance( icon
.uiBratin, De+au(t tar
.uiBratin,Bon Active tar
362
PrimeFaces Users Guide
#.78 "emote$ommand
Re"ote*o""and &rovide a 'ay to e0ecute bac3in, bean "ethod direct(y +ro" /avacri&t.
In%o
9a, remote#ommand
*o"&onent *(a org.primefaces.component.remotecommand.emote#ommand
*o"&onent 9y&e org.primefaces.component.emote#ommand
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.emote#ommandenderer
Renderer *(a org.primefaces.component.remotecommand.emote#ommandenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
action nu(( 8ethod
E0&r
A "ethod e0&reion thatd be &roceed in the &artia(
reCuet caued by uia/a0.
action6itener nu(( 8ethod
E0&r
An action(itener thatd be &roceed in the &artia( reCuet
caued by uia/a0.
i""ediate +a(e 1oo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen +a(e
at invo3eLa&&(ication &hae.
na"e nu(( Strin, <a"e o+ the co""and
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent?@ to &roce &artia((y intead o+ 'ho(e vie'.
u&date nu(( Strin, *o"&onent?@ to u&date 'ith a/a0.
ontart nu(( Strin, Aavacri&t hand(er to e0ecute be+ore a/a0 reCuet i be,in.
onco"&(ete nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet i
co"&(eted.
onucce nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet ucceed.
363
PrimeFaces Users Guide
Name Default Type Description
onerror nu(( Strin, Aavacri&t hand(er to e0ecute 'hen a/a0 reCuet +ai(.
,(oba( true 1oo(ean G(oba( a/a0 reCuet are (itened by a/a0Statu co"&onentE
ettin, ,(oba( to +a(e 'i(( not tri,,er a/a0Statu.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or i+
the va(ue o+ delay i the (itera( trin, OnoneO 'ithout the
CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
autoRun +a(e 1oo(ean When enab(ed co""and i e0ecuted on &a,e (oad.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not be
u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue i
+a(eE no uch indication i "ade.
)ettin& started with "emote$ommand
Re"ote*o""and i ued by invo3in, the co""and +ro" your /avacri&t code.
<p:remoteommand name'(increment( action7istener'(./counter.increment0(
out'(count( />
<h:output!e&t id'(count( value'(./counter.count0( />
<script type'(te&t/,avascript(>
function customfunction9: /
//your custom code
increment9:; //ma2es a remote call
0
</script>
9hat it 'henever you e0ecute your cuto" /avacri&t +unction?e, cuto"+unction?@@E a re"ote ca((
'i(( be "adeE action6itener i &roceed and out&ut te0t i u&dated. <ote that re"ote*o""and
"ut be neted inide a +or".
Passin& Parameters
Re"ote co""and can end dyna"ic &ara"eter in the +o((o'in, 'ayK
increment9Q/name:?&?H value:*00H /name:?y?H value:A00S:;
364
PrimeFaces Users Guide
#.8: "esetInput
In&ut co"&onent 3ee& their (oca( va(ue at tate 'hen va(idation +ai(. ReetIn&ut i ued to c(ear
the cached va(ue +ro" tate o that co"&onent retrieve their va(ue +ro" the bac3in, bean "ode(
intead.
In%o
9a, reset.nput
Action6itener *(a org.primefaces.component.resetinput.eset.nputAction*istener
Attributes
Name Default Type Description
tar,et nu(( Strin, *o""a or 'hite &ace e&arated (it o+
co"&onent identi+ier.
)ettin& started with "esetInput
ReetIn&ut i attached to action ource co"&onent (i3e co""and1utton and co""and6in3.
<h:form id'(form(>
<p:panel id'(panel( header'(Jew Kser( style'(margin3-ottom:*0p&;(>
<p:messages id'(messages( />
<h:panelIrid columns'(A(>
<h:output7a-el for'(firstname( value'(6irstname: W( />
<p:input!e&t id'(firstname( value'(./ppr=ean.firstname0(
reBuired'(true( la-el'(6irstname(>
<f:validate7ength minimum'(A( />
</p:input!e&t>
<h:output7a-el for'(surname( value'(8urname: W( />
<p:input!e&t id'(surname( value'(./ppr=ean.surname0(
reBuired'(true( la-el'(8urname(/>
</h:panelIrid>
</p:panel>
<p:command=utton value'(8u-mit( update'(panel(
action7istener'(./ppr=ean.save#erson0( />
<p:command=utton value'(Ceset !ag( update'(panel( process'(Zthis(>
<p:resetInput target'(panel( />
</p:command=utton>
<p:command=utton value'(Ceset Jon3<,a&(
action7istener'(./ppr=ean.reset0( immediate'(true( a,a&'(false(>
<p:resetInput target'(panel( />
</p:command=utton>
</h:form>
ReetIn&ut u&&ort both a/a0 and nonBa/a0 actionE +or nonBa/a0 action et i""ediate true on the
ource co"&onent o (i+ecyc(e /u"& to render re&one a+ter reettin,. 9o reet "u(ti&(e
365
PrimeFaces Users Guide
co"&onent at onceE &rovide a (it o+ id or /ut &rovide an ancetor co"&onent (i3e the &ane( in
a"&(e above.
"eset Pro&rammatically
ReetIn&ut ta, i the dec(arative 'ay to reet in&ut co"&onentE another 'ay i reettin,
&ro,ra""atica((y. 9hi i a(o handy i+ in&ut hou(d ,et reet baed on a condition. #o((o'in,
a"&(e de"ontrate ho' to ue ReCuet*onte0t to do the reet 'ithin an a/a0behavior (itener.
!ara"eter o+ the reet "ethod can be a in,(e c(ientId or a co((ection o+ c(ientId.
<p:input!e&t value'(./-ean.value0(>
<p:a,a& event'(-lur( listener'(./-ean.listener0( />
</p:input!e&t>
pu-lic void listener9: /
CeBuestonte&t conte&t ' CeBuestonte&t.geturrentInstance9:;
conte&t.reset9(form:panel(:;
0
1ip
&Na/a0 ha bui(tBin reset2alues attribute to reet va(ue o+ &roceed co"&onent durin, a reCuet.
366
PrimeFaces Users Guide
#.81 "esi9able
Rei=ab(e co"&onent i ued to "a3e another AS# co"&onent rei=ab(e.
In%o
9a, resi3a&le
*o"&onent *(a org.primefaces.component.resi3a&le.esi3a&le
*o"&onent 9y&e org.primefaces.component.esi3a&le
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.esi3a&leenderer
Renderer *(a org.primefaces.component.resi3a&le.esi3a&leenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE 'hen
et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
+or nu(( Strin, Identi+ier o+ the tar,et co"&onent to "a3e rei=ab(e.
a&ectRatio +a(e 1oo(ean De+ine i+ a&ectRatio hou(d be 3e&t or not.
&ro0y +a(e 1oo(ean Di&(ay &ro0y e(e"ent intead o+ actua( e(e"ent.
hand(e nu(( Strin, S&eci+ie the rei=e hand(e.
,hot +a(e 1oo(ean In ,hot "odeE rei=e he(&er i di&(ayed a the ori,ina(
e(e"ent 'ith (e o&acity.
ani"ate +a(e 1oo(ean Enab(e ani"ation.
e++ect 'in, Strin, E++ect to ue in ani"ation.
e++ectDuration nor"a( Strin, E++ect duration o+ ani"ation.
"a0Width nu(( Inte,er 8a0i"u" 'idth boundary in &i0e(.
"a0.ei,ht nu(( Inte,er 8a0i"u" hei,ht boundary in &i0e(.
"inWidth 10 Inte,er 8ini"u" 'idth boundary in &i0e(.
"in.ei,ht 10 Inte,er 8a0i"u" hei,ht boundary in &i0e(.
367
PrimeFaces Users Guide
Name Default Type Description
contain"ent +a(e 1oo(ean Set rei=ab(e boundarie a the &arent i=e.
,rid 1 Inte,er Sna& rei=in, to ,rid tructure.
onStart nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen rei=in, be,in.
onRei=e nu(( Strin, *(ient ide ca((bac3 to e0ecute durin, rei=in,.
onSto& nu(( Strin, *(ient ide ca((bac3 to e0ecute a+ter rei=in, end.
)ettin& started with "esi9able
Rei=ab(e i ued by ettin, for o&tion a the identi+ier o+ the tar,et.
<p:graphicImage id'(img( value'(campnou.,pg( />
<p:resiOa-le for'(img( />
Another e0a"&(e i the in&ut +ie(dE i+ uer need "ore &ace +or a te0tareaE "a3e it rei=ab(e byK
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( />
.oundaries
9o &revent over(a&&in, 'ith other e(e"ent on &a,eE boundarie need to be &eci+ied. 9herere -
attribute +or thi min5idthE ma$5idthE min.eight and ma$.eight. 9he va(id va(ue +or thee
attribute are nu"ber in ter" o+ &i0e(.
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( min1idth'(A0( min4eight'(E0( ma&1idth'(50( ma&4eight'(*00(/>
(andles
Rei=e hand(e to di&(ay are cuto"i=e uin, handles attribute 'ith a co"bination o+ nE eE sE wE neE
seE sw and nw a the va(ue. De+au(t va(ue i IeE sE seI.
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( handles'(eHwHnHseHswHneHnw(/>
<isual Feedbac+
Rei=e he(&er i the e(e"ent ued to &rovide viua( +eedbac3 durin, rei=in,. 1y de+au(t actua(
e(e"ent ite(+ i the he(&er and t'o o&tion are avai(ab(e to cuto"i=e the 'ay +eedbac3 i &rovided.
Enab(in, ghost o&tion di&(ay the e(e"ent ite(+ 'ith a (o'er o&acityE in addition enab(in, pro$y
o&tion add a c c(a ca((ed .ui1resi/able1pro$y 'hich you can override to cuto"i=e.
368
PrimeFaces Users Guide
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( pro&y'(true( />
.ui3resiOa-le3pro&y /
-order: Ap& dotted .006;
0
/%%ects
Rei=in, can be ani"ated uin, animate o&tion and ettin, an effect na"e. Ani"ation &eed i
cuto"i=ed uin, effect'uration o&tion 4slow4E 4normal4 and 4fast4 a va(id va(ue.
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( animate'(true( effect'(swing( effectDuration'(normal( />
#o((o'in, i the (it o+ avai(ab(e e++ect na"eK
G 'in,
G eaeInDuad
G eae7utDuad
G eaeIn7utDuad
G eaeIn*ubic
G eae7ut*ubic
G eaeIn7ut*ubic
G eaeInDuart
G eae7utDuart
G eaeIn7utDuart
G eaeInDuint
G eae7utDuint
G eaeIn7utDuint
G eaeInSine
G eae7utSine
G eaeInE0&o
G eae7utE0&o
G eaeIn7utE0&o
G eaeIn*irc
G eae7ut*irc
G eaeIn7ut*irc
G eaeInE(atic
G eae7utE(atic
G eaeIn7utE(atic
G eaeIn1ac3
G eae7ut1ac3
G eaeIn7ut1ac3
G eaeIn1ounce
G eae7ut1ounce
G eaeIn7ut1ounce
A,a- .ehaior /ents
Rei=ab(e &rovide de+au(t and on(y resi/e event that i ca((ed on rei=e end. In cae you have a
(itener de+inedE it 'i(( be ca((ed by &ain, an org.primefaces.event.+esi/eEvent intance a a
&ara"eter.
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area(>
<p:a,a& listener'(./resiOe=ean.handleCesiOe0(>
</p:resiOa-le>
pu-lic class CesiOe=ean /
pu-lic void handleCesiOe9CesiOe$vent event: /
int width ' event.get1idth9:;
int height ' event.get4eight9:;
0
0
369
PrimeFaces Users Guide
$lient Side $allbac+s
Rei=ab(e ha three c(ient ide ca((bac3 you can ue to hoo3Bin your /avacri&tK onStartE on+esi/e
and onStop. A(( o+ thee ca((bac3 receive t'o &ara"eter that &rovide variou in+or"ation about
rei=e event.
<h:input!e&tarea id'(area( value'(CesiOe me if you need more space( />
<p:resiOa-le for'(area( on8top'(handle8top9eventH ui:( />
function handle8top9eventH ui: /
//ui.helper ' helper element as a ,Duery o-,ect
//ui.original#osition ' topH left position -efore resiOing
//ui.original8iOe ' widthH height -efore resiOing
//ui.positon ' topH left after resiOing
//ui.siOe ' width height of current siOe
0
S+innin&
)tyle #lass Applies
.uiBrei=ab(e E(e"ent that i rei=ab(e
.uiBrei=ab(eBhand(e .and(e e(e"ent
.uiBrei=ab(eBhand(eBVhand(e3eyW !articu(ar hand(e e(e"ent identi+ied by hand(e3ey (i3e eE E ne
.uiBrei=ab(eB&ro0y !ro0y he(&er e(e"ent +or viua( +eedbac3
370
PrimeFaces Users Guide
#.82 "in&
Rin, i a data di&(ay co"&onent 'ith a circu(ar ani"ation.
In%o
9a, ring
*o"&onent *(a org.primefaces.component.ring.ing
*o"&onent 9y&e org.primefaces.component.ing
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.ingenderer
Renderer *(a org.primefaces.component.ring.ingenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
va(ue nu(( 7b/ect *o((ection to di&(ay.
var nu(( Strin, <a"e o+ the data iterator.
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
eain, 'in, Strin, 9y&e o+ eain, to ue in ani"ation.
371
PrimeFaces Users Guide
)ettin& started with "in&
A co((ection i reCuired to ue the Rin, co"&onent.
pu-lic class Cing=ean /
private 7ist<#layer> players;
pu-lic Cing=ean9: /
players ' new <rray7ist<#layer>9:;
players.add9new #layer9(5essi(H *0H (messi.,pg(H (6(::;
players.add9new #layer9(Iniesta(H GH (iniesta.,pg(H (5(::;
players.add9new #layer9(@illa(H PH (villa.,pg(H (6(::;
players.add9new #layer9(Navi(H UH (&avi.,pg(H (5(::;
players.add9new #layer9(#uyol(H 5H (puyol.,pg(H (=(::;
0
//getterRsetter for players
0
<p:ring value'(./ring=ean.players0( var'(player]>
<p:graphicImage value'(/images/-arca/./player.photo0(/>
</p:ring>
Item Selection
A co(u"n i reCuired to &roce ite" e(ection +ro" rin, &ro&er(y.
<p:ring value'(./ring=ean.players0( var'(player(>
<p:column>
//KI to select an item e.g. command7in2
</p:column>
</p:ring>
/asin&
#o((o'in, i the (it o+ avai(ab(e o&tion +or eain, ani"ation.
G 'in,
G eaeInDuad
G eae7utDuad
G eaeIn7utDuad
G eaeIn*ubic
G eae7ut*ubic
G eaeIn7ut*ubic
G eaeInDuart
G eae7utDuart
G eaeIn7utDuart
G eaeInDuint
G eae7utDuint
G eaeIn7utDuint
G eaeInSine
G eae7utSine
G eaeInE0&o
G eae7utE0&o
G eaeIn7utE0&o
G eaeIn*irc
G eae7ut*irc
G eaeIn7ut*irc
G eaeInE(atic
G eae7utE(atic
G eaeIn7utE(atic
G eaeIn1ac3
G eae7ut1ac3
G eaeIn7ut1ac3
G eaeIn1ounce
G eae7ut1ounce
G eaeIn7ut1ounce
372
PrimeFaces Users Guide
S+innin&
Rin, reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the (it o+
tructura( ty(e c(ae.
)tyle #lass Applies
.uiBrin, 8ain container e(e"ent.
.uiBrin,Bite" Each ite" in the (it.
373
PrimeFaces Users Guide
#.8# "ow
Ro' i a he(&er co"&onent +or datatab(e.
In%o
9a, ro0
*o"&onent *(a org.primefaces.component.ro0.o0
*o"&onent 9y&e org.primefaces.component.o0
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
)ettin& Started with "ow
See datatab(e ,rou&in, ection +or "ore in+or"ation about ho' ro' i ued.
374
PrimeFaces Users Guide
#.8' "ow/ditor
Ro'Editor i a he(&er co"&onent +or datatab(e.
In%o
9a, ro0'ditor
*o"&onent *(a org.primefaces.component.ro0editor.o0'ditor
*o"&onent 9y&e org.primefaces.component.o0'ditor
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.o0'ditorenderer
Renderer *(a org.primefaces.component.ro0editor.o0'ditorenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
)ettin& Started with "ow/ditor
See in(ine editin, ection in datatab(e docu"entation +or "ore in+or"ation about ua,e.
375
PrimeFaces Users Guide
#.83 "ow/-pansion
Ro'E0&anion i a he(&er co"&onent o+ datatab(e ued to i"&(e"ent e0&andab(e ro'.
In%o
9a, ro0'$pansion
*o"&onent *(a org.primefaces.component.ro0e$pansion.o0'$pansion
*o"&onent 9y&e org.primefaces.component.o0'$pansion
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
)ettin& Started with "ow/-pansion
See datatab(e e0&andab(e ro' ection +or "ore in+or"ation about ho' ro'E0&anion i ued.
376
PrimeFaces Users Guide
#.85 "ow1o&&ler
Ro'9o,,(er i a he(&er co"&onent +or datatab(e.
In%o
9a, ro0Toggler
*o"&onent *(a org.primefaces.component.ro0toggler.o0Toggler
*o"&onent 9y&e org.primefaces.component.o0Toggler
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.o0Togglerenderer
Renderer *(a org.primefaces.component.ro0toggler.o0Togglerenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
)ettin& Started with "ow
See e0&andab(e ro' ection in datatab(e docu"entation +or "ore in+or"ation about ua,e.
377
PrimeFaces Users Guide
#.86 Schedule
Schedu(e &rovide an 7ut(oo3 *a(endarE i*a( (i3e AS# co"&onent to "ana,e event.
In%o
9a, sc"edule
*o"&onent *(a org.primefaces.component.sc"edule.)c"edule
*o"&onent 9y&e org.primefaces.component.)c"edule
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)c"eduleenderer
Renderer *(a org.primefaces.component.sc"edule.)c"eduleenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i((
not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
378
PrimeFaces Users Guide
Name Default Type Description
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
va(ue nu(( 7b/ect An or,.&ri"e+ace."ode(.Schedu(e8ode(
intance re&reentin, the bac3ed "ode(
(oca(e nu(( 7b/ect 6oca(e +or (oca(i=ationE can be Strin, or a
/ava.uti(.6oca(e intance
a&ectRatio nu(( #(oat Ratio o+ ca(endar 'idth to hei,htE hi,her the
va(ue horter the hei,ht i
vie' "onth Strin, 9he vie' ty&e to ueE &oib(e va(ue are
O"onthOE Oa,endaDayOE Oa,endaWee3OE
ObaicWee3OE ObaicDayO
initia(Date nu(( 7b/ect 9he initia( date that i ued 'hen chedu(e
(oad. I+ o""ittedE the chedu(e tart on the
current date
ho'Wee3end true 1oo(ean S&eci+ie inc(uion SaturdayQSunday
co(u"n in any o+ the vie'
ty(e nu(( Strin, Sty(e o+ the "ain container e(e"ent o+
chedu(e
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container e(e"ent o+
chedu(e
dra,,ab(e true 1oo(ean When trueE event are dra,,ab(e.
rei=ab(e true 1oo(ean When trueE event are rei=ab(e.
ho'.eader true 1oo(ean S&eci+ie viibi(ity o+ header content.
(e+t.eader9e"&(ate &revE ne0t
today
Strin, *ontent o+ (e+t ide o+ header.
center.eader9e"&(ate tit(e Strin, *ontent o+ center o+ header.
ri,ht.eader9e"&(ate "onthE
a,endaWee3E
a,endaDay
Strin, *ontent o+ ri,ht ide o+ header.
a((DayS(ot true 1oo(ean Deter"ine i+ a((Bday (ot 'i(( be di&(ayed
in a,endaWee3 or a,endaDay vie'
(ot8inute )0 Inte,er Interva( in "inute in an hour to create a (ot.
+irt.our 4 Inte,er #irt hour to di&(ay in day vie'.
"in9i"e nu(( Strin, 8ini"u" ti"e to di&(ay in a day vie'.
"a09i"e nu(( Strin, 8a0i"u" ti"e to di&(ay in a day vie'.
a0i#or"at nu(( Strin, Deter"ine the ti"eBte0t that 'i(( be
di&(ayed on the vertica( a0i o+ the a,enda
vie'.
379
PrimeFaces Users Guide
Name Default Type Description
ti"e#or"at nu(( Strin, Deter"ine the ti"eBte0t that 'i(( be
di&(ayed on each event.
co(u"n#or"at nu(( Strin, #or"at +or co(u"n header.
ti"eUone nu(( 7b/ect Strin, or a /ava.uti(.9i"eUone intance to
&eci+y the ti"e=one ued +or date
converion.
i,nore9i"e=one true 1oo(ean When &arin, dateE 'hether U9* o++et
hou(d be i,nored 'hi(e &rocein, event
data.
too(ti& +a(e 1oo(ean Di&(ay decri&tion o+ event on a too(ti&.
)ettin& started with Schedule
Schedu(e need to be bac3ed by an org.primefaces.model.Schedule-odel intanceE a chedu(e
"ode( conit o+ org.primefaces.model.ScheduleEvent intance.
<p:schedule value'(./schedule=ean.model0( />
pu-lic class 8chedule=ean /
private 8chedule5odel model;
pu-lic 8chedule=ean9: /
event5odel ' new 8chedule5odel<8chedule$vent>9:;
event5odel.add$vent9new Default8chedule$vent9(title(H new Date9:H
new Date9:::;
0
pu-lic 8chedule5odel get5odel9: /
return model;
0
0
De+au(tSchedu(eEvent i the de+au(t i"&(e"entation o+ Schedu(eEvent inter+ace. 8andatory
&ro&ertie reCuired to create a ne' event are the tit(eE tart date and end date. 7ther &ro&ertie uch
a a((Day ,et enib(e de+au(t va(ue.
9ab(e be(o' decribe each &ro&erty in detai(.
Property Description
id Ued interna((y by !ri"e#aceE auto ,enerated.
tit(e 9it(e o+ the event.
tartDate Start date o+ ty&e /ava.uti(.Date.
380
PrimeFaces Users Guide
Property Description
endDate End date o+ ty&e /ava.uti(.Date.
a((Day #(a, indicatin, event i a(( day.
ty(e*(a >iua( ty(e c(a to enab(e "u(ti reource di&(ay.
data 7&tiona( data you can et to be re&reented by Event.
editab(e Whether the event i editab(e or not.
decri&tion 9oo(ti& te0t to di&(ay on "oueover o+ an event.
A,a- .ehaior /ents
Schedu(e &rovide variou a/a0 behavior event to re&ond uer action.
'vent *istener Parameter +ired
dateSe(ect or,.&ri"e+ace.event.Se(ectEvent When a date i e(ected.
eventSe(ect or,.&ri"e+ace.event.Se(ectEvent When an event i e(ected.
event8ove or,.&ri"e+ace.event.Schedu(eEntry8oveEvent When an event i "oved.
eventRei=e or,.&ri"e+ace.event.Schedu(eEntryRei=eEvent When an event i rei=ed.
vie'*han,e or,.&ri"e+ace.event.Se(ectEvent When a vie' i chan,ed.
A,a- 4pdates
Schedu(e ha a Cuite co"&(e0 UI 'hich i ,enerated onBtheB+(y by the c(ient ide
!ri"e#ace.'id,et.Schedu(e 'id,et to ave band'idth and increae &a,e (oad &er+or"ance. A a
reu(t 'hen you try to u&date chedu(e (i3e 'ith a re,u(ar !ri"e#ace !!RE you "ay notice a UI
(a, a the D78 'i(( be re,enerated and re&(aced. InteadE Schedu(e &rovide a i"&(e c(ient ide
a&i and the update "ethod.
Whenever you ca(( u&dateE chedu(e 'i(( Cuery it erver ide Schedu(e8ode( intance to chec3 +or
u&dateE tran&ort "ethod ued to (oad event dyna"ica((y i AS7<E a a reu(t thi a&&roach i
"uch "ore e++ective then u&datin, 'ith re,u(ar !!R. An e0a"&(e o+ thi i de"ontrated at editab(e
chedu(e e0a"&(eE ave button i ca((in, !#?Owidgetvar?!.update! at onco"&(ete event hand(er.
1imeBone
1y de+au(tE ti"e=one o++et are i,nored. Set i,nore9i"e=one to +a(e o that chedu(e ta3e care o+
ti"e=one di++erence by ca(cu(atin, the c(ient bro'er ti"e=one and the event date o that event
are di&(ayed at the c(ient (oca( ti"e.
/ditable Schedule
6et &ut it a(to,ether to co"e u& a +u((y editab(e and co"&(e0 chedu(e.
381
PrimeFaces Users Guide
<h:form>
<p:schedule value'(./-ean.event5odel0( edita-le'(true( widget@ar'(myschedule(>
<p:a,a& event'(date8elect( listener'(./-ean.onDate8elect0(
update'(eventDetails( oncomplete'(eventDialog.show9:( />
<p:a,a& event'(event8elect( listener'(./-ean.on$vent8elect0(
</p:schedule>
<p:dialog widget@ar'(eventDialog( header'($vent Details(>
<h:panelIrid id'(eventDetails( columns'(A(>
<h:output7a-el for'(title( value'(!itle:( />
<h:input!e&t id'(title( value'(./-ean.event.title0( reBuired'(true(/>
<h:output7a-el for'(from( value'(6rom:( />
<p:input5as2 id'(from( value'(./-ean.event.startDate0( mas2'(++/++/++++(>
<f:convertDate!ime pattern'(dd/55/yyyy( />
</p:input5as2>
<h:output7a-el for'(to( value'(!o:( />
<p:input5as2 id'(to( value'(./-ean.event.endDate0( mas2'(++/++/++++(>
<f:convertDate!ime pattern'(dd/55/yyyy( />
</p:input5as2>
<h:output7a-el for'(allDay( value'(<ll Day:( />
<h:select=ooleanhec2-o& id'(allDay( value'(./-ean.event.allDay0( />
<p:command=utton type'(reset( value'(Ceset( />
<p:command=utton value'(8ave( action7istener'(./-ean.add$vent0(
oncomplete'(#69?myschedule?:.update9:;#69?eventDialog?:.hide9:;(/>
</h:panelIrid>
</p:dialog>
</h:form>
382
PrimeFaces Users Guide
pu-lic class 8chedule=ean /
private 8chedule5odel<8chedule$vent> model;
private 8chedule$ventImpl event ' new Default8chedule$vent9:;
pu-lic 8chedule=ean9: /
event5odel ' new 8chedule5odel<8chedule$vent>9:;
0
pu-lic 8chedule5odel<8chedule$vent> get5odel9: / return model; 0
pu-lic 8chedule$ventImpl get$vent9: / return event; 0
pu-lic void set$vent98chedule$ventImpl event: / this.event ' event; 0
pu-lic void add$vent9: /
if9event.getId9: '' null:
event5odel.add$vent9event:;
else
event5odel.update$vent9event:;
event ' new Default8chedule$vent9:; //reset dialog form
0
pu-lic void on$vent8elect98elect$vent e: /
event ' 98chedule$vent: e.getO-,ect9:;
0
pu-lic void onDate8elect98elect$vent e: /
Date date ' 9Date: e.getO-,ect9:;
event ' new Default8chedule$vent9((H dateH date:;
0
0
*a9y *oadin&
Schedu(e au"e 'ho(e et o+ event are ea,er(y &rovided in Schedu(e8ode(E i+ you have a hu,e
data et o+ eventE (a=y (oadin, +eature 'ou(d he(& to i"&rove &er+or"ance. In (a=y (oadin, "odeE
on(y the event that be(on, to the di&(ayed ti"e +ra"e are +etched 'herea in de+au(t ea,er "ore
a(( event need to be (oaded.
<p:schedule value'(./schedule=ean.laOy5odel0( />
9o enab(e (a=y (oadin, o+ Schedu(e eventE you /ut need to &rovide an intance o+
org.primefaces.model.&a/ySchedule-odel and i"&(e"ent the loadEvents "ethod. loadEvents
"ethod i ca((ed 'ith ne' boundarie every ti"e di&(ayed ti"e+ra"e i chan,ed.
383
PrimeFaces Users Guide
pu-lic class 8chedule=ean /
private 8chedule5odel laOy5odel;
pu-lic 8chedule=ean9: /
laOy5odel ' new 7aOy8chedule5odel9: /
ZOverride
pu-lic void load$vents9Date startH Date end: /
//add$vent9...:;
//add$vent9...:;
0
0;
0
pu-lic 8chedule5odel get7aOy5odel9: /
return laOy5odel;
0
0
$ustomi9in& (eader
.eader contro( o+ Schedu(e can be cuto"i=ed baed on te"&(ateE va(id va(ue o+ te"&(ate o&tion
areK
G tit(eN 9e0t o+ current "onthQ'ee3Qday in+or"ation
G &revN 1utton to "ove ca(endar bac3 one "onthQ'ee3Qday.
G ne0tN 1utton to "ove ca(endar +or'ard one "onthQ'ee3Qday.
G &revMearN 1utton to "ove ca(endar bac3 one year
G ne0tMearN 1utton to "ove ca(endar +or'ard one year
G todayN 1utton to "ove ca(endar to current "onthQ'ee3Qday.
view=ame
N 1utton to chan,e the vie' ty&e baed on the vie' ty&e.
9hee contro( can be &(aced at three (ocation on header 'hich are de+ined 'ith
left.eaderTemplateE right.eaderTemplate and centerTemplate attribute.
<p:schedule value'(./schedule=ean.model0(
left4eader!emplate(today(
right4eader!emplate'(prevHne&t(
center!emplate'(monthH agenda1ee2H agendaDay(
</p:schedule>
384
PrimeFaces Users Guide
<iews
5 di++erent vie' are u&&ortedE thee are I"onthIE Ia,endaWee3IE Ia,endaDayIE IbaicWee3I and
IbaicDayI.
a,endaWee3
<p:schedule value'(./schedule=ean.model0( view'(agenda1ee2(/>
a,endaDay
<p:schedule value'(./schedule=ean.model0( view'(agendaDay(/>
baicWee3
<p:schedule value'(./schedule=ean.model0( view'(-asic1ee2(/>
385
PrimeFaces Users Guide
baicDay
<p:schedule value'(./schedule=ean.model0( view'(-asicDay(/>
*ocale Support
1y de+au(t (oca(e in+or"ation i retrieved +ro" the vie' (oca(e and can be overridden by the (oca(e
attribute. 6oca(e attribute can ta3e a (oca(e 3ey a a Strin, or a /ava.uti(.6oca(e intance. De+au(t
(an,ua,e o+ (abe( are En,(ih and you need to add the neceary tran(ation to your &a,e "anua((y
a !ri"e#ace doe not inc(ude (an,ua,e tran(ation. !ri"e#ace Wi3i !a,e +or
!ri"e#ace6oca(e i a co""unity driven &a,e 'here you "ay +ind the tran(ation you need.
!(eae contribute to thi 'i3i 'ith your o'n tran(ation.
http://wi2i.primefaces.org/display/omponents/#rime6aces>7ocales
9ran(ation i a i"&(e /avacri&t ob/ectE 'e u,,et addin, the code to a /avacri&t +i(e and inc(ude
in your a&&(ication. #o((o'in, i a 9ur3ih ca(endar.
<p:schedule value'(./schedule=ean.model0( locale'(tr(/>
S+innin&
Schedu(e reide in a "ain container 'hich style and styleClass attribute a&&(y. A 3innin, ty(e
c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
386
PrimeFaces Users Guide
#.87 ScrollPanel
Scro((!ane( i ued to di&(ay cro((ab(e content 'ith the"e a'are cro((bar intead o+ native
bro'er cro((bar.
In%o
9a, scrollPanel
*o"&onent *(a org.primefaces.component.scrollpanel.)crollPanel
*o"&onent 9y&e org.primefaces.component.)crollPanel
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)crollPanelenderer
Renderer *(a org.primefaces.component.scrollpanel.)crollPanelenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
"ode de+au(t Strin, Scro((bar di&(ay "odeE va(id va(ue are de+au(t
and native.
387
PrimeFaces Users Guide
)ettin& started with ScrollPanel
In order to ,et cro((ab(e contentE 'idth andQor hei,ht hou(d be de+ined.
<p:scroll#anel style'(width:A50p&;height:A00p&(>
//any content
</p:scroll#anel>
0atie Scroll.ars
1y de+au(tE cro((!ane( di&(ay the"e a'are cro((barE ettin, "ode o&tion to native di&(ay
bro'er cro((bar.
<p:scroll#anel style'(width:A50p&;height:A00p&( mode'(native(>
//any content
</p:scroll#anel>
S+innin&
Scro((!ane( reide in a "ain container 'hich style and styleClass attribute a&&(y. A 3innin, ty(e
c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBcro((&ane( 8ain container e(e"ent.
.uiBcro((&ane(Bcontainer 7ver+(o' container.
.uiBcro((&ane(Bcontent *ontent e(e"ent.
.uiBcro((&ane(Bhbar .ori=onta( cro((bar container.
.uiBcro((&ane(Bvbar >ertica( cro((bar container.
.uiBcro((&ane(Btrac3 9rac3 e(e"ent.
.uiBcro((barBdra, Dra, e(e"ent.
388
PrimeFaces Users Guide
#.88 Select.oolean.utton
Se(ect1oo(ean1utton i ued to e(ect a binary deciion 'ith a to,,(e button.
In%o
9a, select%oolean%utton
*o"&onent *(a org.primefaces.component.select&oolean&utton.)elect%oolean%utton
*o"&onent 9y&e org.primefaces.component.)elect%oolean%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect%oolean%uttonenderer
Renderer *(a org.primefaces.component.select&oolean&utton.)elect%oolean%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a converter
+or the co"&onent. When it an E6 e0&reionE it
reo(ved to a converter intance. In cae it a tatic te0tE
it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethod
E0&r
A "ethod e0&reion that re+er to a "ethod va(idation,
the in&ut
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod e0&reion that re+er to a "ethod +or hand(in,
a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
389
PrimeFaces Users Guide
Name Default Type Description
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
on6abe( nu(( Strin, 6abe( to di&(ay 'hen button i e(ected.
o++6abe( nu(( Strin, 6abe( to di&(ay 'hen button i une(ected.
onIcon nu(( Strin, Icon to di&(ay 'hen button i e(ected.
o++Icon nu(( Strin, Icon to di&(ay 'hen button i une(ected.
)ettin& started with Select.oolean.utton
Se(ect1oo(ean1utton ua,e i i"i(ar to e(ect1oo(ean*hec3bo0.
<p:select=oolean=utton id'(valueA( value'(./-ean.value0( on7a-el'("es(
off7a-el'(Jo( onIcon'(ui3icon3chec2( offIcon'(ui3icon3close( />
pu-lic class =ean /
private -oolean value;
//getter and setter
0
S+innin&
Se(ect1oo(ean1utton reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ectboo(eanbutton 8ain container e(e"ent.
390
PrimeFaces Users Guide
#.1:: Select.oolean$hec+bo-
Se(ect1oo(ean*hec3bo0 i an e0tended verion o+ the tandard chec3bo0 'ith the"e inte,ration.
In%o
9a, select%oolean#"ec,&o$
*o"&onent *(a org.primefaces.component.select&ooleanc"ec,&o$.)elect%oolean#"ec,&o$
*o"&onent 9y&e org.primefaces.component.)elect%oolean#"ec,&o$
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect%oolean#"ec,&o$enderer
Renderer *(a org.primefaces.component.select&ooleanc"ec,&o$.)elect%oolean#"ec,&o$
enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In cae
it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
391
PrimeFaces Users Guide
Name Default Type Description
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
ite"6abe( nu(( Strin, 6abe( di&(ayed ne0t to chec3bo0.
tabinde0 nu(( Strin, S&eci+ie tab order +or tab 3ey navi,ation.
)ettin& started with Select.oolean$hec+bo-
Se(ect1oo(ean*hec3bo0 ua,e i a"e a the tandard one.
$lient Side API
Wid,etN PrimeFaces.widget.Select)ooleanChec"bo$
!et"od Params eturn Type Description
chec3?@ B void *hec3 the chec3bo0.
unchec3?@ B void Unchec3 the chec3bo0.
to,,(e?@ B void 9o,,(e chec3 tate.
S+innin&
Se(ect1oo(ean*hec3bo0 reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBch3bo0 8ain container e(e"ent.
.uiBch3bo0Bbo0 *ontainer o+ chec3bo0 icon.
.uiBch3bo0Bicon *hec3bo0 icon.
.uiBch3bo0Bicon *hec3bo0 (abe(.
392
PrimeFaces Users Guide
#.1:1 Select$hec+bo-Menu
Se(ect*hec3bo08enu i a "u(ti e(ect co"&onent that di&(ay o&tion in an over(ay.
In%o
9a, select#"ec,&o$!enu
*o"&onent *(a org.primefaces.component.selectc"ec,&o$menu.)elect#"ec,&o$!enu
*o"&onent 9y&e org.primefaces.component.)elect#"ec,&o$!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect#"ec,&o$!enuenderer
Renderer *(a org.primefaces.component.selectc"ec,&o$menu.)elect#"ec,&o$!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted
at a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
393
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
cro((.ei,ht nu(( Inte,er .ei,ht o+ the over(ay.
onSho' nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen over(ay i
di&(ayed.
on.ide nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen over(ay i
hidden.
+i(ter +a(e 1oo(ean Render an in&ut +ie(d a a +i(ter.
+i(ter8atch8ode tartWith Strin, 8atch "ode +or +i(terin,E va(id va(ue are
tartWithE containE endWith and cuto".
+i(ter#unction nu(( Strin, *(ient ide +unction to ue in cuto" +i(terin,.
caeSenitive +a(e 1oo(ean De+ine i+ +i(terin, 'ou(d be cae enitive.
&ane(Sty(e nu(( Strin, In(ine ty(e o+ the over(ay.
&ane(Sty(e*(a nu(( Strin, Sty(e c(a o+ the over(ay.
a&&end9o nu(( Strin, A&&end the over(ay to the e(e"ent de+ined by
earch e0&reion. De+au(t to docu"ent body.
tabinde0 nu(( Strin, !oition o+ the e(e"ent in the tabbin, order.
394
PrimeFaces Users Guide
)ettin& started with Select$hec+bo-Menu
Se(ect*hec3bo08enu ua,e i a"e a the tandard e(ect8any*hec3bo0 or !ri"e#ace
e(ect8any*hec3bo0 co"&onent.
<p:selecthec2-o&5enu value'(./-ean.selectedOptions0( la-el'(5ovies(>
<f:selectItems value'(./-ean.options0( />
</p:selecthec2-o&5enu>
Filterin&
When +i(terin, i enab(ed 'ith ettin, filter onE an in&ut +ie(d i rendered at over(ay header and on
3eyu& event +i(terin, i e0ecuted on c(ient ide uin, filter-atch-ode. De+au(t "ode o+
+i(ter8atch8ode are tartWithE containE endWith and cuto". *uto" "ode reCuire a /avacri&t
+unction to do the +i(terin,.
<p:selecthec2-o&5enu value'(./-ean.selectedOptions0( la-el'(5ovies(
filter5atch5ode'(custom( filter6unction'(custom6ilter(>
<f:selectItems value'(./-ean.options0( />
</p:selecthec2-o&5enu>
function custom6ilter9item7a-elH filter@alue: /
//return true to accept and false to re,ect
0
A,a- .ehaior /ents
In addition to co""on do" event (i3e chan,eE e(ect*hec3bo08enu &rovide toggleSelect event.
'vent *istener Parameter +ired
to,,(eSe(ect or,.&ri"e+ace.event.9o,,(eSe(ectEvent When to,,(e a(( chec3bo0 chan,e.
S+innin&
Se(ect*hec3bo08enu reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ectchec3bo0"enu 8ain container e(e"ent.
.uiBe(ectchec3bo0"enuB(abe(Bcontainer 6abe( container.
.uiBe(ectchec3bo0"enuB(abe( 6abe(.
.uiBe(ectchec3bo0"enuBtri,,er Dro&do'n icon.
.uiBe(ectchec3bo0"enuB&ane( 7ver(ay &ane(.
.uiBe(ectchec3bo0"enuBite" 7&tion (it container.
395
PrimeFaces Users Guide
)tyle #lass Applies
.uiBe(ectchec3bo0"enuBite" Each o&tion in the co((ection.
.uiBch3bo0 *ontainer o+ a chec3bo0.
.uiBch3bo0Bbo0 *ontainer o+ chec3bo0 icon.
.uiBch3bo0Bicon *hec3bo0 icon.
396
PrimeFaces Users Guide
#.1:2 SelectMany.utton
Se(ect8any1utton i a "u(ti e(ect co"&onent uin, button UI.
In%o
9a, select!any%utton
*o"&onent *(a org.primefaces.component.selectmany&utton.)elect!any%utton
*o"&onent 9y&e org.primefaces.component.)elect!any%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect!any%utton
Renderer *(a org.primefaces.component.selectmany&utton.)elect!any%utton
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted
at a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
397
PrimeFaces Users Guide
Name Default Type Description
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
)ettin& started with SelectMany.utton
Se(ect8any1utton ua,e i a"e a e(ect8any*hec3bo0E button /ut re&(ace chec3bo0e.
S+innin&
Se(ect8any1utton reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ect"anybutton 8ain container e(e"ent.
398
PrimeFaces Users Guide
#.1:# SelectMany$hec+bo-
Se(ect8any*hec3bo0 i an e0tended verion o+ the tandard Se(ect8any*hec3bo0 'ith the"e
inte,ration.
In%o
9a, select!any#"ec,&o$
*o"&onent *(a org.primefaces.component.selectmanyc"ec,&o$.)elect!any#"ec,&o$
*o"&onent 9y&e org.primefaces.component.)elect!any#"ec,&o$
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect!any#"ec,&o$enderer
Renderer *(a org.primefaces.component.selectmanyc"ec,&o$.)elect!any#"ec,&o$enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQSt
rin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
399
PrimeFaces Users Guide
Name Default Type Description
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
(ayout (ineDirection Strin, 6ayout o+ the chec3bo0eE va(id va(ue are
line'irectionE page'irection and grid.
co(u"n 0 Inte,er <u"ber o+ co(u"n in ,rid (ayout.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
)ettin& started with SelectMany$hec+bo-
Se(ect8any*hec3bo0 ua,e i a"e a the tandard one.
S+innin&
Se(ect8any*hec3bo0 reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ect"anychec3bo0 8ain container e(e"ent.
.uiBch3bo0 *ontainer o+ a chec3bo0.
.uiBch3bo0Bbo0 *ontainer o+ chec3bo0 icon.
.uiBch3bo0Bicon *hec3bo0 icon.
400
PrimeFaces Users Guide
#.1:' SelectManyMenu
Se(ect8any8enu i an e0tended verion o+ the tandard Se(ect8any8enu.
In%o
9a, select!any!enu
*o"&onent *(a org.primefaces.component.selectmanymenu.)elect!any!enu
*o"&onent 9y&e org.primefaces.component.)elect!any!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect!any!enuenderer
Renderer *(a org.primefaces.component.selectmanymenu.)elect!any!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted
at a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
401
PrimeFaces Users Guide
Name Default Type Description
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
onc(ic3 nu(( Strin, *a((bac3 +or c(ic3 event.
ondb(c(ic3 nu(( Strin, *a((bac3 +or db(c(ic3 event.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
tabinde0 nu(( Strin, !oition o+ the in&ut e(e"ent in the tabbin, order.
var nu(( Strin, <a"e o+ iterator to be ued in cuto" content
di&(ay.
ho'*hec3bo0 +a(e 1oo(ean When trueE a chec3bo0 i di&(ayed ne0t to each
ite".
+i(ter +a(e 1oo(ean Di&(ay an in&ut +i(ter +or the (it.
+i(ter8atch8ode nu(( Strin, 8atch "ode +or +i(terin,E va(id va(ue are
tartWith ?de+au(t@E containE endWith and
cuto".
+i(ter#unction nu(( Strin, *(ient ide +unction to ue in cuto"
+i(ter8atch8ode.
caeSenitive +a(e 1oo(ean De+ine i+ +i(terin, 'ou(d be cae enitive.
cro((.ei,ht nu(( Inte,er De+ine the hei,ht o+ the cro((ab(e area
)ettin& started with SelectManyMenu
Se(ect8any8enu ua,e i a"e a the tandard one.
$ustom $ontent
*uto" content can be di&(ayed +or each ite" uin, co(u"n co"&onent.
402
PrimeFaces Users Guide
<p:select5any5enu value'(./-ean.selected#layers0( converter'(player( var'(p(>
<f:selectItems value'(./-ean.players0( var'(player(
item7a-el'(./player.name0( item@alue'(./player0( />
<p:column>
<p:graphicImage value'(/images/-arca/./p.photo0( width'(E0(/>
</p:column>
<p:column>
./p.name0 3 ./p.num-er0
</p:column>
</p:select5any5enu>
Filterin&
#i(terin, i enab(ed by ettin, +i(ter attribute to true. 9here are +our +i(ter "odeK starts5ithE
containsE ends5ith and custom. In cuto" "odeE filterFunction "ut be de+ined a the na"e o+ the
/avacri&t +unction that ta3e the ite" va(ue and +i(ter a &ara"eter to return a boo(ean to acce&t or
re/ect a va(ue. 9o add a +i(ter to &reviou e0a"&(eK
<p:selectOne5enu value'(./menu=ean.selected#layer0( converter'(player( var'(p(
filter'(true( filter5atch5ode'(contains(>
...
</p:selectOne5enu>
$hec+bo-
Se(ect8any8enu ha bui(tBin u&&ort +or chec3bo0 baed "u(ti&(e e(ectionE 'hen enab(ed by
showChec"bo$ o&tionE chec3bo0e are di&(ayed ne0t to each co(u"n.
403
PrimeFaces Users Guide
S+innin&
Se(ect8any8enu reide in a container that style and styleClass attribute a&&(y. A 3innin, ty(e
c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ect"any"enu 8ain container e(e"ent.
.uiBe(ect(itbo0Bite" Each ite" in (it.
404
PrimeFaces Users Guide
#.1:3 Select;ne.utton
Se(ect7ne1utton i an in&ut co"&onent to do a in,(e e(ect.
In%o
9a, select6ne%utton
*o"&onent *(a org.primefaces.component.selectone&utton.)elect6ne%utton
*o"&onent 9y&e org.primefaces.component.)elect6ne%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect6ne%uttonenderer
Renderer *(a org.primefaces.component.selectone&utton.)elect6ne%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQSt
rin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
405
PrimeFaces Users Guide
Name Default Type Description
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
)ettin& started with Select;ne.utton
Se(ect7ne1utton ua,e i a"e a e(ect7neRadio co"&onentE button /ut re&(ace the radio.
S+innin&
Se(ect7ne1utton reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ectonebutton 8ain container e(e"ent.
406
PrimeFaces Users Guide
#.1:5 Select;ne*istbo-
Se(ect7ne6itbo0 i an e0tended verion o+ the tandard e(ect7ne6itbo0 co"&onent.
In%o
9a, select6ne*ist&o$
*o"&onent *(a org.primefaces.component.selectonelist&o$.)elect6ne*ist&o$
*o"&onent 9y&e org.primefaces.component.)elect6ne*ist&o$
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect6ne*ist&o$enderer
Renderer *(a org.primefaces.component.selectonelist&o$.)elect6ne*ist%o$enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
407
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
onc(ic3 nu(( Strin, *a((bac3 +or c(ic3 event.
ondb(c(ic3 nu(( Strin, *a((bac3 +or db(c(ic3 event.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
tabinde0 nu(( Strin, !oition o+ the in&ut e(e"ent in the tabbin, order.
va(ue nu(( Strin, <a"e o+ iterator to be ued in cuto" content
di&(ay.
var nu(( Strin, <a"e o+ iterator to be ued in cuto" content
di&(ay.
+i(ter +a(e 1oo(ean Di&(ay an in&ut +i(ter +or the (it.
+i(ter8atch8ode nu(( Strin, 8atch "ode +or +i(terin,E va(id va(ue are
tartWith ?de+au(t@E containE endWith and
cuto".
+i(ter#unction nu(( Strin, *(ient ide +unction to ue in cuto"
+i(ter8atch8ode.
caeSenitive +a(e 1oo(ean De+ine i+ +i(terin, 'ou(d be cae enitive.
cro((.ei,ht nu(( Inte,er De+ine the hei,ht o+ the cro((ab(e area.
)ettin& started with Select;ne*istbo-
Se(ect7ne6itbo0 ua,e i a"e a the tandard one.
$ustom $ontent
*uto" content can be di&(ayed +or each ite" uin, co(u"n co"&onent.
408
PrimeFaces Users Guide
<p:selectOne7ist-o& value'(./-ean.player0( converter'(player( var'(p(>
<f:selectItems value'(./-ean.players0( var'(player(
item7a-el'(./player.name0( item@alue'(./player0( />
<p:column>
<p:graphicImage value'(/images/-arca/./p.photo0( width'(E0(/>
</p:column>
<p:column>
./p.name0 3 ./p.num-er0
</p:column>
</p:selectOne7ist-o&>
Filterin&
#i(terin, i enab(ed by ettin, +i(ter attribute to true. 9here are +our +i(ter "odeK starts5ithE
containsE ends5ith and custom. In cuto" "odeE filterFunction "ut be de+ined a the na"e o+ the
/avacri&t +unction that ta3e the ite" va(ue and +i(ter a &ara"eter to return a boo(ean to acce&t or
re/ect a va(ue. 9o add a +i(ter to &reviou e0a"&(eK
<p:selectOne5enu value'(./menu=ean.selected#layer0( converter'(player( var'(p(
filter'(true( filter5atch5ode'(contains(>
...
</p:selectOne5enu>
S+innin&
Se(ect7ne6itbo0 reide in a "ain container 'hich style and styleClass attribute a&&(y. A
3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i
the (it o+ tructura( ty(e c(aeK
409
PrimeFaces Users Guide
)tyle #lass Applies
.uiBe(ectone(itbo0 8ain container e(e"ent.
.uiBe(ect(itbo0Bite" Each ite" in (it.
410
PrimeFaces Users Guide
#.1:6 Select;neMenu
Se(ect7ne8enu i an e0tended verion o+ the tandard Se(ect7ne8enu.
In%o
9a, select6ne!enu
*o"&onent *(a org.primefaces.component.selectonemenu.)elect6ne!enu
*o"&onent 9y&e org.primefaces.component.)elect6ne!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect6ne!enuenderer
Renderer *(a org.primefaces.component.selectonemenu.)elect6ne!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate 0 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired 0 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
411
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
e++ect b(ind Strin, <a"e o+ the to,,(e ani"ation.
e++ectS&eed -00 Inte,er Duration o+ to,,(e ani"ation in "i((iecond.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute on va(ue chan,e.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute on 3eyu&.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute on 3eydo'n.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
var nu(( Strin, <a"e o+ the ite" iterator.
hei,ht auto Inte,er .ei,ht o+ the over(ay.
tabinde0 nu(( Strin, 9abinde0 o+ the in&ut.
editab(e +a(e 1oo(ean When trueE in&ut beco"e editab(e.
+i(ter +a(e 1oo(ean Render an in&ut +ie(d a a +i(ter.
+i(ter8atch8ode tart
With
Strin, 8atch "ode +or +i(terin,E va(id va(ue are tartWithE
containE endWith and cuto".
+i(ter#unction nu(( Strin, *(ient ide +unction to ue in cuto" +i(terin,.
caeSenitive +a(e 1oo(ean De+ine i+ +i(terin, 'ou(d be cae enitive.
"a0(en,th nu(( Inte,er <u"ber o+ "a0i"u" character a((o'ed in editab(e
e(ect7ne8enu.
a&&end9o nu(( Strin, A&&end the over(ay to the e(e"ent de+ined by earch
e0&reion. De+au(t to docu"ent body.
)ettin& started with Select;neMenu
1aic Se(ect7ne8enu ua,e i a"e a the tandard one.
412
PrimeFaces Users Guide
$ustom $ontent
Se(ect7ne8enu can di&(ay cuto" content in over(ay &ane( by uin, co(u"n co"&onent and the
var o&tion to re+er to each ite".
pu-lic class 5enu=ean /
private 7ist<#layer> players;
private #layer selected#layer;
pu-lic Order7ist=ean9: /
players ' new <rray7ist<#layer>9:;
players.add9new #layer9(5essi(H *0H (messi.,pg(::;
//more players
0
//getters and setters
0
<p:selectOne5enu value'(./menu=ean.selected#layer0( converter'(player( var'(p(>
<f:selectItem item7a-el'(8elect One( item@alue'(( />
<f:selectItems value'(./menu=ean.players0( var'(player(
item7a-el'(./player.name0( item@alue'(./player0(/>
<p:column>
<p:graphicImage value'(/images/-arca/./p.photo0( width'(E0( height'(50(/>
</p:column>
<p:column>
./p.name0 3 ./p.num-er0
</p:column>
</p:selectOne5enu>
/%%ects
An ani"ation i e0ecuted to ho' and hide the over(ay "enuE de+au(t e++ect i +ade and +o((o'in,
o&tion are avai(ab(e +or effect attributeK b(indE bounceE c(i&E dro&E e0&(odeE +o(dE hi,h(i,htE &u++E
&u(ateE ca(eE ha3eE i=eE (ide and none.
413
PrimeFaces Users Guide
/ditable
Editab(e Se(ect7ne8enu &rovide a UI to either chooe +ro" the &rede+ined o&tion or enter a
"anua( in&ut. Set editab(e o&tion to true to ue thi +eature.
Filterin&
When +i(terin, i enab(ed 'ith ettin, filter onE an in&ut +ie(d i rendered at over(ay header and on
3eyu& event +i(terin, i e0ecuted on c(ient ide uin, filter-atch-ode. De+au(t "ode o+
+i(ter8atch8ode are tartWithE containE endWith and cuto". *uto" "ode reCuire a /avacri&t
+unction to do the +i(terin,.
<p:selectOne5enu value'(./-ean.selectedOptions0(
filter5atch5ode'(custom( filter6unction'(custom6ilter(>
<f:selectItems value'(./-ean.options0( />
</p:selectOne5enu>
function custom6ilter9item7a-elH filter@alue: /
//return true to accept and false to re,ect
0
$lient Side API
Wid,etN PrimeFaces.widget.Select,ne-enu
414
PrimeFaces Users Guide
!et"od Params eturn Type Description
ho'?@ B void Sho' over(ay "enu.
hide?@ B void .ide over(ay "enu.
b(ur?@ B void Invo3e b(ur event.
+ocu?@ B void Invo3e +ocu event.
enab(e?@ B void Enab(e co"&onent.
diab(e?@ B void Diab(ed co"&onent.
e(ect>a(ue?@ va(ueN ite">a(ue void Se(ect ,iven va(ue.
,etSe(ected>a(ue?@ B 7b/ect Return va(ue o+ e(ected ite".
,etSe(ected6abe(?@ Strin, Return (abe( o+ e(ected ite".
S+innin&
Se(ect7ne8enu reide in a container e(e"ent that style and styleClass attribute a&&(y. A 3innin,
ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ectone"enu 8ain container.
.uiBe(ectone"enuB(abe( 6abe( o+ the co"&onent.
.uiBe(ectone"enuBtri,,er *ontainer o+ dro&do'n icon.
.uiBe(ectone"enuBite" Ite" (it.
.uiBe(ectone"enuBite" Each ite" in the (it.
415
PrimeFaces Users Guide
#.1:7 Select;ne"adio
Se(ect7neRadio i an e0tended verion o+ the tandard Se(ect7neRadio 'ith the"e inte,ration.
In%o
9a, select6neadio
*o"&onent *(a org.primefaces.component.selectoneradio.)elect6neadio
*o"&onent 9y&e org.primefaces.component.)elect6neadio
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)elect6neadioenderer
Renderer *(a org.primefaces.component.selectoneradio.)elect6neadioenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent re+errin, to a 6it.
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate 0 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired 0 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod
va(idation, the in&ut
va(ue*han,e6itener nu(( 8ethodE0&r A "ethod e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
416
PrimeFaces Users Guide
Name Default Type Description
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
(ayout (ine
Direction
Strin, 6ayout o+ the radiobuttonE va(id va(ue are
line'irectionE page'irectionE custom and grid.
co(u"n 0 Inte,er <u"ber o+ co(u"n in ,rid (ayout.
onchan,e nu(( Strin, *a((bac3 to e0ecute on va(ue chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container.
tabinde0 nu(( Strin, S&eci+ie the tab order o+ e(e"ent in tab navi,ation.
&(ain +a(e 1oo(ean !(ain "ode di&(ay radiobutton uin, native
bro'er renderin, intead o+ the"e.
)ettin& started with Select;ne"adio
Se(ect7neRadio ua,e i a"e a the tandard one.
$ustom *ayout
Standard e(ect7neRadio co"&onent on(y u&&ort hori=onta( and vertica( renderin, o+ the radio
button 'ith a trict tab(e "ar3u&. !ri"e#ace Se(ect7neRadio on the other hand &rovide a
+(e0ib(e (ayout o&tion o that radio button can be (ocated any'here on the &a,e. 9hi i
i"&(e"ented by ettin, (ayout o&tion to cuto" and 'ith tanda(one radio1utton co"&onent. <ote
that in cuto" "odeE e(ect7neRadio ite(+ doe not render any out&ut.
<p:selectOneCadio id'(customCadio( value'(./form=ean.option0( layout'(custom(>
<f:selectItem item7a-el'(Option *( item@alue'(*( />
<f:selectItem item7a-el'(Option A( item@alue'(A( />
<f:selectItem item7a-el'(Option )( item@alue'()( />
</p:selectOneCadio>
417
PrimeFaces Users Guide
<h:panelIrid columns'()(>
<p:radio=utton id'(opt*( for'(customCadio( itemInde&'(0(/>
<h:output7a-el for'(opt*( value'(Option *( />
<p:spinner />
<p:radio=utton id'(optA( for'(customCadio( itemInde&'(*(/>
<h:output7a-el for'(optA( value'(Option A( />
<p:input!e&t />
<p:radio=utton id'(opt)( for'(customCadio( itemInde&'(A(/>
<h:output7a-el for'(opt)( value'(Option )( />
<p:calendar />
</h:panelIrid>
Radio1utton +or attribute hou(d re+er to a e(ect7neRadio co"&onent and ite"Inde0 &oint to the
inde0 o+ the e(ectIte". When uin, cuto" (ayout o&tionE e(ect7neRadio co"&onent hou(d be
&(aced above any radio1utton that &oint to the e(ect7neRadio.
S+innin&
Se(ect7neRadio reide in a "ain container 'hich style and styleClass attribute a&&(y. A 3innin,
ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBe(ectoneradio 8ain container e(e"ent.
.uiBradiobutton *ontainer o+ a radio button.
.uiBradiobuttonBbo0 *ontainer o+ radio button icon.
.uiBradiobuttonBicon Radio button icon.
418
PrimeFaces Users Guide
#.1:8 Separator
Se&erator di&(ay a hori=onta( (ine to e&arate content.
In%o
9a, separator
*o"&onent *(a org.primefaces.component.separator.)eparator
*o"&onent 9y&e org.primefaces.component.)eparator
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)eparator
Renderer *(a org.primefaces.component.separator.)eparator
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
ty(e nu(( Strin, In(ine ty(e o+ the e&arator.
ty(e*(a nu(( Strin, Sty(e c(a o+ the e&arator.
)ettin& started with Separator
In it i"&(et +or"E e&arator i ued aK
//content
<p:separator />
//content
Dimensions
Se&arator render a @hr AB ta, 'hich ty(e and ty(e*(a o&tion a&&(y.
419
PrimeFaces Users Guide
<p:separator style'(width:500p&;height:A0p&( />
Special Separators
Se&arator can be ued inide other co"&onent uch a "enu 'hen u&&orted.
<p:menu>
//su-menu or menuitem
<p:separator />
//su-menu or menuitem
</p:menu>
S+innin&
A "entioned in di"enion ectionE ty(e and ty(e*(a o&tion can be ued to ty(e the e&arator.
#o((o'in, i the (it o+ tructura( ty(e c(aeK
#lass Applies
.uiBe&arator Se&arator e(e"ent
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
420
PrimeFaces Users Guide
#.11: SlideMenu
S(ide8enu i ued to di&(ay neted ub"enu 'ith (idin, ani"ation.
In%o
9a, slide!enu
*o"&onent *(a org.primefaces.component.slidemenu.)lide!enu
*o"&onent 9y&e org.primefaces.component.)lide!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)lide!enuenderer
Renderer *(a org.primefaces.component.slidemenu.)lide!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ode( nu(( 8enu8ode( 8enu8ode( intance +or &ro,ra""atic "enu.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
bac36abe( 1ac3 Strin, 9e0t +or bac3 (in3.
tri,,er nu(( Strin, Id o+ the co"&onent 'hoe tri,,erEvent 'i(( ho'
the dyna"ic &oitioned "enu.
"y nu(( Strin, *orner o+ "enu to a(i,n 'ith tri,,er e(e"ent.
421
PrimeFaces Users Guide
Name Default Type Description
at nu(( Strin, *orner o+ tri,,er to a(i,n 'ith "enu e(e"ent.
over(ay +a(e 1oo(ean De+ine &oitionin,E 'hen enab(ed "enu i
di&(ayed 'ith abo(ute &oition re(ative to the
tri,,er. De+au(t i +a(eE "eanin, tatic &oitionin,.
tri,,erEvent c(ic3 Strin, Event na"e o+ tri,,er that 'i(( ho' the dyna"ic
&oitioned "enu.
)ettin& started with the SlideMenu
S(ide8enu conit o+ ub"enu and "enuite"E ub"enu can be neted and each neted ub"enu
'i(( be di&(ayed 'ith a (ide ani"ation.
<p:slide5enu>
<p:su-menu la-el'(<,a& 5enuitems( icon'(ui3icon3refresh(>
<p:menuitem value'(8ave( action7istener'(./-utton=ean.save0(
update'(messages( icon'(ui3icon3dis2( />
<p:menuitem value'(Kpdate( action7istener'(./-utton=ean.update0(
update'(messages( icon'(ui3icon3arrowrefresh3*3w( />
</p:su-menu>
<p:su-menu la-el'(Jon3<,a& 5enuitem( icon'(ui3icon3newwin(>
<p:menuitem value'(Delete( action7istener'(./-utton=ean.delete0(
update'(messages( a,a&'(false( icon'(ui3icon3close(/>
</p:su-menu>
<p:separator />
<p:su-menu la-el'(Javigations( icon'(ui3icon3e&tlin2(>
<p:su-menu la-el'(#rime 7in2s(>
<p:menuitem value'(#rime( url'(http://www.prime.com.tr( />
<p:menuitem value'(#rime6aces( url'(http://www.primefaces.org( />
</p:su-menu>
<p:menuitem value'(5o-ile( url'(/mo-ile( />
</p:su-menu>
</p:slide5enu>
;erlay
S(ide8enu can be &oitioned re(ative to a tri,,er co"&onentE +o((o'in, a"&(e attache a
(ide8enu to the button o that 'henever the button i c(ic3ed "enu 'i(( be di&(ayed in an over(ay
ite(+.
<p:command=utton type'(-utton( value'(8how( id'(-tn( />
<p:slide5enu trigger'(-tn( my'(left top( at'(left -ottom(>
//content
</p:slide5enu>
422
PrimeFaces Users Guide
$lient Side API
Wid,etN PrimeFaces.widget.Slide-enu
!et"od Params eturn Type Description
ho'?@ B void Sho' over(ay "enu.
hide?@ B void .ide over(ay "enu.
a(i,n?@ B void A(i,n over(ay "enu 'ith tri,,er.
S+innin&
S(ide8enu reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB"enu .uiB(ide"enu *ontainer e(e"ent o+ "enu.
.uiB(ide"enuB'ra&&er Wra&&er e(e"ent +or content.
.uiB(ide"enuBcontent *ontent container.
.uiB(ide"enuBbac3'ard 1ac3 navi,ator.
.uiB"enuB(it 6it container
.uiB"enuite" Each "enu ite"
.uiB"enuite"B(in3 Anchor e(e"ent in a (in3 ite"
.uiB"enuite"Bte0t 9e0t e(e"ent in an ite"
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
423
PrimeFaces Users Guide
#.111 Slider
S(ider i ued to &rovide in&ut 'ith variou cuto"i=ation o&tion (i3e orientationE di&(ay "ode
and 3innin,.
In%o
9a, slider
*o"&onent *(a org.primefaces.component.slider.)lider
*o"&onent 9y&e org.primefaces.component.)lider
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)liderenderer
Renderer *(a org.primefaces.component.slider.)liderenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
+or nu(( Strin, Id o+ the in&ut te0t that the (ider 'i(( be ued +or
di&(ay nu(( Strin, Id o+ the co"&onent to di&(ay the (ider va(ue.
"in>a(ue 0 Inte,er 8ini"u" va(ue o+ the (ider
"a0>a(ue 100 Inte,er 8a0i"u" va(ue o+ the (ider
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent
ani"ate true 1oo(ean 1oo(ean va(ue to enab(eQdiab(e the ani"ated "ove 'hen
bac3,round o+ (ider i c(ic3ed
ty&e hori=onta( Strin, Set the ty&e o+ the (iderE Ihori=onta(I or Ivertica(I.
te& 1 Inte,er #i0ed &i0e( incre"ent that the (ider "ove in
diab(ed 0 1oo(ean Diab(e or enab(e the (ider.
onS(ideStart nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (ide be,in.
424
PrimeFaces Users Guide
Name Default Type Description
onS(ide nu(( Strin, *(ient ide ca((bac3 to e0ecute durin, (idin,.
onS(ideEnd nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen (ide end.
ran,e +a(e 1oo(ean When enab(edE t'o hand(e are &rovided +or e(ection a
ran,e.
di&(ay9e"&(ate nu(( Strin, Strin, te"&(ate to ue 'hen u&datin, the di&(ay. >a(id
&(aceho(der are Vva(ueWE V"inW and V"a0W.
)ettin& started with Slider
S(ider reCuire an in&ut co"&onent to 'or3 'ithE for attribute i ued to et the id o+ the in&ut
co"&onent 'hoe in&ut 'i(( be &rovided by the (ider.
pu-lic class 8lider=ean /
private int num-er;
pu-lic int getJum-er9: /
return num-er;
0
pu-lic void setJum-er9int num-er: /
this.num-er ' num-er;
0
0
<h:input!e&t id'(num-er( value'(./slider=ean.num-er0( />
<p:slider for'(num-er( />
Display <alue
Uin, display +eatureE you can &reent a readon(y di&(ay va(ue and ti(( ue (ider to &rovide in&utE
in thi cae for hou(d re+er to a hidden in&ut to bind the va(ue.
<h:input4idden id'(num-er( value'(./slider=ean.num-er0( />
<h:output!e&t value'(8et ratio to F( />
<h:output!e&t id'(output( value'(./slider=ean.num-er0( />
<p:slider for'(num-er( display'(output( />
425
PrimeFaces Users Guide
<ertical Slider
1y de+au(t (ider orientation i hori=onta(E vertica( (idin, i a(o u&&orted and can be et uin,
the type attribute.
<h:input!e&t id'(num-er( value'(./sliderontroller.num-er0( />
<p:slider for'(num-er( type'(vertical( min@alue'(0( ma&@alue'(A00(/>
Step
Ste& +actor de+ine the interva( bet'een each &oint durin, (idin,. De+au(t va(ue i one and it i
cuto"i=ed uin, step o&tion.
<h:input!e&t id'(num-er( value'(./slider=ean.num-er0( />
<p:slider for'(num-er( step'(*0( />
Animation
S(idin, i ani"ated by de+au(tE i+ you 'ant to turn it o+ ani"ate attribute et the animate o&tion to
+a(e.
.oundaries
8a0i"u" and "ini"u" boundarie +or the (idin, i de+ined uin, "in>a(ue and "a0>a(ue
attribute. #o((o'in, (ider can (ide bet'een B100 and H100.
<h:input!e&t id'(num-er( value'(./slider=ean.num-er0( />
<p:slider for'(num-er( min@alue'(3*00( ma&@alue'(*00(/>
"an&e Slider
Se(ectin, a ran,e 'ith "inB"a0 va(ue are u&&orted by (ider. 9o enab(e thi +eatureE et range
attribute to true and &rovide a co""a e&arate &air o+ in&ut +ie(d to attach "inB"a0 va(ue.
#o((o'in, a"&(e de"ontrate a ran,e (ider a(on, 'ith the di&(ay te"&(ate +eature +or +eedbac3K
426
PrimeFaces Users Guide
<h:output!e&t id'(displayCange(
value'(=etween ./slider=ean.num-erU0 and ./slider=ean.num-erP0(/>
<p:slider for'(t&tUHt&tP( display'(displayCange( style'(width:E00p&( range'(true(
display!emplate'(=etween /min0 and /ma&0(/>
<h:input4idden id'(min( value'(./slider=ean.min0( />
<h:input4idden id'(ma&( value'(./slider=ean.ma&0( />
$lient Side $allbac+s
S(ider &rovide three ca((bac3 to hoo3Bin your cuto" /avacri&tE onS(ideStartE onS(ide and
onS(ideEnd. A(( o+ thee ca((bac3 receive t'o &ara"eterK (ide event and the ui ob/ect containin,
in+or"ation about the event.
<h:input!e&t id'(num-er( value'(./slider=ean.num-er0( />
<p:slider for'(num-er( on8lide$nd'(handle8lide$nd9eventH ui:(/>
function handle8lide$nd9eventH ui: /
//ui.helper ' 4andle element of slider
//ui.value ' urrent value of slider
0
A,a- .ehaior /ents
S(ider &rovide one a/a0 behavior event ca((ed slideEnd that i +ired 'hen the (ide co"&(ete. I+
you have a (itener de+inedE it 'i(( be ca((ed by &ain, org.primefaces.event.SlideEndEvent
intance. E0a"&(e be(o' add a "ea,e and di&(ay it uin, ,ro'( co"&onent 'hen (ide end.
<h:input!e&t id'(num-er( value'(./slider=ean.num-er0( />
<p:slider for'(num-er(>
<p:a,a& event'(slide$nd( listener'(./slider=ean.on8lide$nd0( update'(msgs( />
</p:slider>
<p:messages id'(msgs( />
427
PrimeFaces Users Guide
pu-lic class 8lider=ean /
private int num-er;
pu-lic int getJum-er9: /
return num-er;
0
pu-lic void setJum-er9int num-er: /
this.num-er ' num-er;
0
pu-lic void on8lide$nd98lide$nd$vent event: /
int value ' event.get@alue9:;
//add faces message
0
0
$lient Side API
Wid,etN PrimeFaces.widget.Slider
!et"od Params eturn Type Description
,et>a(ue?@ B <u"ber Return the current va(ue
et>a(ue?va(ue@ va(ueN >a(ue to et void U&date (ider va(ue 'ith
&rovided one.
diab(e?@ inde0N Inde0 o+ tab to diab(e void Diab(e (ider.
enab(e?@ inde0N Inde0 o+ tab to enab(e void Enab(e (ider.
S+innin&
S(ider reide in a "ain container 'hich style and styleClass attribute a&&(y. 9hee attribute are
handy to &eci+y the di"enion o+ the (ider. #o((o'in, i the (it o+ tructura( ty(e c(aeK
#lass Applies
.uiB(ider 8ain container e(e"ent
.uiB(iderBhori=onta( 8ain container e(e"ent o+ hori=onta( (ider
.uiB(iderBvertica( 8ain container e(e"ent o+ vertica( (ider
.uiB(iderBhand(e S(ider hand(e
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
428
PrimeFaces Users Guide
#.112 Spotli&ht
S&ot(i,ht hi,h(i,ht a certain co"&onent on &a,e.
In%o
9a, spotlig"t
*o"&onent *(a org.primefaces.component.spotlig"t.)potlig"t
*o"&onent 9y&e org.primefaces.component.)potlig"t
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)potlig"tenderer
Renderer *(a org.primefaces.component.spotlig"t.)potlig"tenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered +a(e 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
tar,et nu(( Strin, *o"&onent to hi,h(i,ht.
ani"ate true 1oo(ean *ontro( ani"ation ued durin, hi,h(i,ht.
429
PrimeFaces Users Guide
)ettin& started with Spotli&ht
S&ot(i,ht i acceed uin, c(ient ide a&i. *(ic3in, the button hi,h(i,ht the &ane( be(o'K
<p:panel id'(pnl( header'(#anel(>
//content
</p:panel>
<p:command=utton value'(4ighlight( onclic2'(#69?spot?:.show9:( />
<p:spotlight target'(pnl( widget@ar'(spot( />
$lient Side API
Wid,etN PrimeFaces.widget.Spotlight
!et"od Params eturn Type Description
ho'?@ B void .i,h(i,ht tar,et.
hide?@ B void Re"ove hi,h(i,ht.
S+innin&
S(ider reide in a "ain container 'hich style and styleClass attribute a&&(y. 9hee attribute are
handy to &eci+y the di"enion o+ the (ider. A 3innin, ty(e c(ae are ,(oba(E ee the "ain
the"in, ection +or "ore in+or"ation. #o((o'in, i the (it o+ tructura( ty(e c(aeK
#lass Applies
.uiB&ot(i,ht 8a3 e(e"entE co""on to a(( re,ion.
.uiB&ot(i,htBto& 9o& "a3 e(e"ent.
.uiB&ot(i,htBbotto" 1otto" "a3 e(e"ent.
.uiB&ot(i,htB(e+t 6e+t "a3 e(e"ent.
.uiB&ot(i,htBri,ht Ri,ht "a3 e(e"ent.
430
PrimeFaces Users Guide
#.11' Soc+et
Soc3et co"&onent i an a,ent that create a &uh channe( bet'een the erver and the c(ient.
In%o
9a, soc,et
*o"&onent *(a org.primefaces.component.soc,et.)oc,et
*o"&onent 9y&e org.primefaces.component.)oc,et
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)oc,etenderer
Renderer *(a org.primefaces.component.soc,et.)oc,etenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
channe( nu(( 7b/ect *hanne( na"e o+ the connection.
tran&ort 'eboc3et Strin, Deired &rotoco( to be ued va(id va(ue are
'eboc3et ?de+au(t@E eE trea"in,E (on,B&o((in,E
/on&.
+a((bac39ran&ort (on,B&o((in, Strin, #a((bac3 &rotoco( to be ued 'hen deired tran&ort
i not u&&orted in environ"entE va(id va(ue are
'eboc3etE eE trea"in,E (on,B&o((in, ?de+au(t@E
/on&.
on8ea,e nu(( Strin, Aavacri&t event hand(er that i &roceed 'hen
erver &ub(ihe data.
onError nu(( Strin, Aavacri&t event hand(er that i &roceed 'hen
there i an error.
on*(oe nu(( Strin, Aavacri&t event hand(er +or on*(oe ca((bac3 o+
at"o&here.
on7&en nu(( Strin, Aavacri&t event hand(er +or on7&en ca((bac3 o+
at"o&here.
onReconnect nu(( Strin, Aavacri&t event hand(er +or onReconnect ca((bac3
o+ at"o&here.
431
PrimeFaces Users Guide
Name Default Type Description
on8ea,e!ub(ihed nu(( Strin, Aavacri&t event hand(er +or on8ea,e!ub(ihed
ca((bac3 o+ at"o&here.
on9ran&ort#ai(ure nu(( Strin, Aavacri&t event hand(er +or on9ran&ort#ai(ure
ca((bac3 o+ at"o&here.
on6oca(8ea,e nu(( Strin, Aavacri&t event hand(er +or on6oca(8ea,e
ca((bac3 o+ at"o&here.
auto*onnect true 1oo(ean *onnect to channe( on &a,e (oad 'hen enab(ed.
)ettin& Started with the Soc+et
See cha&ter 5E I!ri"e#ace !uhI +or detai(ed in+or"ation.
432
PrimeFaces Users Guide
#.113 Spacer
S&acer i ued to &ut &ace bet'een e(e"ent.
In%o
9a, spacer
*o"&onent *(a org.primefaces.component.spacer.)pacer
*o"&onent 9y&e org.primefaces.component.)pacer
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)pacerenderer
Renderer *(a org.primefaces.component.spacer.)pacerenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
ty(e nu(( Strin, In(ine ty(e o+ the &acer.
ty(e*(a nu(( Strin, Sty(e c(a o+ the &acer.
'idth nu(( Strin, Width o+ the &ace.
hei,ht nu(( Strin, .ei,ht o+ the &ace.
)ettin& started with Spacer
S&acer i ued by either &eci+yin, 'idth or hei,ht o+ the &ace.
8pacer in this e&le separates this te&t <p:spacer width'(*00( height'(*0(> and
<p:spacer width'(*00( height'(*0(> this te&t.
433
PrimeFaces Users Guide
#.115 Spinner
S&inner i an in&ut co"&onent to &rovide a nu"erica( in&ut via incre"ent and decre"ent button.
In%o
9a, spinner
*o"&onent *(a org.primefaces.component.spinner.)pinner
*o"&onent 9y&e org.primefaces.component.)pinner
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)pinnerenderer
Renderer *(a org.primefaces.component.spinner.)pinnerenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
i""ediate +a(e 1oo(ean 1oo(ean va(ue that &eci+ie the (i+ecyc(e &hae the
va(ue*han,eEvent hou(d be &roceedE 'hen true
the event 'i(( be +ired at Ia&&(y reCuet va(ueIE i+
i""ediate i et to +a(eE va(ue*han,e Event are
+ired in I&roce va(idationI
&hae
reCuired #a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a
"ethod va(idation, the in&ut
434
PrimeFaces Users Guide
Name Default Type Description
va(ue*han,e6itener nu(( 8ethod
E0&r
A "ethod bindin, e0&reion that re+er to a
"ethod +or hand(in, a va(uchan,eevent
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d
va(idation +ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
te&#actor 1 Doub(e Ste&&in, +actor +or each incre"ent and decre"ent
"in nu(( Doub(e 8ini"u" boundary va(ue
"a0 nu(( Doub(e 8a0i"u" boundary va(ue
&re+i0 nu(( Strin, !re+i0 o+ the in&ut
u++i0 nu(( Strin, Su++i0 o+ the in&ut
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the
in&ut e(e"ent.
a(t nu(( Strin, A(ternate te0tua( decri&tion o+ the in&ut +ie(d.
autoco"&(ete nu(( Strin, *ontro( bro'er autoco"&(ete behavior.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
diab(ed +a(e 1oo(ean Diab(e in&ut +ie(d
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated
"ar3u& +or thi co"&onent.
"a0(en,th nu(( Inte,er 8a0i"u" nu"ber o+ character that "ay be
entered in thi +ie(d.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
(oe +ocu.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
(oe +ocu and it va(ue ha been "odi+ied ince
,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
i c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
i doub(e c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen in&ut e(e"ent
receive +ocu.
435
PrimeFaces Users Guide
Name Default Type Description
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
&reed do'n over in&ut e(e"ent.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
&reed and re(eaed over in&ut e(e"ent.
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i
re(eaed over in&ut e(e"ent.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i &reed do'n over in&ut e(e"ent
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved 'ithin in&ut e(e"ent.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved a'ay +ro" in&ut e(e"ent.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i "oved onto in&ut e(e"ent.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer
button i re(eaed over in&ut e(e"ent.
one(ect nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen te0t 'ithin
in&ut e(e"ent i e(ected by uer.
&(aceho(der nu(( Strin, S&eci+ie a hort hint.
readon(y +a(e 1oo(ean #(a, indicatin, that thi co"&onent 'i(( &revent
chan,e by the uer.
i=e nu(( Inte,er <u"ber o+ character ued to deter"ine the 'idth
o+ the in&ut e(e"ent.
ty(e nu(( Strin, In(ine ty(e o+ the in&ut e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the in&ut e(e"ent.
tabinde0 nu(( Inte,er !oition o+ the in&ut e(e"ent in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"aton.
)ettin& Started with Spinner
S&inner i an in&ut co"&onent and ued /ut (i3e a tandard in&ut te0t.
pu-lic class 8pinner=ean /
private int num-er;
//getter and setter
0
<p:spinner value'(./spinner=ean.num-er0( />
436
PrimeFaces Users Guide
Step Factor
7ther than inte,erE &inner a(o u&&ort deci"a( o the +ractiona( &art can be contro((er 'ith
&inner a 'e((. #or deci"a( ue the te&#actor attribute to &eci+y te&&in, a"ount. #o((o'in,
e0a"&(e ue a te&#actor 0.%5.
<p:spinner value'(./spinner=ean.num-er0( step6actor'(0.A5(/>
pu-lic class 8pinner=ean /
private dou-le num-er;
//getter and setter
0
7ut&ut o+ thi &inner 'ou(d beK
A+ter an incre"ent ha&&en a cou&(e o+ ti"e.
Pre%i- and Su%%i-
!re+i0 and Su++i0 o&tion enab(e &(acin, +i0ed trin, on in&ut +ie(d. <ote that you 'ou(d need to
ue a converter to avoid converion error ince &re+i0Qu++i0 'i(( a(o be &oted.
<p:spinner value'(./spinner=ean.num-er0( prefi&'(V( />
.oundaries
In order to retrict the boundary va(ueE ue min and ma$ o&tion.
<p:spinner value'(./spinner=ean.num-er0( min'(0( ma&'(*00(/>
A,a- Spinner
S&inner can be a/a0i+ied uin, c(ient behavior (i3e +Na/a0 or &Na/a0. In e0a"&(e be(o'E an a/a0
reCuet i done to u&date the out&utte0t 'ith ne' va(ue 'henever a &inner button i c(ic3ed.
<p:spinner value'(./spinner=ean.num-er0(>
<p:a,a& update'(display( />
</p:spinner>
<h:output!e&t id'(display( value'(./spinner=ean.num-er0( />
437
PrimeFaces Users Guide
S+innin&
S&inner reide in a container e(e"ent that uin, style and styleClass a&&(ie. #o((o'in, i the (it o+
tructura( ty(e c(aeK
#lass Applies
.uiB&inner 8ain container e(e"ent o+ &inner
.uiB&innerBin&ut In&ut +ie(d
.uiB&innerBbutton S&inner button
.uiB&innerBbuttonBu& Incre"ent button
.uiB&innerBbuttonBdo'n Decre"ent button
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
438
PrimeFaces Users Guide
#.116 Split.utton
S&(it1utton di&(ay a co""and by de+au(t and additiona( one in an over(ay.
In%o
9a, split%utton
*o"&onent *(a org.primefaces.component.split&utton.)plit%utton
*o"&onent 9y&e org.primefaces.component.)plit%utton
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)plit%uttonenderer
Renderer *(a org.primefaces.component.split&utton.)plit%uttonenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
va(ue nu(( Strin, 6abe( +or the button
action nu(( 8ethodE0&rQ
Strin,
A "ethod e0&reion or a Strin, outco"e thatd be
&roceed 'hen button i c(ic3ed.
action6itener nu(( 8ethodE0&r An action(itener thatd be &roceed 'hen button i
c(ic3ed.
i""ediate +a(e 1oo(ean 1oo(ean va(ue that deter"ine the &haeIdE 'hen true
action are &roceed at a&&(yLreCuetLva(ueE 'hen
+a(e at invo3eLa&&(ication &hae.
ty&e ub"it Strin, Set the behavior o+ the button.
a/a0 true 1oo(ean S&eci+ie the ub"it "odeE 'hen et to true?de+au(t@E
ub"it 'ou(d be "ade 'ith A/a0.
439
PrimeFaces Users Guide
Name Default Type Description
aync +a(e 1oo(ean When et to trueE a/a0 reCuet are not Cueued.
&roce nu(( Strin, *o"&onent?@ to &roce &artia((y intead o+ 'ho(e vie'.
u&date nu(( Strin, *o"&onent?@ to be u&dated 'ith a/a0.
ontart nu(( Strin, *(ient ide ca((bac3 to e0ecute be+ore a/a0 reCuet i
be,in.
onco"&(ete nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet i
co"&(eted.
onucce nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet
ucceed.
onerror nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a/a0 reCuet +ai(.
,(oba( true 1oo(ean De+ine 'hether to tri,,er a/a0Statu or not.
de(ay nu(( Strin, I+ (e than delay "i((iecond e(a&e bet'een ca(( to
request! on(y the "ot recent one i ent and a(( other
reCuet are dicarded. I+ thi o&tion i not &eci+iedE or i+
the va(ue o+ delay i the (itera( trin, OnoneO 'ithout the
CuoteE no de(ay i ued.
&artia(Sub"it +a(e 1oo(ean Enab(e eria(i=ation o+ va(ue be(on,in, to the &artia((y
&roceed co"&onent on(y.
reet>a(ue +a(e 1oo(ean I+ trueE (oca( va(ue o+ in&ut co"&onent to be u&dated
'ithin the a/a0 reCuet 'ou(d be reet.
i,noreAutoU&date +a(e 1oo(ean I+ trueE co"&onent 'hich autoU&datePItrueI 'i(( not be
u&dated +or thi reCuet. I+ not &eci+iedE or the va(ue i
+a(eE no uch indication i "ade.
ty(e nu(( Strin, In(ine ty(e o+ the button e(e"ent.
ty(e*(a nu(( Strin, Sty(e*(a o+ the button e(e"ent.
onb(ur nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button (oe +ocu
and it va(ue ha been "odi+ied ince ,ainin, +ocu.
onc(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i c(ic3ed.
ondb(c(ic3 nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button i doub(e
c(ic3ed.
on+ocu nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen button receive
+ocu.
on3eydo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed
do'n over button.
on3ey&re nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i &reed and
re(eaed over button.
440
PrimeFaces Users Guide
Name Default Type Description
on3eyu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a 3ey i re(eaed
over button.
on"ouedo'n nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
&reed do'n over button.
on"oue"ove nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved 'ithin button.
on"oueout nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved a'ay +ro" button.
on"oueover nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
"oved onto button.
on"oueu& nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a &ointer button i
re(eaed over button.
one(ect nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen te0t 'ithin button i
e(ected by uer.
acce3ey nu(( Strin, Acce 3ey that 'hen &reed tran+er +ocu to the
button.
a(t nu(( Strin, A(ternate te0tua( decri&tion o+ the button.
dir nu(( Strin, Direction indication +or te0t that doe not inherit
directiona(ity. >a(id va(ue are 69R and R96.
diab(ed +a(e 1oo(ean Diab(e the button.
i"a,e nu(( Strin, Sty(e c(a +or the button icon. ?de&recatedN ue icon@
(abe( nu(( Strin, A (oca(i=ed uer &reentab(e na"e.
(an, nu(( Strin, *ode decribin, the (an,ua,e ued in the ,enerated
"ar3u& +or thi co"&onent.
tabinde0 nu(( Inte,er !oition o+ the button e(e"ent in the tabbin, order.
tit(e nu(( Strin, Adviory too(ti& in+or"ation.
readon(y +a(e 1oo(ean #(a, indicatin, that thi co"&onent 'i(( &revent chan,e
by the uer.
icon nu(( Strin, Icon o+ the button a a c c(a.
icon!o (e+t Strin, !oition o+ the icon.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
a&&end9o nu(( Strin, A&&end the over(ay to the e(e"ent de+ined by earch
e0&reion. De+au(t to docu"ent body.
441
PrimeFaces Users Guide
)ettin& started with Split.utton
S&(it1utton ua,e i i"i(ar to a re,u(ar co""and1utton. Additiona( co""and are &(aced inide
the co"&onent and di&(ayed in an over(ay. In e0a"&(e be(o'E c(ic3in, the ave button invo3e ave
"ethod o+ the bean and u&date "ea,e. <eted o&tion de+ined a "enuite" do a/a0E nonBa/a0
reCuet a 'e(( a re,u(ar navi,ation to an e0terna( ur(.
<p:split=utton value'(8ave( action7istener'(./-utton=ean.save0( update'(messages(
icon'(ui3icon3dis2(>
<p:menuitem value'(Kpdate( action7istener'(./-utton=ean.update0(
update'(messages( icon'(ui3icon3arrowrefresh3*3w(/>
<p:menuitem value'(Delete( action7istener'(./-utton=ean.delete0( a,a&'(false(
icon'(ui3icon3close(/>
<p:separator />
<p:menuitem value'(4omepage( url'(http://www.primefaces.org(
icon'(ui3icon3e&tlin2(/>
</p:split=utton>
$lient Side API
Wid,etN PrimeFaces.widget.Split)utton
!et"od Params eturn Type Description
ho'?@ B void Di&(ay over(ay.
hide?@ B void .ide over(ay.
S+innin&
S&(it1utton render a container e(e"ent 'hich style and styleClass a&&(ie. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiB&(itbutton *ontainer e(e"ent.
.uiBbutton 1utton e(e"ent
.uiB&(itbuttonB"enubutton Dro&do'n button
.uiBbuttonBte0tBon(y 1utton e(e"ent 'hen icon i not ued
.uiBbuttonBte0t 6abe( o+ button
.uiB"enu *ontainer e(e"ent o+ "enu
.uiB"enuB(it 6it container
.uiB"enuite" Each "enu ite"
.uiB"enuite"B(in3 Anchor e(e"ent in a (in3 ite"
.uiB"enuite"Bte0t 9e0t e(e"ent in an ite"
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
442
PrimeFaces Users Guide
#.117 Submenu
Sub"enu i neted in "enu co"&onent and re&reent a ub "enu ite".
In%o
9a, su&menu
*o"&onent *(a org.primefaces.component.su&menu.)u&menu
*o"&onent 9y&e org.primefaces.component.)u&menu
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
(abe( nu(( Strin, 6abe( o+ the ub"enu header.
icon nu(( Strin, Icon o+ a ub"enuE ee "enuite" to ee ho' it i ued
ty(e nu(( Strin, In(ine ty(e o+ the ub"enu.
ty(e*(a nu(( Strin, Sty(e c(a o+ the ub"enu.
)ettin& started with Submenu
!(eae ee 8enu or 8enubar ection to +ind out ho' ub"enu i ued 'ith the "enu.
443
PrimeFaces Users Guide
#.118 Stac+
Stac3 i a navi,ation co"&onent that "i"ic the tac3 +eature in 8ac 7S F.
In%o
9a, stac,
*o"&onent *(a org.primefaces.component.stac,.)tac,
*o"&onent 9y&e org.primefaces.component.)tac,
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)tac,enderer
Renderer *(a org.primefaces.component.stac,.)tac,enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean.
icon nu(( Strin, An o&tiona( i"a,e to contain tac3ed ite".
o&enS&eed )00 Strin, S&eed o+ the ani"ation 'hen o&enin, the tac3.
c(oeS&eed )00 Inte,er S&eed o+ the ani"ation 'hen o&enin, the tac3.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ode( nu(( 8enu8ode( 8enu8ode( intance to create "enu &ro,ra""atica((y
e0&anded +a(e 1oo(ean Whether to di&(ay tac3 a e0&anded or not.
444
PrimeFaces Users Guide
)ettin& started with Stac+
Each ite" in the tac3 i re&reented 'ith "enuite". Stac3 be(o' ha +ive ite" 'ith di++erent
icon and (abe(.
<p:stac2 icon'(/images/stac2/stac2.png(>
<p:menuitem value'(<perture( icon'(/images/stac2/aperture.png( url'(.(/>
<p:menuitem value'(#hotoshop( icon'(/images/stac2/photoshop.png( url'(.(/>
//...
</p:stac2>
Initia((y tac3 'i(( be rendered in co((a&ed "odeK
*ocation
Stac3 i a +i0ed &oitioned e(e"ent and (ocation can be chan,e via c. 9here one i"&ortant c
e(ector +or tac3 ca((ed .ui1stac". 7verride thi ty(e to chan,e the (ocation o+ tac3.
.ui3stac2 /
-ottom: AGp&;
right: E0p&;
0
Dynamic Menus
8enu can be created &ro,ra""atica((y a 'e((E ee the dyna"ic "enu &art in "enu co"&onent
ection +or "ore in+or"ation and an e0a"&(e.
S+innin&
#lass Applies
.uiBtac3 8ain container e(e"ent o+ tac3
.uiBtac3 u( (i Each ite" in tac3
.uiBtac3 u( (i i", Icon o+ a tac3 ite"
.uiBtac3 u( (i &an 6abe( o+ a tac3 ite"
445
PrimeFaces Users Guide
#.12: Stic+y
Stic3y co"&onent &oition other co"&onent a +i0ed o that thee co"&onent tay in 'indo'
vie'&ort durin, cro((in,.
In%o
9a, stic,y
*o"&onent *(a org.primefaces.component.stic,y.)tic,y
*o"&onent 9y&e org.primefaces.component.)tic,y
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)tic,yenderer
Renderer *(a org.primefaces.component.stic,y.)tic,yenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean.
tar,et nu(( Strin, *o"&onent to "a3e tic3y.
"ar,in 0 Inte,er 8ar,in to the to& o+ the &a,e durin, +i0ed cro((in,.
446
PrimeFaces Users Guide
)ettin& started with Stic+y
Stic3y reCuire a tar,et to 3ee& in vie'&ort on cro((. .ere i a tic3y too(barK
<p:tool-ar id'(t-(>
<p:tool-arIroup align'(left(>
<p:command=utton type'(-utton( value'(Jew( icon'(ui3icon3document( />
<p:command=utton type'(-utton( value'(Open( icon'(ui3icon3folder3open(/>
<p:separator />
<p:command=utton type'(-utton( title'(8ave( icon'(ui3icon3dis2(/>
<p:command=utton type'(-utton( title'(Delete( icon'(ui3icon3trash(/>
<p:command=utton type'(-utton( title'(#rint( icon'(ui3icon3print(/>
</p:tool-arIroup>
</p:tool-ar>
<p:stic2y target'(t-( />
S+innin&
9here are no viua( ty(e o+ tic3y ho'everE ui1stic"y c(a i a&&(ied to the tar,et 'hen the &oition
i +i0ed. When tar,et i retored to it ori,ina( (ocation thi i re"oved.
447
PrimeFaces Users Guide
#.121 Sub1able
Sub9ab(e i a he(&er co"&onent o+ datatab(e ued +or ,rou&in,.
In%o
9a, su&Ta&le
*o"&onent *(a org.primefaces.component.su&ta&le.)u&Ta&le
*o"&onent 9y&e org.primefaces.component.)u&Ta&le
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)u&Ta&leenderer
Renderer *(a org.primefaces.component.su&ta&le.)u&Ta&leenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
va(ue nu(( 7b/ect Data o+ the co"&onent.
var nu(( Strin, <a"e o+ the data iterator.
)ettin& started with Sub1able
See Data9ab(e ection +or "ore in+or"ation.
448
PrimeFaces Users Guide
#.122 Summary"ow
Su""aryRo' i a he(&er co"&onent o+ datatab(e ued +or dyna"ic ,rou&in,.
In%o
9a, summaryo0
*o"&onent *(a org.primefaces.component.summaryro0.)ummaryo0
*o"&onent 9y&e org.primefaces.component.)ummaryo0
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.)ummaryo0enderer
Renderer *(a org.primefaces.component.summaryro0.)ummaryo0enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
(itener nu(( 8ethodE0&r 8ethod e0&reion to e0ecute be+ore renderin, u""ary
ro'. ?e.,. to ca(cu(ate tota(@.
)ettin& started with Summary"ow
See Data9ab(e ection +or "ore in+or"ation.
449
PrimeFaces Users Guide
#.12# 1ab
9ab i a ,eneric container co"&onent ued by other !ri"e#ace co"&onent uch a tab>ie' and
accordion!ane(.
In%o
9a, ta&
*o"&onent *(a org.primefaces.component.Ta&Vie0.Ta&
*o"&onent 9y&e org.primefaces.component.Ta&
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
tit(e nu(( 1oo(ean 9it(e te0t o+ the tab
tit(eSty(e nu(( Strin, In(ine ty(e o+ the tab.
tit(eSty(e*(a nu(( Strin, Sty(e c(a o+ the tab.
diab(ed +a(e 1oo(ean Diab(e tab e(e"ent.
c(oab(e +a(e 1oo(ean 8a3e the tab c(oab(e 'hen enab(ed.
tit(eti& nu(( Strin, 9oo(ti& o+ the tab header.
)ettin& started with the 1ab
See the ection o+ co"&onent 'ho uti(i=e tab co"&onent +or "ore in+or"ation. A tab i a hared
co"&onentE not a(( attribute "ay a&&(y to the co"&onent that ue tab.
450
PrimeFaces Users Guide
#.12' 1abMenu
9ab8enu i a navi,ation co"&onent that di&(ay "enuite" a tab.
In%o
9a, ta&!enu
*o"&onent *(a org.primefaces.component.ta&menu.Ta&!enu
*o"&onent 9y&e org.primefaces.component.Ta&!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Ta&!enuenderer
Renderer *(a org.primefaces.component.ta&menu.Ta&!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
"ode( nu(( 8enu8ode( 8enu8ode( intance to bui(d "enu dyna"ica((y.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
activeInde0 0 Inte,er Inde0 o+ the active tab.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
)ettin& started with 1abMenu
9ab8enu reCuire "enuite" a chi(dren co"&onentE each "enuite" i rendered a a tab. Aut (i3e
in any other "enu co"&onentE "enuite" can be uti(i=ed to do a/a0 reCuetE nonBa/a0 reCuet and
i"&(e GE9 navi,ation.
451
PrimeFaces Users Guide
<p:ta-5enu activeInde&'(0(>
<p:menuitem value'(Overview( outcome'(main( icon'(ui3icon3star(/>
<p:menuitem value'(Demos( outcome'(demos( icon'(ui3icon3search( />
<p:menuitem value'(Documentation( outcome'(docs( icon'(ui3icon3document(/>
<p:menuitem value'(8upport( outcome'(support( icon'(ui3icon3wrench(/>
<p:menuitem value'(8ocial( outcome'(social( icon'(ui3icon3person( />
</p:ta-5enu>
S+innin& 1abMenu
9ab8enu reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBtab"enu 8ain container e(e"ent.
.uiBtab"enuBnav *ontainer +or tab.
.uiBtab"enuite" 8enuite" container.
.uiB"enuite" Anchor o+ a "enuite".
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
452
PrimeFaces Users Guide
#.123 1ab<iew
9ab>ie' i a container co"&onent to ,rou& content in tab.
In%o
9a, ta&Vie0
*o"&onent *(a org.primefaces.component. ta&vie0.Ta&Vie0
*o"&onent 9y&e org.primefaces.component.Ta&Vie0
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Ta&Vie0enderer
Renderer *(a org.primefaces.component.ta&vie0.Ta&Vie0enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean.
'id,et>ar nu(( Strin, >ariab(e na"e o+ the c(ient ide 'id,et.
activeInde0 0 Inte,er Inde0 o+ the active tab.
e++ect nu(( Strin, <a"e o+ the tranition e++ect.
e++ectDuration nu(( Strin, Duration o+ the tranition e++ect.
dyna"ic +a(e 1oo(ean Enab(e (a=y (oadin, o+ inactive tab.
453
PrimeFaces Users Guide
Name Default Type Description
cache true 1oo(ean When tab content are (a=y (oaded by a/a0
to,,(e8odeE cachin, on(y retrieve the tab content
once and ubeCuent to,,(e o+ a cached tab doe not
co""unicate 'ith erver. I+ cachin, i turned o++E tab
content are re(oaded +ro" erver each ti"e tab i
c(ic3ed.
on9ab*han,e nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a tab i c(ic3ed.
on9abSho' nu(( Strin, *(ient ide ca((bac3 to e0ecute 'hen a tab i ho'n.
on9ab*(oe nu(( Strin, *(ient ide ca((bac3 to e0ecute on tab c(oe.
ty(e nu(( Strin, In(ine ty(e o+ the "ain container.
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container.
var nu(( Strin, <a"e o+ iterator to re+er an ite" in co((ection.
va(ue nu(( 7b/ect *o((ection "ode( to di&(ay dyna"ic tab.
orientation to& Strin, 7rientation o+ tab header.
dir (tr Strin, De+ine te0t directionE va(id va(ue are ltr and rtl.
cro((ab(e +a(e 1oo(ean When enab(edE tab header can be cro((ed
hori=onta((y intead o+ 'ra&&in,.
&re&endId true 1oo(ean 9ab>ie' i a na"in, container thu &re&end it id to
it chi(dren by de+au(tE a +a(e va(ue turn thi
behavior o++ e0ce&t +or dyna"ic tab.
)ettin& started with the 1ab<iew
9ab>ie' reCuire one "ore chi(d tab co"&onent to di&(ay. 9it(e can a(o be de+ined by uin,
tit(e +acet.
<p:ta-@iew>
<p:ta- title'(!a- One(>
<h:output!e&t value'(7orem( />
</p:ta->
<p:ta- title'(!a- !wo(>
<h:output!e&t value'(Ipsum( />
</p:ta->
<p:ta- title'(!a- !hree(>
<h:output!e&t value'(Dolor( />
</p:ta->
</p:ta-@iew>
454
PrimeFaces Users Guide
Dynamic 1abs
9herere t'o to,,(e8ode in tabvie'E non1dynamic ?de+au(t@ and dynamic. 1y de+au(tE a(( tab
content are rendered to the c(ientE on the other hand in dyna"ic "odeE on(y the active tab content
are rendered and 'hen an inactive tab header i e(ectedE content i (oaded 'ith a/a0. Dyna"ic
"ode i handy in reducin, &a,e i=eE ince inactive tab are (a=y (oadedE &a,e 'i(( (oad +ater. 9o
enab(e dyna"ic (oadin,E i"&(y et dynamic o&tion to true.
<p:ta-@iew dynamic'(true(>
//ta-s
</p:ta-@iew>
$ontent $achin&
Dyna"ica((y (oaded tab cache their content by de+au(tE by doin, oE reactivatin, a tab doent
reu(t in an a/a0 reCuet ince content are cached. I+ you 'ant to re(oad content o+ a tab each ti"e a
tab i e(ectedE turn o++ cachin, by cache to +a(e.
/%%ects
*ontent tranition e++ect are contro((ed 'ith effect and effect'uration attribute. E++ectDuration
&eci+ie the &eed o+ the e++ectE slowE normal ?de+au(t@ and fast are the va(id o&tion.
<p:ta-@iew effect'(fade( effectDuration'(fast(>
//ta-s
</p:ta-@iew>
A,a- .ehaior /ents
tabChange and tabClose are the a/a0 behavior event o+ tabvie' that are e0ecuted 'hen a tab i
chan,ed and c(oed re&ective(y. .ere i an e0a"&(e o+ a tab*han,e behavior i"&(e"entationK
<p:ta-@iew>
<p:a,a& event'ta-hange listener'./-ean.onhange0 />
//ta-s
</p:ta-@iew>
pu-lic void onhange9!a-hange$vent event: /
//!a- active!a- ' event.get!a-9:;
//...
0
Mour (itener?i+ de+ined@ 'i(( be invo3ed 'ith an org.primefaces.event.TabChangeEvent intance
that contain a re+erence to the ne' active tab and the accordion &ane( ite(+. #or tab*(oe eventE
(itener 'i(( be &aed an intance o+ org.primefaces.event.TabCloseEvent.
Dynamic 0umber o% 1abs
When the tab to di&(ay are not taticE ue the bui(tBin iteration +eature i"i(ar to uiNre&eat.
455
PrimeFaces Users Guide
<p:ta-@iew value'(./-ean.list0( var'(listItem(>
<p:ta- title'(./listItem.property<0(>
<h:output!e&t value' (./listItem.property=0(/>
...5ore content
</p:ta->
</p:ta-@iew>
;rientations
#our di++erent orientation are avai(ab(eK topdefault!E leftE right and bottom.
<p:ta-@iew orientation'(left(>
//ta-s
</p:ta-@iew>
Scrollable 1abs
9ab header 'ra& to the ne0t (ine in cae there i not enou,h &ace at header area by de+au(t. Uin,
cro((ab(e +eatureE it i &oib(e to 3ee& header a(i,ned hori=onta((y and ue navi,ation button to
acce hidden header.
<p:ta-@iew scrolla-le'(true(>
//ta-s
</p:ta-@iew>
$lient Side $allbac+s
9abvie' ha three ca((bac3 +or c(ient ide. onTabChange i e0ecuted 'hen an inactive tab i
c(ic3edE onTabShow i e0ecuted 'hen an inactive tab beco"e active to be ho'n and onTabClose
'hen a c(oab(e tab i c(oed. A(( thee ca((bac3 receive inde0 &ara"eter a the inde0 o+ tab.
456
PrimeFaces Users Guide
<p:ta-@iew on!a-hange'(handle!a-hange9inde&:(>
//ta-s
</p:ta-@iew>
function handle!a-hange9i: /
//i ' Inde& of the new ta-
0
$lient Side API
Wid,etN PrimeFaces.widget.Tab2iew
!et"od Params eturn Type Description
e(ect?inde0@ inde0N Inde0 o+ tab to di&(ay void Activate tab 'ith ,iven inde0
e(ect9ab?inde0@ inde0N Inde0 o+ tab to di&(ay void ?De&recatedE ue e(ect intead@
Activate tab 'ith ,iven inde0
diab(e?inde0@ inde0N Inde0 o+ tab to diab(e void Diab(e tab 'ith ,iven inde0
enab(e?inde0@ inde0N Inde0 o+ tab to enab(e void Enab(e tab 'ith ,iven inde0
re"ove?inde0@ inde0N Inde0 o+ tab to re"ove void Re"ove tab 'ith ,iven inde0
,et6en,th?@ B <u"ber Return the nu"ber o+ tab
,etActiveInde0?@ B <u"ber Return inde0 o+ current tab
S+innin&
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation. #o((o'in,
i the (it o+ tructura( ty(e c(ae.
#lass Applies
.uiBtab 8ain tabvie' container e(e"ent
.uiBtabBVorientationW 7rientation &eci+ic ?to&E botto"E ri,hE (e+t@ container.
.uiBtabBnav 8ain container o+ tab header
.uiBtabB&ane( Each tab container
.uiBtabBcro((ab(e *ontainer e(e"ent o+ a cro((ab(e tabvie'.
457
PrimeFaces Users Guide
#.125 1a&$loud
9a,*(oud di&(ay a co((ection o+ ta, 'ith di++erent tren,th.
In%o
9a, tag#loud
*o"&onent *(a org.primefaces.component.tagcloud.Tag#loud
*o"&onent 9y&e org.primefaces.component.Tag#loud
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Tag#loudenderer
Renderer *(a org.primefaces.component.tagcloud.Tag#loudenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ode( nu(( 9a,*(oud8ode( 1ac3in, ta, c(oud "ode(.
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
)ettin& started with the 1a&$loud
9a,*(oud reCuire a bac3end 9a,*(oud "ode( to di&(ay.
<p:tagloud model'(./tagloud=ean.model0( />
458
PrimeFaces Users Guide
pu-lic class !agloud=ean /
private !agloud5odel model;
pu-lic !agloud=ean9: /
model ' new Default!agloud5odel9:;
model.add!ag9new Default!agloudItem9(!ransformers(H (.(H *::;
//more
0
//getter
0
Selectin& 1a&s
An ite" i ta,*(oud can be e(ected uin, select a/a0 behavior. <ote that on(y ite" 'ith nu(( ur(
can be e(ected.
<h:form>
<p:growl id'(msg( showDetail'(true( />
<p:tagloud model'(./tagloud=ean.model0(>
<p:a,a& event'(select( update'(msg( listener'(./tagloud=ean.on8elect0( />
</p:tagloud>
</h:form>
pu-lic class !agloud=ean /
//modelH getter and setter
pu-lic void on8elect98elect$vent event: /
!agloudItem item ' 9!agloudItem: event.getO-,ect9:;
6aces5essage msg ' new 6aces5essage96aces5essage.8$@$CI!"LIJ6OH
(Item 8elected(H item.get7a-el9::;
6acesonte&t.geturrentInstance9:.add5essage9nullH msg:;
0
0
1a&$loud API
org.primefaces.model.tagcloud.TagCloud-odel
!et"od Description
6itS9a,*6oudIte"T ,et9a,?@ Return a(( ta, in "ode(.
void add9a,?9a,*(oudIte" ite"@ Add a ta,.
void re"ove9a,?9a,*(oudIte" ite"@ Re"ove a ta,.
void c(ear?@ Re"ove a(( ta,.
!ri"e#ace &rovide org.primefaces.model.tagcloud.'efaultTagCloud-odel a the de+au(t
i"&(e"entation.
459
PrimeFaces Users Guide
org.primefaces.model.tagcloud.TagCloud*tem
!et"od Description
Strin, ,et6abe(?@ Return (abe( o+ the ta,.
Strin, ,etUr(?@ Return ur( o+ the ta,.
int ,etStren,th?@ Return tren,th o+ the ta, bet'een 1 and 5.
org.primefaces.model.tagcloud.'efaultTagCloud*tem i &rovided a the de+au(t i"&(e"entation.
S+innin&
9a,*(oud reide in a container e(e"ent that style and styleClass attribute a&&(y. .ui1tagcloud
a&&(ie to "ain container and .ui1tagcloud1strength1CD6;E a&&(ie to each ta,. A 3innin, ty(e
c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
460
PrimeFaces Users Guide
#.126 1erminal
9er"ina( i an a/a0 &o'ered 'eb baed ter"ina( that brin, de3to& ter"ina( to AS#.
In%o
9a, terminal
*o"&onent *(a org.primefaces.component.terminal.Terminal
*o"&onent 9y&e org.primefaces.component.Terminal
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Terminalenderer
Renderer *(a org.primefaces.component.terminal.Terminalenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
'e(co"e8ea,e nu(( Strin, We(co"e "ea,e to be di&(ayed on initia( (oad.
&ro"&t &ri"e _ Strin, !ri"ary &ro"&t te0t.
co""and.and(er nu(( 8ethodE0&r 8ethod to be ca((ed 'ith ar,u"ent to &roce.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
461
PrimeFaces Users Guide
)ettin& started with the 1erminal
A co""and hand(er i reCuired to inter&ret co""and entered in ter"ina(.
<p:terminal command4andler'(./terminal=ean.handleommand0( />
pu-lic class !erminal=ean /
pu-lic 8tring handleommand98tring commandH 8tringQS params: /
if9command.eBuals9(greet(::
return (4ello ( > paramsQ0S;
else if9command.eBuals9(date(::
return new Date9:.to8tring9:;
else
return command > ( not found(;
0
0
Whenever a co""and i ent to the erverE hand(e*o""and "ethod i invo3ed 'ith the co""and
na"e and the co""and ar,u"ent a a Strin, array.
$lient Side API
*(ient ide 'id,et e0&oe clear! and focus! "ethod. #o((o'in, ho' ho' to add +ocu on a
ter"ina( neted inide a dia(o,K
<p:command=utton type'(-utton( @alue'(<pply 6ocus( onclic2'(#69OtermO:.focus9:;(/>
<p:terminal widget@ar'(term( command4andler'(./terminal=ean.handleommand0( />
S+innin&
9er"ina( reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBter"ina( 8ain container e(e"ent.
.uiBter"ina(Bcontent *ontent di&(ay o+ &reviou co""and 'ith re&one.
.uiBter"ina(B&ro"&t !ro"&t te0t.
#.127 1hemeSwitcher
9he"eS'itcher enab(e 'itchin, !ri"e#ace the"e on the +(y 'ith no &a,e re+reh.
462
PrimeFaces Users Guide
In%o
9a, t"eme)0itc"er
*o"&onent *(a org.primefaces.component.t"emes0itc"er.T"eme)0itc"er
*o"&onent 9y&e org.primefaces.component.T"eme)0itc"er
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.T"eme)0itc"erenderer
Renderer *(a org.primefaces.component.t"emes0itc"er.T"eme)0itc"erenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
e++ect +ade Strin, <a"e o+ the ani"ation.
e++ectS&eed -00 Inte,er Duration o+ the ani"ation in "i((iecond.
diab(ed +a(e 1oo(ean Diab(e the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
onchan,e nu(( Strin, *(ient ide ca((bac3 to e0ecute on the"e chan,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
var nu(( Strin, >ariab(e na"e to re+er to each ite".
hei,ht nu(( Inte,er .ei,ht o+ the &ane(.
463
PrimeFaces Users Guide
Name Default Type Description
tabinde0 nu(( Inte,er !oition o+ the e(e"ent in the tabbin, order.
)ettin& Started with the 1hemeSwitcher
9he"eS'itcher ua,e i very i"i(ar to e(ect7ne8enu.
<p:theme8witcher style'(width:*50p&(>
<f:selectItem item7a-el'(hoose !heme( item@alue'(( />
<f:selectItems value'(./-ean.themes0( />
</p:theme8witcher>
State%ul 1hemeSwitcher
1y de+au(tE the"e'itcher /ut chan,e the the"e on the +(y 'ith no &a,e re+rehE in cae youd (i3e
to ,et noti+ied 'hen a uer chan,e the the"e ?e.,. to u&date uer &re+erence@E you can ue an a/a0
behavior.
<p:theme8witcher value'(./-ean.theme0( effect'(fade(>
<f:selectItem item7a-el'(hoose !heme( item@alue'(( />
<f:selectItems value'(./theme8witcher=ean.themes0( />
<p:a,a& listener'(./-ean.save!heme0( />
</p:theme8witcher>
Adanced 1hemeSwitcher
9he"eS'itcher u&&ort di&(ayin, cuto" content o that you can ho' the"e &revie'.
<p:theme8witcher>
<f:selectItem item7a-el'(hoose !heme( item@alue'(( />
<f:selectItems value'(./theme8witcher=ean.advanced!hemes0( var'(theme(
item7a-el'(./theme.name0( item@alue'(./theme0(/>
<p:column>
<p:graphicImage value'(/images/themes/./t.image0(/>
</p:column>
<p:column>
./t.name0
</p:column>
</p:theme8witcher>
464
PrimeFaces Users Guide
#.128 1ieredMenu
9iered8enu i ued to di&(ay neted ub"enu 'ith over(ay.
In%o
9a, tiered!enu
*o"&onent *(a org.primefaces.component.tieredmenu.Tiered!enu
*o"&onent 9y&e org.primefaces.component.Tiered!enu
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Tiered!enuenderer
Renderer *(a org.primefaces.component.tieredmenu.Tiered!enuenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
"ode( nu(( 8enu8ode( 8enu8ode( intance +or &ro,ra""atic "enu.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
autoDi&(ay true 1oo(ean De+ine 'hether the +irt (eve( o+ ub"enu 'i(( be
di&(ayed on "oueover or not. When et to +a(eE
c(ic3 event i reCuired to di&(ay.
tri,,er nu(( Strin, Id o+ the co"&onent 'hoe tri,,erEvent 'i(( ho'
the dyna"ic &oitioned "enu.
"y nu(( Strin, *orner o+ "enu to a(i,n 'ith tri,,er e(e"ent.
at nu(( Strin, *orner o+ tri,,er to a(i,n 'ith "enu e(e"ent.
465
PrimeFaces Users Guide
Name Default Type Description
over(ay +a(e 1oo(ean De+ine &oitionin,E 'hen enab(ed "enu i
di&(ayed 'ith abo(ute &oition re(ative to the
tri,,er. De+au(t i +a(eE "eanin, tatic &oitionin,.
tri,,erEvent c(ic3 Strin, Event na"e o+ tri,,er that 'i(( ho' the dyna"ic
&oitioned "enu.
)ettin& started with the 1ieredMenu
9iered8enu conit o+ ub"enu and "enuite"E ub"enu can be neted and each neted
ub"enu 'i(( be di&(ayed in an over(ay.
<p:tiered5enu>
<p:su-menu la-el'(<,a& 5enuitems( icon'(ui3icon3refresh(>
<p:menuitem value'(8ave( action7istener'(./-utton=ean.save0(
update'(messages( icon'(ui3icon3dis2( />
<p:menuitem value'(Kpdate( action7istener'(./-utton=ean.update0(
update'(messages( icon'(ui3icon3arrowrefresh3*3w( />
</p:su-menu>
<p:su-menu la-el'(Jon3<,a& 5enuitem( icon'(ui3icon3newwin(>
<p:menuitem value'(Delete( action7istener'(./-utton=ean.delete0(
update'(messages( a,a&'(false( icon'(ui3icon3close(/>
</p:su-menu>
<p:separator />
<p:su-menu la-el'(Javigations( icon'(ui3icon3e&tlin2(>
<p:su-menu la-el'(#rime 7in2s(>
<p:menuitem value'(#rime( url'(http://www.prime.com.tr( />
<p:menuitem value'(#rime6aces( url'(http://www.primefaces.org( />
</p:su-menu>
<p:menuitem value'(5o-ile( url'(/mo-ile( />
</p:su-menu>
</p:tiered5enu>
AutoDisplay
1y de+au(tE ub"enu are di&(ayed 'hen "oue i over root "enuite"E et autoDi&(ay to +a(e to
reCuire a c(ic3 on root "enuite" to enab(e autoDi&(ay "ode.
<p:tiered5enu autoDisplay'(false(>
//content
</p:tiered5enu>
;erlay
9iered8enu can be &oitioned re(ative to a tri,,er co"&onentE +o((o'in, a"&(e attache a
tiered8enu to the button o that 'henever the button i c(ic3ed tiered8enu 'i(( be di&(ayed in an
over(ay ite(+.
466
PrimeFaces Users Guide
<p:command=utton type'(-utton( value'(8how( id'(-tn( />
<p:tiered5enu autoDisplay'(false( trigger'(-tn( my'(left top( at'(left -ottom(>
//content
</p:tiered5enu>
$lient Side API
Wid,etN PrimeFaces.widget.Tiered-enu
!et"od Params eturn Type Description
ho'?@ B void Sho' over(ay "enu.
hide?@ B void .ide over(ay "enu.
a(i,n?@ B void A(i,n over(ay "enu 'ith tri,,er.
S+innin&
9iered8enu reide in a "ain container 'hich style and styleClass attribute a&&(y. #o((o'in, i the
(it o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiB"enu .uiBtiered"enu *ontainer e(e"ent o+ "enu.
.uiB"enuB(it 6it container
.uiB"enuite" Each "enu ite"
.uiB"enuite"B(in3 Anchor e(e"ent in a (in3 ite"
.uiB"enuite"Bte0t 9e0t e(e"ent in an ite"
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
467
PrimeFaces Users Guide
#.1#: 1oolbar
9oo(bar i a hori=onta( ,rou&in, co"&onent +or co""and and other content.
In%o
9a, tool&ar
*o"&onent *(a org.primefaces.component.tool&ar.Tool&ar
*o"&onent 9y&e org.primefaces.component.Tool&ar
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Tool&arenderer
Renderer *(a org.primefaces.component.tool&ar.Tool&arenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
)ettin& Started with the 1oolbar
9oo(bar ha t'o &(aceho(der?(e+t and ri,ht@ that are de+ined 'ith +acet.
<p:tool-ar>
<f:facet name'(left(></f:facet>
<f:facet name'(right(></f:facet>
</p:tool-ar>
Any content can be &(aced inide too(bar.
468
PrimeFaces Users Guide
<p:tool-ar>
<f:facet name'(left(>
<p:command=utton type'(push( value'(Jew( image'(ui3icon3document( />
<p:command=utton type'(push( value'(Open( image'(ui3icon3folder3open(/>
<span class'(ui3separator(>
<span class'(ui3icon ui3icon3grip3dotted3vertical( />
</span>
<p:command=utton type'(push( title'(8ave( image'(ui3icon3dis2(/>
<p:command=utton type'(push( title'(Delete( image'(ui3icon3trash(/>
<p:command=utton type'(push( title'(#rint( image'(ui3icon3print(/>
</f:facet>
<f:facet name'(right(>
<p:menu=utton value'(Javigate(>
<p:menuitem value'(4ome( url'(.( />
<p:menuitem value'(7ogout( url'(.( />
</p:menu=utton>
</f:facet>
</p:tool-ar>
S+innin&
9oo(bar reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. #o((o'in, i the (it
o+ tructura( ty(e c(aeK
)tyle #lass Applies
.uiBtoo(bar 8ain container
.uiBtoo(bar .uiBe&arator Divider in a too(bar
.uiBtoo(barB,rou&B(e+t 6e+t too(barGrou& container
.uiBtoo(barB,rou&Bri,ht Ri,ht too(barGrou& container
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
469
PrimeFaces Users Guide
#.1#1 1oolbar)roup CDeprecatedD
9oo(barGrou& i a he(&er co"&onent +or 9oo(bar co"&onent to de+ine &(aceho(der.
In%o
9a, tool&ar/roup
*o"&onent *(a org.primefaces.component.tool&ar.Tool&ar/roup
*o"&onent 9y&e org.primefaces.component.Tool&ar/roup
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
a(i,n nu(( Strin, De+ine the a(i,n"ent 'ithin too(barE va(id va(ue
are left and right.
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
)ettin& Started with the 1oolbar)roup
See too(bar docu"entation +or "ore in+or"ation about ho' 9oo(bar Grou& i ued.
Deprecated
9oo(barGrou& co"&onent i de&recated and 'i(( be re"oved in a +uture re(eae. Ue left and right
+acet inide too(bar co"&onent intead.
470
PrimeFaces Users Guide
#.1#2 1ooltip
9oo(ti& ,oe beyond the (e,acy ht"( tit(e attribute by &rovidin, cuto" e++ectE eventE ht"( content
and advance the"e u&&ort.
In%o
9a, tooltip
*o"&onent *(a org.primefaces.component.tooltip.Tooltip
*o"&onent 9y&e org.primefaces.component.Tooltip
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Tooltipenderer
Renderer *(a org.primefaces.component.tooltip.Tooltipenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent than can be either an E6
e0&reion o+ a (itera( te0t
converter nu(( *onverterQ
Strin,
An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When it an E6
e0&reionE it reo(ved to a converter intance. In
cae it a tatic te0tE it "ut re+er to a converter id
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
ho'Event "oueover Strin, Event di&(ayin, the too(ti&.
ho'E++ect +ade Strin, E++ect to be ued +or di&(ayin,.
hideEvent "oueout Strin, Event hidin, the too(ti&.
hideE++ect +ade Strin, E++ect to be ued +or hidin,.
ho'De(ay 150 Inte,er De(ay ti"e to ho' too(ti& in "i((iecond.
471
PrimeFaces Users Guide
Name Default Type Description
hideDe(ay 0 Inte,er De(ay ti"e to hide too(ti& in "i((iecond.
+or nu(( Strin, *o"&onent to attach the too(ti&.
ty(e nu(( Strin, In(ine ty(e o+ the too(ti&.
ty(e*(a nu(( Strin, Sty(e c(a o+ the too(ti&.
,(oba(Se(ector nu(( Strin, /Cuery e(ector +or ,(oba( too(ti&E de+au(t to
IaENin&utENbuttonI.
eca&e true 1oo(ean De+ine 'hether ht"( 'ou(d be eca&ed or not.
trac38oue +a(e 1oo(ean 9oo(ti& &oition +o((o' &ointer on "oue"ove.
)ettin& started with the 1ooltip
9oo(ti& can be ued by attachin, it to a tar,et co"&onent. 9oo(ti& va(ue can a(o be retrieved +ro"
tar,et tit(eE o +o((o'in, are a"eK
<h:input8ecret id'(pwd( value'(./my=ean.password0( />
<p:tooltip for'(pwd( value'(Only num-ers(/>
<h:input8ecret id'(pwd( value'(./my=ean.password0( title'(Only num-ers(/>
<p:tooltip for'(pwd(/>
)lobal 1ooltip
Global tooltip binds to elements with title attributes. Ajax updates are supported as well, meaning if
target component is updated with ajax, tooltip can still bind. A ,(oba( too(ti& are "ore e++icient
ince on(y one intance o+ too(ti& i ued acro a(( too(ti& tar,etE it i u,,eted to be ued intead
o+ e0&(icit too(ti& un(e you have a cuto" cae e.,. di++erent o&tionE cuto" content.
<p:tooltip />
<p:input!e&t id'(focus( title'(!ooltip for an input(/>
<h:output7in2 id'(fade( value'(.( title'(!ooltip for a lin2(>
<h:output!e&t value'(6ade $ffect( />
</h:output7in2>
<p:command=utton value'(Kp( title'(Kp( />
I/1: Issue
Due to a bu,E IE10 a('ay di&(ay the tit(e te0t in a native &o&u& 'hen the e(e"ent receive +ocu
via tabbin, and t'o too(ti& "i,ht be di&(ayed at once. So(ution i to ue &athrou,h dataBtoo(ti&
attribute intead o+ tit(e.
472
PrimeFaces Users Guide
<html &mlns'(http://www.w).org/*+++/&html(
&mlns:h'(http://&mlns.,cp.org/,sf/html(
&mlns:pt'(http://&mlns.,cp.org/,sf/passthrough(
&mlns:p'(http://primefaces.org/ui(>
<h:head></h:head>
<h:-ody>
<p:input!e&t pt:data3tooltip'(!itle here(/>
<p:input!e&t title'(1or2s fine e&cept ta--ed on I$*0(/>
</h:-ody>
</html>
/ents and /%%ects
A too(ti& i ho'n on "oueover event and hidden 'hen "oue i out by de+au(t. I+ you need to
chan,e thi behavior ue the ho'Event and hideEvent +eature. 9oo(ti& be(o' i di&(ayed 'hen the
in&ut ,et the +ocu and hidden 'ith onb(ur.
<h:input8ecret id'(pwd( value'(./my=ean.password0( />
<p:tooltip for'(pwd( value'(#assword must contain only num-ers(
show$vent'(focus( hide$vent'(-lur( show$ffect'(-lind( hide$ffect'(e&plode( />
Avai(ab(e o&tion +or e++ect areK blind6 bounce6 clip6 drop6 e$plode6 fold6 highlight6 puff6 pulsate6
scale6 sha"e6 si/e and slide.
(tml $ontent
Another &o'er+u( +eature o+ too(ti& i the abi(ity to di&(ay cuto" content a a too(ti&.
<h:output7in2 id'(ln2( value'(.(>
<h:output!e&t value'(#rime6aces 4ome( />
</h:output7in2>
<p:tooltip for'(ln2(>
<p:graphicImage value'(/images/primeLlogo.png( />
<h:output!e&t value'(@isit #rime6aces 4ome( />
</p:tooltip>
S+innin&
9oo(ti& ha on(y .ui1tooltip a a ty(e c(a and i ty(ed 'ith ,(oba( 3innin, e(ectorE ee "ain
3innin, ection +or "ore in+or"ation.
473
PrimeFaces Users Guide
#.1## 1ree
9ree i i ued +or di&(ayin, hierarchica( data and creatin, ite navi,ation.
In%o
9a, tree
*o"&onent *(a org.primefaces.component.tree.Tree
*o"&onent 9y&e org.primefaces.component.Tree
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.Treeenderer
Renderer *(a org.primefaces.component.tree.Treeenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
va(ue nu(( 7b/ect A 9ree<ode intance a the bac3in, "ode(.
var nu(( Strin, <a"e o+ the reCuetBco&ed variab(e thatO(( be ued
to re+er each treenode data.
dyna"ic +a(e 1oo(ean S&eci+ie the a/a0Qc(ient to,,(e8ode
cache true 1oo(ean S&eci+ie cachin, on dyna"ica((y (oaded node.
When et to true e0&anded node 'i(( be 3e&t in
"e"ory.
on<ode*(ic3 nu(( Strin, Aavacri&t event to &roce 'hen a tree node i
c(ic3ed.
e(ection nu(( 7b/ect 9ree<ode array to re+erence the e(ection.
474
PrimeFaces Users Guide
Name Default Type Description
ty(e nu(( Strin, Sty(e o+ the "ain container e(e"ent o+ tree
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain container e(e"ent o+ tree
e(ection8ode nu(( Strin, De+ine the e(ection8ode
hi,h(i,ht true 1oo(ean .i,h(i,ht node on hover 'hen e(ection i
enab(ed.
data3ey nu(( 7b/ect UniCue 3ey o+ the data &reented by node.
ani"ate +a(e 1oo(ean When enab(edE di&(ay (ide e++ect on to,,(e.
orientation vertica( Strin, 7rientation o+ (ayoutE vertical or hori/ontal.
&ro&a,ateSe(ectionU& true 1oo(ean De+ine u&'ard e(ection &ro&a,ation +or
chec3bo0 "ode.
&ro&a,ateSe(ectionDo'n true 1oo(ean De+ine do'n'ard e(ection &ro&a,ation +or
chec3bo0 "ode.
dir (tr Strin, De+ine te0t directionE va(id va(ue are ltr and rtl.
dra,,ab(e +a(e 1oo(ean 8a3e tree node dra,,ab(e.
dro&&ab(e +a(e 1oo(ean 8a3e tree dro&&ab(e.
dra,dro&Sco&e nu(( Strin, Sco&e 3ey to ,rou& a et o+ tree co"&onent +or
tran+errin, node uin, dra, and dro&.
dra,8ode e(+ Strin, De+ine &arentBchi(d re(ationhi& 'hen a node i
dra,,edE va(id va(ue are e(+ ?de+au(t@E &arent and
ancetor.
dro&Retrict none Strin, De+ine &arentBchi(d retriction 'hen a node i
dro&&ed va(id va(ue are none ?de+au(t@ and ib(in,.
reCuired +a(e 1oo(ean >a(idation contraint +or e(ection.
reCuired8ea,e nu(( Strin, 8ea,e +or reCuired e(ection va(idation.
)ettin& started with the 1ree
9ree i &o&u(ated 'ith a org.primefaces.model.Tree=ode intance 'hich corre&ond to the root.
<p:tree value'(./tree=ean.root0( var'(node(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
475
PrimeFaces Users Guide
pu-lic class !ree=ean /
private !reeJode root;
pu-lic !ree=ean9: /
root ' new !reeJode9(Coot(H null:;
!reeJode node0 ' new !reeJode9(Jode 0(H root:;
!reeJode node* ' new !reeJode9(Jode *(H root:;
!reeJode nodeA ' new !reeJode9(Jode A(H root:;
!reeJode node00 ' new !reeJode9(Jode 0.0(H node0:;
!reeJode node0* ' new !reeJode9(Jode 0.*(H node0:;
!reeJode node*0 ' new !reeJode9(Jode *.0(H node*:;
!reeJode node** ' new !reeJode9(Jode *.*(H node*:;
!reeJode node000 ' new !reeJode9(Jode 0.0.0(H node00:;
!reeJode node00* ' new !reeJode9(Jode 0.0.*(H node00:;
!reeJode node0*0 ' new !reeJode9(Jode 0.*.0(H node0*:;
!reeJode node*00 ' new !reeJode9(Jode *.0.0(H node*0:;
0
//getter of root
0
1ree0ode s pE1ree0ode
9ree<ode A!I i ued to create the node "ode( and conit o+ org.primefaces.model.Tree=ode
i n t ance E on t he ot her hand @p7tree=ode AB re&reent a co"&onent o+ ty&e
org.primefaces.component.tree.(*Tree=ode. Mou can bind a 9ree<ode to a &articu(ar &Ntree<ode
uin, the type na"e. Docu"ent 9ree e0a"&(e in u&co"in, ection de"ontrate a a"&(e ua,e.
1ree0ode API
9ree<ode ha a i"&(e A!I to ue 'hen bui(din, the bac3in, "ode(. #or e0a"&(e i+ you ca((
node.etE0&anded?true@ on a &articu(ar nodeE tree 'i(( render that node a e0&anded.
Property Type Description
ty&e Strin, ty&e o+ the tree<ode na"eE de+au(t ty&e na"e i Ide+au(tI.
data 7b/ect Enca&u(ated data
chi(dren 6itS9ree<odeT 6it o+ chi(d node
&arent 9ree<ode !arent node
e0&anded 1oo(ean #(a, indicatin, 'hether the node i e0&anded or not
476
PrimeFaces Users Guide
Dynamic 1ree
9ree i nonBdyna"ic by de+au(t and to,,(in, ha&&en on c(ientBide. In order to enab(e a/a0 to,,(in,
et dyna"ic ettin, to true.
<p:tree value'(./tree=ean.root0( var'(node( dynamic'(true(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
=on1'ynamic7 When to,,(in, i et to c(ient a(( the treenode in "ode( are rendered to the c(ient
and tree i createdE thi "ode i uitab(e +or re(ative(y "a(( dataet and &rovide +at uer
interaction. 7n the otherhand it not uitab(e +or (ar,e data ince a(( the data i ent to the c(ient a(o
c(ient ide tree i tate(e.
'ynamic7 Dyna"ic "ode ue a/a0 to +etch the treenode +ro" erver ide on de"andE co"&ared to
the c(ient to,,(in,E dyna"ic "ode ha the advanta,e o+ dea(in, 'ith (ar,e data becaue on(y the
chi(d node o+ the root node i ent to the c(ient initia((y and 'ho(e tree i (a=i(y &o&u(ated. When a
node i e0&andedE tree on(y (oad the chi(dren o+ the &articu(ar e0&anded node and end to the c(ient
+or di&(ay.
Multiple 1ree0ode 1ypes
It a co""on reCuire"ent to di&(ay di++erent 9ree<ode ty&e 'ith a di++erent UI ?e, icon@.
Su&&oe youre uin, tree to viua(i=e a co"&any 'ith di++erent de&art"ent and di++erent
e"&(oyeeE or a docu"ent tree 'ith variou +o(derE +i(e each havin, a di++erent +or"at ?"uicE
video@. In order to o(ve thiE you can &(ace "ore than one @p7tree=ode AB co"&onent each havin,
a di++erent ty&e and ue that Ity&eI to bind 9ree<ode in your "ode(. #o((o'in, e0a"&(e
de"ontrate a docu"ent e0&(orer. .ere i the +ina( out&ut to achieveK
Docu"ent E0&(orer i i"&(e"ented 'ith +our di++erent @p7tree=ode AB co"&onent and additiona(
*SS 3innin, to viua(i=e e0&andedQc(oed +o(der icon.
477
PrimeFaces Users Guide
<p:tree value'(./-ean.root0( var'(doc(>
<p:treeJode e&pandedIcon'(ui3icon ui3icon3folder3open(
collapsedIcon'(ui3icon ui3icon3folder3collapsed(>
<h:output!e&t value'(./doc.name0(/>
</p:treeJode>
<p:treeJode type'(document( icon'(ui3icon ui3icon3document(>
<h:output!e&t value'(./doc.name0( />
</p:treeJode>
<p:treeJode type'(picture( icon'(ui3icon ui3icon3image(>
<h:output!e&t value'(./doc.name0( />
</p:treeJode>
<p:treeJode type'(mp)( icon'(ui3icon ui3icon3video(>
<h:output!e&t value'(./doc.name0( />
</p:treeJode>
</p:tree>
478
PrimeFaces Users Guide
pu-lic class =ean /
private !reeJode root;
pu-lic =ean9: /
root ' new !reeJode9(root(H null:;
!reeJode documents ' new !reeJode9(Documents(H root:;
!reeJode pictures ' new !reeJode9(#ictures(H root:;
!reeJode music ' new !reeJode9(5usic(H root:;
!reeJode wor2 ' new !reeJode9(1or2(H documents:;
!reeJode primefaces ' new !reeJode9(#rime6aces(H documents:;
//Documents
!reeJode e&penses ' new !reeJode9(document(H ($&penses.doc(H wor2:;
!reeJode resume ' new !reeJode9(document(H (Cesume.doc(H wor2:;
!reeJode refdoc ' new !reeJode9(document(H (CefDoc.pages(H primefaces:;
//#ictures
!reeJode -arca ' new !reeJode9(picture(H (-arcelona.,pg(H pictures:;
!reeJode primelogo ' new !reeJode9(picture(H (logo.,pg(H pictures:;
!reeJode optimus ' new !reeJode9(picture(H (optimus.png(H pictures:;
//5usic
!reeJode tur2ish ' new !reeJode9(!ur2ish(H music:;
!reeJode cemTaraca ' new !reeJode9(em Taraca(H tur2ish:;
!reeJode er2inToray ' new !reeJode9($r2in Toray(H tur2ish:;
!reeJode mogollar ' new !reeJode9(5ogollar(H tur2ish:;
!reeJode nemalaca2 ' new !reeJode9(mp)(H (Jem <laca2 6ele2 =enim(H cemTaraca:;
!reeJode resimde2i ' new !reeJode9(mp)(H (Cesimde2i IoO "aslari(H cemTaraca:;
!reeJode copculer ' new !reeJode9(mp)(H (opculer(H er2inToray:;
!reeJode oyle-irgecer ' new !reeJode9(mp)(H (Oyle =ir Iecer(H er2inToray:;
!reeJode topra2ana ' new !reeJode9(mp)(H (!opra2 <na(H mogollar:;
!reeJode -isiyapmali ' new !reeJode9(mp)(H (=isi "apmali(H mogollar:;
0
//getter of root
0
Inte,ration bet'een a 9ree<ode and a &Ntree<ode i the ty&e attributeE +or e0a"&(e "uic +i(e in
docu"ent e0&(orer are re&reented uin, 9ree<ode 'ith ty&e I"&)IE there a(o a &Ntree<ode
co"&onent 'ith a"e ty&e I"&)I. 9hi reu(t in renderin, a(( "uic node uin, that &articu(ar
&Ntree<ode re&reentation 'hich di&(ay a note icon. Si"i(ar(y docu"ent and &icture have their
o'n &Ntree<ode re&reentation.
#o(der on the other hand have t'o tate 'hoe icon are de+ined by e$panded*con and
collapsed*con attribute.
A,a- .ehaior /ents
9ree &rovide variou a/a0 behavior event.
479
PrimeFaces Users Guide
'vent *istener Parameter +ired
e0&and or,.&ri"e+ace.event.<odeE0&andEvent When a node i e0&anded.
co((a&e or,.&ri"e+ace.event.<ode*o((a&eEvent When a node i co((a&ed.
e(ect or,.&ri"e+ace.event.<odeSe(ectEvent When a node i e(ected.
co((a&e or,.&ri"e+ace.event.<odeUne(ectEvent When a node i une(ected.
#o((o'in, tree ha three (itenerK
<p:tree value'(./tree=ean.model0( dynamic'(true(>
<p:a,a& event'(select( listener'(./tree=ean.onJode8elect0( />
<p:a,a& event'(e&pand( listener'(./tree=ean.onJode$&pand0( />
<p:a,a& event'(collapse( listener'(./tree=ean.onJodeollapse0( />
...
</p:tree>
pu-lic void onJode8elect9Jode8elect$vent event: /
8tring node ' event.get!reeJode9:.getData9:.to8tring9:;
0
pu-lic void onJode$&pand9Jode$&pand$vent event: /
8tring node ' event.get!reeJode9:.getData9:.to8tring9:;
0
pu-lic void onJodeollapse9Jodeollapse$vent event: /
8tring node ' event.get!reeJode9:.getData9:.to8tring9:;
0
Event (itener are a(o ue+u( 'hen dea(in, 'ith hu,e a"ount o+ data. 9he idea +or i"&(e"entin,
uch a ue cae 'ou(d be &rovidin, on(y the root and chi(d node to the treeE ue event (itener to
,et the e(ected node and add ne' node to that &articu(ar tree at runti"e.
Selection
<ode e(ection i a bui(tBin +eature o+ tree and it u&&ort three di++erent "ode. Se(ection hou(d be
a 9ree<ode +or in,(e cae and an array o+ 9ree<ode +or "u(ti&(e and chec3bo0 caeE tree +ind
the e(ected node and ai,n the" to your e(ection "ode(.
singleN 7n(y one at a ti"e can be e(ectedE e(ection hou(d be a 9ree<ode re+erence.
multipleN 8u(ti&(e node can be e(ectedE e(ection hou(d be a 9ree<ode`a re+erence.
chec"bo$N 8u(ti&(e e(ection i done 'ith chec3bo0 UIE e(ection hou(d be a 9ree<ode`a re+erence.
480
PrimeFaces Users Guide
<p:tree value'(./tree=ean.root0( var'(node(
selection5ode'(chec2-o&(
selection'(./tree=ean.selectedJodes0(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
pu-lic class !ree=ean /
private !reeJode root;
private !reeJodeQS selectedJodes;
pu-lic !ree=ean9: /
root ' new hec2-o&!reeJode9(Coot(H null:;
//populate nodes
0
//getters and setters
0
9hat itE no' the chec3bo0 baed tree (oo3 (i3e be(o'. When the +or" i ub"itted 'ith a
co""and co"&onent (i3e a buttonE e(ected node 'i(( be &o&u(ated in e(ected<ode &ro&erty o+
9ree1ean. A chec3bo0 e(ection have a &ecia( hierarchyE ue Chec"bo$Tree=ode intead.
0ode $achin&
When cachin, i turned on by de+au(tE dyna"ica((y (oaded node 'i(( be 3e&t in "e"ory o reB
e0&andin, a node 'i(( not tri,,er a erver ide reCuet. In cae it et to +a(eE co((a&in, the node
'i(( re"ove the chi(dren and e0&andin, it (ater caue the chi(dren node to be +etched +ro" erver
a,ain.
(andlin& 0ode $lic+
I+ you need to e0ecute cuto" /avacri&t 'hen a treenode i c(ic3edE ue the on=odeClic" attribute.
Mour /avacri&t "ethod 'i(( be invo3ed 'ith &ain, the ht"( e(e"ent o+ the node and the c(ic3
event a &ara"eter. In cae you have data3ey de+inedE you can acce data3ey on c(ient ide by
uin, node.attr?!dataBdata3ey@ that re&reent the data re&reented by the bac3in, tree "ode(.
Dra&Drop
9ree node can be reordered 'ithin a in,(e tree and can even be tran+erred bet'een "u(ti&(e tree
uin, dra,dro&. #or a in,(e tree enab(e dra,,ab(e and dro&&ab(e o&tion.
481
PrimeFaces Users Guide
<p:tree value'(./tree=ean.root0( var'(node( dragga-le'(true( droppa-le'(true(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
#or "u(ti&(e treeE ue a co&e attribute to "atch the" and con+i,ure dra,dro& o&tion de&endin,
on your caeE +o((o'in, e0a"&(e ha % tree 'here one i the ource and other i the tar,et. 9ar,et
can a(o be reordered 'ithin ite(+.
<p:tree value'(./tree=ean.root*0( var'(node( dragga-le'(true( droppa-le'(false(
dragdrop8cope'(myscope(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
<p:tree value'(./tree=ean.rootA0( var'(node( dragga-le'(true( droppa-le'(true(
dragdrop8cope'(myscope(>
<p:treeJode>
<h:output!e&t value'(./node0(/>
</p:treeJode>
</p:tree>
9'o additiona( o&tion e0it +or +urther con+i,urationE drag-ode de+ine the tar,et node that 'ou(d
be dro&&edE de+au(t va(ue i self and other va(ue are parent and ancestor. drop+estrict on the other
handE can retrict the dro& tar,et to be 'ithin the &arent by ettin, it to sibling.
(ori9ontal 1ree
De+au(t orientation o+ tree i vertica(E ettin, it to hori=onta( di&(ay node in an hori=onta( (ayout.
A(( +eature o+ vertica( tree e0ce&t dra,dro& i avai(ab(e +or hori=onta( tree a 'e((.
482
PrimeFaces Users Guide
$onte-tMenu
9ree ha &ecia( inte,ration 'ith conte0t "enuE you can even "atch di++erent conte0t "enu 'ith
di++erent tree node uin, nodeType o&tion o+ conte0t "enu that "atche the tree node ty&e. <ote
that e(ection "ut be enab(ed in tree co"&onent +or conte0t "enu inte,ration.
<p:conte&t5enu for'(tree(>
<p:menuitem value'(@iew( update'(messages(
action7istener'(./-ean.view0( icon'(ui3icon3search( />
<p:menuitem value'(@iew( update'(tree(
action7istener'(./-ean.delete0( icon'(ui3icon3close( />
</p:conte&t5enu>
<p:tree id'(tree( value'(./-ean.root0( var'(node(
selection5ode'(single( selection'(./-ean.selectedJode0(>
<p:treeJode>
<h:output!e&t value'(./node0( />
</p:treeJode>
</p:tree>
S+innin&
9ree reide in a container e(e"ent 'hich style and styleClass o&tion a&&(y. #o((o'in, i the (it o+
tructura( ty(e c(aeK
)tyle #lass Applies
.uiBtree 8ain container
.uiBtreeBcontainer Root node container.
.uiBtreenode 9ree node
.uiBtreenodeBcontent 9ree node content
483
PrimeFaces Users Guide
)tyle #lass Applies
.uiBtreenodeBicon 9ree node icon
.uiBtreeBto,,(er 9o,,(e icon
.uiBtreenodeB(abe( 9ree node (abe(
.uiBtreenodeB&arent <ode 'ith chi(dren
.uiBtreenodeB(ea+ <ode 'ithout chi(dren
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
484
PrimeFaces Users Guide
#.1#' 1ree0ode
9ree<ode i ued 'ith 9ree co"&onent to re&reent a node in tree.
In%o
9a, treeNode
*o"&onent *(a org.primefaces.component.tree.-.TreeNode
*o"&onent 9y&e org.primefaces.component.-.TreeNode
*o"&onent #a"i(y org.primefaces.component
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty&e de+au(t Strin, 9y&e o+ the tree node
ty(e*(a nu(( Strin, Sty(e c(a to a&&(y a &articu(ar tree node ty&e
icon nu(( Strin, Icon o+ the node.
e0&andedIcon nu(( Strin, E0&anded icon o+ the node.
co((a&edIcon nu(( Strin, *o((a&ed icon o+ the node.
)ettin& started with the 1ree0ode
9ree<ode i ued by 9ree and 9ree9ab(e co"&onentE re+er to ection o+ thee co"&onent +or
"ore in+or"ation.
485
PrimeFaces Users Guide
#.1#3 1ree1able
9reetab(e i i ued +or di&(ayin, hierarchica( data in tabu(ar +or"at.
In%o
9a, treeTa&le
*o"&onent *(a org.primefaces.component.treeta&le.TreeTa&le
*o"&onent 9y&e org.primefaces.component.TreeTa&le
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.TreeTa&leenderer
Renderer *(a org.primefaces.component.treeta&le.TreeTa&leenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i((
not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect A 9ree<ode intance a the bac3in, "ode(.
var nu(( Strin, <a"e o+ the reCuetBco&ed variab(e ued to
re+er each treenode.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et.
ty(e nu(( Strin, In(ine ty(e o+ the container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the container e(e"ent.
486
PrimeFaces Users Guide
Name Default Type Description
e(ection nu(( 7b/ect Se(ection re+erence.
e(ection8ode nu(( Strin, 9y&e o+ e(ection "ode.
cro((ab(e +a(e 1oo(ean Whether or not the data hou(d be cro((ab(e.
cro((.ei,ht nu(( Inte,er .ei,ht o+ cro((ab(e data.
cro((Width nu(( Inte,er Width o+ cro((ab(e data.
tab(eSty(e nu(( Strin, In(ine ty(e o+ the tab(e e(e"ent.
tab(eSty(e*(a nu(( Strin, Sty(e c(a o+ the tab(e e(e"ent.
e"&ty8ea,e <o
record
+ound
Strin, 9e0t to di&(ay 'hen there i no data to di&(ay.
rei=ab(e*o(u"n +a(e 1oo(ean De+ine i+ co(u" can be rei=ed or not.
ro'Sty(e*(a nu(( Strin, Sty(e c(a +or each ro'.
(iveRei=e +a(e 1oo(ean *o(u"n are rei=ed (ive in thi "ode 'ithout
uin, a rei=e he(&er.
reCuired +a(e 1oo(ean >a(idation contraint +or e(ection.
reCuired8ea,e nu(( Strin, 8ea,e +or reCuired e(ection va(idation.
ort1y nu(( >a(ueE0&r E0&reion +or de+au(t ortin,.
ort7rder acendin, Strin, De+ine de+au(t ortin, order.
ort#unction nu(( 8ethodE0&r *uto" &(u,,ab(e ort#unction +or de+au(t
ortin,.
nativeE(e"ent +a(e 1oo(ean In native "odeE treetab(e ue native
chec3bo0e.
data6oca(e nu(( 7b/ect 6oca(e to be ued in +eature uch a ortin,E
de+au(t to vie' (oca(e.
caeSenitiveSort +a(e 1oo(ean *ae enitivity +or ortin,E inenitive by
de+au(t.
)ettin& started with the 1ree1able
Si"i(ar to the 9reeE 9ree9ab(e i &o&u(ated 'ith an org.primefaces.model.Tree=ode intance that
corre&ond to the root node. 9ree<ode A!I ha a hierarchica( data tructure and re&reent the data
to be &o&u(ated in tree. #or an e0a"&(eE "ode( to be di&(ayed i a co((ection o+ docu"ent i"i(ar
a in tree ection.
487
PrimeFaces Users Guide
pu-lic class Document /
private 8tring name;
private 8tring siOe;
private 8tring type;
//gettersH setters
0
<p:tree!a-le value'(./-ean.root0( var'(document(>
<p:column>
<f:facet name'(header(>
Jame
</f:facet>
<h:output!e&t value'(./document.name0( />
</p:column>
//more columns
</p:tree!a-le>
Selection
<ode e(ection i a bui(tBin +eature o+ tree and it u&&ort t'o di++erent "ode. Se(ection hou(d be a
9ree<ode +or in,(e cae and an array o+ 9ree<ode +or "u(ti&(e caeE tree +ind the e(ected node
and ai,n the" to your e(ection "ode(.
singleN 7n(y one at a ti"e can be e(ectedE e(ection hou(d be a 9ree<ode re+erence.
multiple or chec"bo$N 8u(ti&(e node can be e(ectedE e(ection hou(d be a 9ree<ode`a re+erence.
A chec3bo0 e(ection have a &ecia( hierarchyE ue Chec"bo$Tree=ode in chec3bo0 "ode.
A,a- .ehaior /ents
9ree9ab(e &rovide variou a/a0 behavior event to re&ond uer action.
'vent *istener Parameter +ired
e0&and or,.&ri"e+ace.event.<odeE0&andEvent When a node i e0&anded.
co((a&e or,.&ri"e+ace.event.<ode*o((a&eEvent When a node i co((a&ed.
e(ect or,.&ri"e+ace.event.<odeSe(ectEvent When a node i e(ected.
une(ect or,.&ri"e+ace.event.<odeUne(ectEvent When a node i une(ected.
co(Rei=e or,.&ri"e+ace.event.*o(u"nRei=eEvent When a co(u"n i rei=ed.
$onte-tMenu
9ree9ab(e ha &ecia( inte,ration 'ith conte0t "enuE you can even "atch di++erent conte0t "enu
'ith di++erent tree node uin, nodeType o&tion o+ conte0t "enu that "atche the tree node ty&e.
488
PrimeFaces Users Guide
Scrollin&
Scro((ab(e 9ree9ab(e i"&(e"entation i a"e a Data9ab(e Scro((ab(eE re+er to cro((in, &art in
Data9ab(e ection +or detai(ed in+or"ation.
Sortin&
Sortin, i enab(ed by ettin, sort)y e0&reion at co(u"n (eve(.
<p:tree!a-le value'(./-ean.root0( var'(document(>
<p:column sort=y'(./document.name0(>
<h:output!e&t value'(./document.name0( />
</p:column>
//more columns
</p:tree!a-le>
In cae youOd (i3e to di&(ay tree9ab(e a orted on &a,e (oad ue ort1y attribute o+ tree9ab(eE
o&tiona( sort,rder and sortFunction attribute are &rovided to de+ine the de+au(t ort order
?acendin, or decindin,@ and a /ava "ethod to do the actua( ortin, re&ective(y. Re+er to datatab(e
ortin, ection +or an e0a"&(e ua,e o+ sortFunction.
S+innin&
9ree9ab(e content reide in a container e(e"ent 'hich ty(e and ty(e*(a attribute a&&(y.
#o((o'in, i the (it o+ tructura( ty(e c(aeK
#lass Applies
.uiBtreetab(e 8ain container e(e"ent.
.uiBtreetab(eBheader .eader o+ treetab(e.
.uiBtreetab(eBdata 1ody e(e"ent o+ the tab(e containin, data
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
489
PrimeFaces Users Guide
#.1#5 Watermar+
Water"ar3 di&(ay a hint on an in&ut +ie(d.
In%o
9a, 0atermar,
*o"&onent *(a org.primefaces.component.0atermar,.1atermar,
*o"&onent 9y&e org.primefaces.component.1atermar,
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.1atermar,enderer
Renderer *(a org.primefaces.component.0atermar,.1atermar,enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect 9e0t o+ 'ater"ar3.
+or nu(( Strin, *o"&onent to attach the 'ater"ar3
)ettin& started with Watermar+
Water"ar3 reCuire a tar,et o+ the in&ut co"&onent. In cae you donOt need to u&&ort (e,acy
bro'erE &re+er &(aceho(der attribute o+ in&ut co"&onent over 'ater"ar3.
<h:input!e&t id'(t&t( value'(./-ean.searchTeyword0( />
<p:watermar2 for'(t&t( value'(8earch with a 2eyword( />
490
PrimeFaces Users Guide
Form Submissions
Water"ar3 i et a the te0t o+ an in&ut +ie(d 'hich hou(dnt be ent to the erver 'hen an
enc(oin, +or i ub"itted. 9hi 'ou(d reu(t in u&datin, bean &ro&ertie 'ith 'ater"ar3 va(ue.
Water"ar3 co"&onent i c(ever enou,h to hand(e thi caeE by de+au(t in nonBa/a0 +or"
ub"iionE 'ater"ar3 are c(eared. .o'ever a/a0 ub"iion reCuire a (itt(e "anua( e++ort.
!(eae note that thi on(y a&&(ie to (e,acy bro'erE a 'ater"ar3 ue .9865 &(aceho(der o&tion
'hen avai(ab(e.
<h:input!e&t id'(t&t( value'(./-ean.searchTeyword0( />
<p:watermar2 for'(t&t( value'(8earch with a 2eyword( />
<p:command=utton value'(8u-mit( onclic2'(#rime6aces.clean1atermar2s9:(
oncomplete'(#rime6aces.show1atermar2s9:( />
S+innin&
#or bro'er that do not u&&ort &(aceho(derE there on(y one c ty(e c(a a&&(yin, 'ater"ar3
'hich i !.ui1watermar"E you can override thi c(a to brin, in your o'n ty(e.
491
PrimeFaces Users Guide
#.1#6 Wi9ard
Wi=ard &rovide an a/a0 enhanced UI to i"&(e"ent a 'or3+(o' eai(y in a in,(e &a,e. Wi=ard
conit o+ evera( chi(d tab co"&onent 'here each tab re&reent a te& in the &roce.
In%o
9a, 0i3ard
*o"&onent *(a org.primefaces.component.0i3ard.1i3ard
*o"&onent 9y&e org.primefaces.component.1i3ard
*o"&onent #a"i(y org.primefaces.component
Renderer 9y&e org.primefaces.component.1i3ardenderer
Renderer *(a org.primefaces.component.0i3ard.1i3ardenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent.
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE
'hen et to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent
intance in a bac3in, bean
te& 0 Strin, Id o+ the current te& in +(o'
ty(e nu(( Strin, Sty(e o+ the "ain 'i=ard container e(e"ent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the "ain 'i=ard container e(e"ent.
+(o'6itener nu(( 8ethodE0&r Server ide (itener to invo3e 'hen 'i=ard atte"&t to ,o
+or'ard or bac3.
ho'<av1ar true 1oo(ean S&eci+ie viibi(ity o+ de+au(t navi,ator arro'.
ho'Ste&Statu true 1oo(ean S&eci+ie viibi(ity o+ de+au(t te& tit(e bar.
492
PrimeFaces Users Guide
Name Default Type Description
onbac3 nu(( Strin, Aavacri&t event hand(er to be invo3ed 'hen +(o' ,oe
bac3.
onne0t nu(( Strin, Aavacri&t event hand(er to be invo3ed 'hen +(o' ,oe
+or'ard.
ne0t6abe( nu(( Strin, 6abe( o+ ne0t navi,ation button.
bac36abe( nu(( Strin, 6abe( o+ bac3 navi,ation button.
'id,et>ar nu(( Strin, <a"e o+ the c(ient ide 'id,et
)ettin& Started with Wi9ard
Each te& in the +(o' i re&reented 'ith a tab. A an e0a"&(e +o((o'in, 'i=ard i ued to create a
ne' uer in a tota( o+ - te& 'here (at te& i +or con+ir"ation o+ the in+or"ation &rovided in +irt
) te&. 9o be,in 'ith create your bac3in, beanE it i"&ortant that the bean (ive acro "u(ti&(e
reCuet o avoid a reCuet co&e bean. 7&ti"a( co&e +or 'i=ard i vie'Sco&e.
pu-lic class Kser1iOard /
private Kser user ' new Kser9:;
pu-lic Kser getKser9: /
return user;
0
pu-lic void setKser9Kser user: /
this.user ' user;
0
pu-lic void save9<ction$vent action$vent: /
//#ersist user
6aces5essage msg ' new 6aces5essage9(8uccessful(H
(1elcome :( > user.get6irstname9::;
6acesonte&t.geturrentInstance9:.add5essage9nullH msg:;
0
0
(ser i a i"&(e &o/o 'ith &ro&ertie uch a +irtna"eE (atna"eE e"ai( and etc. #o((o'in, 'i=ard
reCuire ) te& to ,et the uer dataK !erona( Detai(E Addre Detai( and *ontact Detai(. <ote
that (at tab contain readBon(y data +or con+ir"ation and the ub"it button.
493
PrimeFaces Users Guide
<h:form>
<p:wiOard>
<p:ta- id'(personal(>
<p:panel header'(#ersonal Details(>
<h:messages errorlass'(error(/>
<h:panelIrid columns'(A(>
<h:output!e&t value'(6irstname: W( />
<h:input!e&t value'(./user1iOard.user.firstname0( reBuired'(true(/>
<h:output!e&t value'(7astname: W( />
<h:input!e&t value'(./user1iOard.user.lastname0( reBuired'(true(/>
<h:output!e&t value'(<ge: ( />
<h:input!e&t value'(./user1iOard.user.age0( />
</h:panelIrid>
</p:panel>
</p:ta->
<p:ta- id'(address(>
<p:panel header'(<dress Details(>
<h:messages errorlass'(error(/>
<h:panelIrid columns'(A( columnlasses'(la-elH value(>
<h:output!e&t value'(8treet: ( />
<h:input!e&t value'(./user1iOard.user.street0( />
<h:output!e&t value'(#ostal ode: ( />
<h:input!e&t value'(./user1iOard.user.postalode0( />
<h:output!e&t value'(ity: ( />
<h:input!e&t value'(./user1iOard.user.city0( />
</h:panelIrid>
</p:panel>
</p:ta->
<p:ta- id'(contact(>
<p:panel header'(ontact Information(>
<h:messages errorlass'(error(/>
<h:panelIrid columns'(A(>
<h:output!e&t value'($mail: W( />
<h:input!e&t value'(./user1iOard.user.email0( reBuired'(true(/>
<h:output!e&t value'(#hone: ( />
<h:input!e&t value'(./user1iOard.user.phone0(/>
<h:output!e&t value'(<dditional Info: ( />
<h:input!e&t value'(./user1iOard.user.info0(/>
</h:panelIrid>
</p:panel>
</p:ta->
494
PrimeFaces Users Guide
<p:ta- id'(confirm(>
<p:panel header'(onfirmation(>
<h:panelIrid id'(confirmation( columns'(U(>
<h:output!e&t value'(6irstname: ( />
<h:output!e&t value'(./user1iOard.user.firstname0(/>
<h:output!e&t value'(7astname: ( />
<h:output!e&t value'(./user1iOard.user.lastname0(/>
<h:output!e&t value'(<ge: ( />
<h:output!e&t value'(./user1iOard.user.age0( />
<h:output!e&t value'(8treet: ( />
<h:output!e&t value'(./user1iOard.user.street0( />
<h:output!e&t value'(#ostal ode: ( />
<h:output!e&t value'(./user1iOard.user.postalode0(/>
<h:output!e&t value'(ity: ( />
<h:output!e&t value'(./user1iOard.user.city0(/>
<h:output!e&t value'($mail: ( />
<h:output!e&t value'(./user1iOard.user.email0( />
<h:output!e&t value'(#hone ( />
<h:output!e&t value'(./user1iOard.user.phone0(/>
<h:output!e&t value'(Info: ( />
<h:output!e&t value'(./user1iOard.user.info0(/>
<h:output!e&t />
<h:output!e&t />
</h:panelIrid>
<p:command=utton value'(8u-mit( action7istener'(./user1iOard.save0( />
</p:panel>
</p:ta->
</p:wiOard>
</h:form>
A!A= and Partial <alidations
S'itchin, bet'een te& i baed on a/a0E "eanin, each te& i (oaded dyna"ica((y 'ith a/a0.
!artia( va(idation i a(o bui(tBinE by thi 'ay 'hen you c(ic3 ne0tE on(y the current te& i va(idatedE
i+ the current te& i va(idE ne0t tab content are (oaded 'ith a/a0. >a(idation are not e0ecuted
'hen +(o' ,oe bac3.
0ai&ations
Wi=ard &rovide t'o icon to interact 'ithK ne0t and &rev. !(eae ee the 3innin, 'i=ard ection to
3no' "ore about ho' to chan,e the (oo3 and +ee( o+ a 'i=ard.
495
PrimeFaces Users Guide
$ustom 4I
1y de+au(t 'i=ard di&(ay ri,ht and (e+t arro' to navi,ate bet'een te&E i+ you need to co"e u&
'ith your o'n UIE et show=av)ar to +a(e and ue the &rovided the c(ient ide a&i.
<p:wiOard showJav=ar'(false( widget@ar'(wiO(>
...
</p:wiOard>
<h:output7in2 value'(.( onclic2'(#69?wiO?:.ne&t9:;(>Je&t</h:output7in2>
<h:output7in2 value'(.( onclic2'(#69?wiO?:.-ac29:;(>=ac2</h:output7in2>
Flow*istener
I+ youd (i3e ,et noti+ied on erver ide 'hen 'i=ard atte"&t to ,o bac3 or +or'ardE de+ine a
+(o'6itener.
<p:wiOard flow7istener'(./user1iOard.handle6low0(>
...
</p:wiOard>
pu-lic 8tring handle6low96low$vent event: /
8tring current8tepId ' event.geturrent8tep9:;
8tring step!oIo ' event.getJe&t8tep9:;
if9s2ip:
return (confirm(;
else
return event.getJe&t8tep9:;
0
Ste& here are i"&(y the id o+ tabE by uin, a +(o'6itener you can decide 'hich te& to di&(ay
ne0t o 'i=ard doe not need to be (inear a('ay. I+ you need to u&date other co"&onent?@ on &a,e
'ithin a +(o'E ue +equestConte$t.updateString client*d! a&i.
$lient Side $allbac+s
Wi=ard i eCui&&ed 'ith onbac3 and onne0t attributeE in cae you need to e0ecute cuto"
/avacri&t a+ter 'i=ard ,oe bac3 or +orth. Mou /ut need to &rovide the na"e o+ /avacri&t +unction
a the va(ue o+ thee attribute.
<p:wiOard onne&t'(alert9!Je&t:( on-ac2'(alert9!=ac2:(>
...
</p:wiOard>
$lient Side API
Wid,etN PrimeFaces.widget.5i/ard
496
PrimeFaces Users Guide
!et"od Params eturn Type Description
ne0t?@ B void !roceed to ne0t te&.
bac3?@ B void Goe bac3 in +(o'.
,etSte&Inde0?@ B <u"ber Return the inde0 o+ current te&.
ho'<e0t<av?@ B void Sho' ne0t button.
hide<e0t<av?@ B void .ide ne0t button.
ho'1ac3<av?@ B void Sho' bac3 button.
hide1ac3<av?@ B void .ide bac3 button.
S+innin&
Wi=ard reide in a container e(e"ent that style and styleClass attribute a&&(y. #o((o'in, i the (it
o+ tructura( c c(ae.
)elector Applies
.uiB'i=ard 8ain container e(e"ent.
.uiB'i=ardBcontent *ontainer e(e"ent o+ content.
.uiB'i=ardBte&Btit(e *ontainer o+ te& tit(e.
.uiB'i=ardBte&Btit(e Each te& tit(e.
.uiB'i=ardBnavbar *ontainer o+ navi,ation contro(.
.uiB'i=ardBnavBbac3 1ac3 navi,ation contro(.
.uiB'i=ardBnavBne0t #or'ard navi,ation contro(.
A 3innin, ty(e c(ae are ,(oba(E ee the "ain the"in, ection +or "ore in+or"ation.
497
PrimeFaces Users Guide
'. Partial "enderin& and Processin&
!ri"e#ace &rovide a &artia( renderin, and vie' &rocein, +eature baed on tandard AS# % A!I
to enab(e chooin, 'hat to &roce in AS# (i+ecy(e and 'hat to render in the end 'ith a/a0.
'.1 Partial "enderin&
In addition to co"&onent (i3e auto*o"&(eteE datatab(eE (ider 'ith bui(tBin a/a0 ca&abi(itieE
!ri"e#ace a(o &rovide a ,eneric !!R ?!artia( !a,e Renderin,@ "echani" to u&date AS#
co"&onent 'ith a/a0. Severa( co"&onent are eCui&&ed 'ith the co""on !!R attribute ?e.,.
u&dateE &roceE ontartE onco"&(ete@.
'.1.1 In%rastructure
!ri"e#ace A/a0 #ra"e'or3 i baed on tandard erver ide A!I o+ AS# %. 9here are no additiona(
art+act (i3e cuto" A/a0>ie'RootE A/a0State8ana,erE A/a0>ie'.and(erE Serv(et #i(terE
.t"(!arerE !hae6itener and o on. !ri"e#ace ai" to 3ee& it c(eanE +at and (i,ht'ei,ht.
7n c(ient ide rather than uin, c(ient ide A!I i"&(e"entation o+ AS# i"&(e"entation (i3e
8o/arra and 8y#aceE !ri"e#ace cri&t are baed on the "ot &o&u(ar /avacri&t (ibraryK /Duery
'hich i +ar "ore tetedE tab(e re,ardin, a/a0E do" hand(in,E do" tree traverin, than a AS#
i"&(e"entation cri&t.
'.1.2 4sin& IDs
)ettin& Started
When uin, !!R you need to &eci+y 'hich co"&onent?@ to u&date 'ith a/a0. I+ the co"&onent
that tri,,er !!R reCuet i at the a"e na"in,container ?e,. +or"@ 'ith the co"&onent?@ it
renderE you can ue the erver id direct(y. In thi ection a(thou,h 'e(( be uin, co""and1uttonE
a"e a&&(ie to every co"&onent that ca&ab(e o+ !!R uch a co""and6in3E &o((E
re"ote*o""and and etc.
<h:form>
<p:command=utton update'(display( />
<h:output!e&t id'(display( value'(./-ean.value0(/>
</h:form>
PrependId
Settin, &re&endId ettin, o+ a +or" ha no e++ect on ho' !!R i ued.
<h:form prependId'(false(>
<p:command=utton update'(display( />
<h:output!e&t id'(display( value'(./-ean.value0(/>
</h:form>
498
PrimeFaces Users Guide
$lientId
It i a(o &oib(e to de+ine the c(ient id o+ the co"&onent to u&date.
<h:form id'(myform(>
<p:command=utton update'(myform:display( />
<h:output!e&t id'(display( value'(./-ean.value0(/>
</h:form>
Di%%erent 0amin&$ontainers
I+ your &a,e ha di++erent na"in, container ?e.,. t'o +or"@E you a(o need to add the container id
to earch e0&reion o that !!R can hand(e reCuet that are tri,,ered inide a na"in,container
that u&date another na"in,container. #o((o'in, i the u,,eted 'ay uin, e&arator char a a
&re+i0E note that thi ue a"e earch a(,orith" a tandard AS# % i"&(e"entationK
<h:form id'(form*(>
<p:command=utton update'(:formA:display( />
</h:form>
<h:form id'(formA(>
<h:output!e&t id'(display( value'(./-ean.value0(/>
</h:form>
!(eae read find#omponent a(,orith" decribed in (in3 be(o' ued by both AS# core and
!ri"e#ace to +u((y undertand ho' co"&onent re+erencin, 'or3.
http://docs.oracle.com/,avaee/U/api/,ava&/faces/component/KIomponent.html
AS# hN+or"E datatab(eE co"&oite co"&onent are na"in, containerE in addition tab>ie'E
accordion!ane(E data9ab(eE dataGridE data6itE caroue(E ,a((eriaE rin,E heet and ub9ab(e are
!ri"e#ace co"&onent that i"&(e"ent <a"in,*ontainer.
Multiple $omponents
8u(ti&(e co"&onent to u&date can be &eci+ied 'ith &rovidin, a (it o+ id e&arated by a co""aE
'hite&ace or even both.
<h:form>
<p:command=utton update'(display*HdisplayA( />
<p:command=utton update'(display* displayA( />
<h:output!e&t id'(display*( value'(./-ean.value*0(/>
<h:output!e&t id'(displayA( value'(./-ean.valueA0(/>
</h:form>
499
PrimeFaces Users Guide
'.1.# 0oti%yin& 4sers
a/a0Statu i the co"&onent to noti+y the uer about the tatu o+ glo&al a/a0 reCuet. See the
a/a0Statu ection to ,et "ore in+or"ation about the co"&onent.
)lobal s 0on>)lobal
1y de+au(t a/a0 reCuet are ,(oba(E "eanin, i+ there i an a/a0Statu co"&onent &reent on &a,eE it
i tri,,ered.
I+ you 'ant to do a Ii(entI reCuet not to tri,,er a/a0Statu inteadE et ,(oba( to +a(e. An e0a"&(e
'ith co""and1utton 'ou(d beK
<p:command=utton value'(8ilent( glo-al'(false( />
<p:command=utton value'(Jotify( glo-al'(true( />
'.1.' .itsAPieces
PrimeFaces A,a- !aascript API
See the /avacri&t ection to (earn "ore about the !ri"e#ace Aavacri&t A/a0 A!I.
500
PrimeFaces Users Guide
'.2 Partial Processin&
In !artia( !a,e Renderin,E on(y &eci+ied co"&onent are renderedE i"i(ar(y in !artia( !rocein,
on(y de+ined co"&onent are &roceed. !rocein, "ean e0ecutin, A&&(y ReCuet >a(ueE
!roce >a(idationE U&date 8ode( and Invo3e A&&(ication AS# (i+ecyc(e &hae on(y on de+ined
co"&onent.
9hi +eature i a i"&(e but &o'er+u( enou,h to do ,rou& va(idationE avoidin, va(idatin, un'anted
co"&onentE e(i"inatin, need o+ uin, i""ediate and "any "ore ue cae. >ariou co"&onent
uch a co""and1uttonE co""and6in3 are eCui&&ed 'ith &roce attributeE in e0a"&(e 'e(( be
uin, co""and1utton.
'.2.1 Partial <alidation
A co""on ue cae o+ &artia( &roce i doin, &artia( va(idationE u&&oe you have a i"&(e
contact +or" 'ith t'o dro&do'n co"&onent +or e(ectin, city and uburbE a(o there an in&ut9e0t
'hich i reCuired. When city i e(ectedE re(ated uburb o+ the e(ected city i &o&u(ated in uburb
dro&do'n.
<h:form>
<h:selectOne5enu id'(cities( value'(./-ean.city0(>
<f:selectItems value'(./-ean.cityhoices0( />
<p:a,a& listener'(./-ean.populate8u-ur-s0( update'(su-ur-s(
process'(Zall(/>
</h:selectOne5enu>
<h:selectOne5enu id'(su-ur-s( value'(./-ean.su-ur-0(>
<f:selectItems value'(./-ean.su-ur-hoices0( />
</h:selectOne5enu>
<h:input!e&t value'(./-ean.email0( reBuired'(true(/>
</h:form>
When the city dro&do'n i chan,ed an a/a0 reCuet i ent to e0ecute &o&u(ateSuburb "ethod
'hich &o&u(ate uburb*hoice and +ina((y u&date the uburb dro&do'n. !rob(e" i
&o&u(ateSuburb "ethod 'i(( not be e0ecuted a (i+ecyc(e 'i(( to& a+ter &roce va(idation &hae
to /u"& render re&one a e"ai( in&ut i not &rovided. Reaon i &Na/a0 ha ba(( a the va(ue
tatin, to &roce every co"&onent on &a,e but there i no need to &roce the in&ut9e0t.
9he o(ution i to de+ine 'hat to &roce in &Na/a0. A 'ere /ut "a3in, a city chan,e reCuetE on(y
&rocein, that hou(d ha&&en i citie dro&do'n.
501
PrimeFaces Users Guide
<h:form>
<h:selectOne5enu id'(cities( value'(./-ean.city0(>
<f:selectItems value'(./-ean.cityhoices0( />
<p:a,a& action7istener'(./-ean.populate8u-ur-s0(
event'(change( update'(su-ur-s( process'(Zthis(/>
</h:selectOne5enu>
<h:selectOne5enu id'(su-ur-s( value'(./-ean.su-ur-0(>
<f:selectItems value'(./-ean.su-ur-hoices0( />
</h:selectOne5enu>
<h:input!e&t value'(./-ean.email0( reBuired'(true(/>
</h:form>
9hat i itE no' &o&u(ateSuburb "ethod 'i(( be ca((ed and uburb (it 'i(( be &o&u(ated. <ote that
de+au(t va(ue +or &roce o&tion i bthi a(ready +or &Na/a0 a tated in A/a01ehavior
docu"entationE it i e0&(icit(y de+ined here to ,ive a better undertandin, o+ ho' &artia( &rocein,
'or3.
'.2.2 4sin& Ids
!artia( !roce ue the a"e techniCue a&&(ied in &artia( u&date to &eci+y co"&onent identi+ier
to &roce.
502
PrimeFaces Users Guide
'.# Search /-pression Framewor+
*ore AS# co"&onent re+erencin, i baed on co"&onent identi+ier on(y 'ith baic 3ey'ord
u&&ort. !ri"e#ace Search E0&reion #ra"e'or3 ?SE#@ &rovide both erver ide and c(ient ide
e0tenion to "a3e it eaier to re+erence co"&onent. SE# i uti(i=ed in &artia( u&dateE &roce and
'henever a co"&onent re+erence another co"&onent.
'.#.1 @eywords
;ey'ord are the eaier 'ay to re+erence co"&onentE they reo(ve to id o that i+ an id chan,eE
the re+erence doe not need to chan,e. *ore AS# &rovide a cou&(e o+ 3ey'ord and !ri"e#ace
&rovide "ore a(on, 'ith co"&oite e0&reion u&&ort.
5ey0ord Type Description
bthi Standard *urrent co"&onent.
ba(( Standard Who(e vie'.
b+or" Standard *(oet ancetor +or" o+ current co"&onent.
bnone Standard <o co"&onent.
bna"in,container !ri"e#ace *(oet ancetor na"in, container o+ current co"&onent.
b&arent !ri"e#ace !arent o+ the current co"&onent.
bco"&oite !ri"e#ace *(oet co"&oite co"&onent ancetor.
bchi(d?n@ !ri"e#ace nth chi(d.
b&reviou !ri"e#ace !reviou ib(in,.
bne0t !ri"e#ace <e0t ib(in,.
b'id,et>ar?na"e@ !ri"e#ace *o"&onent 'ith ,iven 'id,et>ar.
*onider the +o((o'in, cae 'here id are ued +or re+erencin,K
<h:form id'(form*(>
<p:command=utton id'(-tn( update'(form*( process'(-tn( />
<h:output!e&t value'(./-ean.value0(/>
</h:form>
Uin, 3ey'ordE a"e can be 'ritten aK
<h:form id'(form*(>
<p:command=utton id'(-tn( update'(Zform( process'(Zthis( />
<h:output!e&t value'(./-ean.value0(/>
</h:form>
503
PrimeFaces Users Guide
$omposite /-pressions
8u(ti&(e 3ey'ord can be co"bined in a in,(e e0&reion uin, co(onK
G b+or"Nb&arent
G bco"&oiteN"ybuttonid
G bthiNb&arentNb&arent
G b+or"Nbchi(d?%@
4sa&e Scenarios
SE# i not /ut at &artia( &roce and u&dateE they are a(o avai(ab(e 'henever a co"&onent i
re+erencin, another.
<h:form>
<p:command=utton id'(dyna=utton( value'(8how( type'(-utton( />
<p:menu overlay'(true( trigger'(Zparent:dyna=utton(>
//items
</p:menu>
</h:form>
'.#.2 PrimeFaces Selectors CPFSD
!#S inte,rate /Duery Se(ector A!I 'ith AS# co"&onent re+erencin, "ode( o that re+erencin, can
be done uin, /Duery Se(ector A!I intead o+ core id baed AS# "ode(. 1et 'ay to e0&(ain the
&o'er o+ !#S i e0a"&(eK
U&date a(( +or"
update'(Z9form:(
U&date +irt +or"
update'(Z9form:first:(
U&date a(( co"&onent that ha ty(e*(a na"ed "yty(e
update'(Z9.mystyle:(
U&date and &roce a(( in&ut
update'(Z9:input:( process'(Z9:input:(
504
PrimeFaces Users Guide
U&date a(( datatab(e
update'(Z9.ui3datata-le:(
!roce in&ut co"&onent inide any &ane( and u&date a(( &ane(
process'(Z9.ui3panel :input:( update'(Z9.ui3panel:(
!roce in&ut co"&onent but not e(ect co"&onent
process'(Z9:input:not9select::(
U&date in&ut co"&onent that are diab(ed
update'(Z9:input:disa-led:(
!#S can be ued 'ith other re+erencin, a&&roache a 'e((K
update'(compId :form:compId Z9:input: Zparent:Zchild9A:(
<h:form>
<p:command=utton id'(dyna=utton( value'(8how( type'(-utton( stylelass'(-tn(/>
<p:menu overlay'(true( trigger'(Z9.-tn:(>
//items
</p:menu>
</h:form>
!#S &rovide an a(ternativeE +(e0ib(eE ,rou&in, baed a&&roach to re+erence co"&onent to &artia((y
&roce and u&date. 9here i (e *!U erver (oad co"&ared to re,u(ar re+erencin, becaue AS#
co"&onent tree i not travered on erver ide to +ind a co"&onent and +i,ure out the c(ient id a
!#S i i"&(e"ented on c(ient ide by (oo3in, at do" tree. Another advanta,e i avoidin, na"in,
container (i"itationE /ut re"e"ber the ti"e youve +aced 'ith cannot +ind co"&onent e0ce&tion
ince the co"&onent you are (oo3in, +or i in a di++erent na"in, container (i3e a +or" or a
datatab(e. !#S can he(& you out in tric3y ituation by +o((o'in, /Duery 'rite (e do "ore ty(e.
#or !#S to +unction &ro&er(y and not to "i any co"&onentE it i reCuired to have e0&(icit(y
de+ined id on the "atched et a core AS# co"&onent uua((y do not render auto id. So even
thou,h "anua((y de+ined id 'onOt be re+erenced direct(yE they are ti(( reCuired +or !#S to be
co((ected and end in the reCuet.
#or +u(( re+erence o+ /Duery e(ector a&iE eeK
http://api.,Buery.com/category/selectors/
505
PrimeFaces Users Guide
'.' PartialSubmit
*ore AS# A/a0 i"&(e"entation and by de+au(t !ri"e#ace eria(i=e the 'ho(e +or" to bui(d the
&ot data in a/a0 reCuet o the a"e data i &oted /ut (i3e in a nonBa/a0 reCuet. 9hi ha a
do'nide in (ar,e vie' 'here you on(y need to &roceQe0ecute a "inor &art o+ the vie'. Au"e
you have a +or" 'ith 100 in&ut +ie(dE there i an in&ut +ie(d 'ith a/a0behavior attached &rocein,
on(y ite(+?bthi@ and then u&date another +ie(d onb(ur. A(thou,h on(y a &articu(ar in&ut +ie(d i
&roceedE 'ho(e +or" data 'i(( be &oted 'ith the unneceary in+or"ation that 'ou(d be i,nored
durin, erver ide &rocein, but conu"e reource.
!ri"e#ace &rovide &artia(Sub"it +eature to reduce the net'or3 tra++ic and co"&utin, on c(ient
ide. When &artia(Sub"it i enab(edE on(y data o+ co"&onent that 'i(( be &artia((y &roceed on the
erver ide are eria(i=ed. 1y de+au(t &artia(Sub"it i diab(ed and you can enab(e it ,(oba((y uin, a
conte0t &ara"eter.
<conte&t3param>
<param3name>primefaces.8K=5I!</param3name>
<param3value>partial</param3value>
</conte&t3param>
*o"&onent (i3e button and behavior (i3e &Na/a0 are eCui&&ed 'ith &artia(Sub"it o&tion o you
can override the ,(oba( ettin, &er co"&onent.
<p:command=utton value'(8u-mit( partial8u-mit'(true[false( />
506
PrimeFaces Users Guide
3. !aascript API
!ri"e#ace render unobtruive /avacri&t 'hich c(ean(y e&arate behavior +ro" the ht"(. *(ient
ide en,ine i &o'ered by /Duery verion 1.2.1 'hich i the (atet at the ti"e o+ the 'ritin,.
3.1 PrimeFaces 0amespace
PrimeFaces i the "ain /avacri&t ob/ect &rovidin, uti(itie and na"e&ace.
!et"od Description
eca&e*(ientId?id@ Eca&ed AS# id 'ith e"i co(on to 'or3 'ith /Duery.
addSub"it!ara"?e(E na"eE &ara"@ Add reCuet &ara"eter dyna"ica((y to the e(e"ent.
,et*oo3ie?na"e@ Return coo3ie 'ith ,iven na"e.
et*oo3ie?na"eE va(ue@ Set a coo3ie 'ith ,iven na" and va(ue.
3inIn&ut?in&ut@ !ro,reive(y enhance an in&ut e(e"ent 'ith the"in,.
in+o?",@E debu,?",@E 'arn?",@E error?",@ *(ient ide (o, A!I.
chan,e9he"e?the"e@ *han,e the"e on the +(y 'ith no &a,e re+reh.
c(eanWater"ar3?@ Water"ar3 co"&onent e0tenionE c(ean a((
'ater"ar3 on &a,e be+ore ub"ittin, the +or".
ho'Water"ar3?@ Sho' 'ater"ar3 on +or".
9o be co"&atib(e 'ith other /avacri&t entitie on a &a,eE !ri"e#ace de+ine t'o /avacri&t
na"e&aceK
Prime+aces.0idget.*
*ontain cuto" !ri"e#ace 'id,et (i3eK
B !ri"e#ace.'id,et.Data9ab(e
B !ri"e#ace.'id,et.9ree
B !ri"e#ace.'id,et.!o((
B and "ore...
8ot o+ the co"&onent have a corre&ondin, c(ient ide 'id,et 'ith a"e na"e.
PrimeFaces.ajax.*
!ri"e#ace.a/a0 na"e&ace contain the a/a0 A!I 'hich i decribed in ne0t ection.
507
PrimeFaces Users Guide
3.2 A,a- API
!ri"e#ace A/a0 Aavacri&t A!I i &o'ered by /Duery and o&ti"i=ed +or AS#. Who(e A!I conit
o+ three &ro&er(y na"e&aced i"&(e /avacri&t +unction.
PrimeFaces.a,a-."eFuest
Send a/a0 reCuet that e0ecute AS# (i+ecyc(e and retrieve &artia( out&ut. #unction i,nature i a
+o((o'K
#rime6aces.a,a&.CeBuest.handle9cfg:;
$on%i&uration ;ptions
6ption Description
+or"Id Id o+ the +or" e(e"ent to eria(i=eE i+ not de+ined &arent +or" o+
ource i ued.
aync #(a, to de+ine 'hether reCuet hou(d ,o in a/a0 Cueue or notE de+au(t
i +a(e.
,(oba( #(a, to de+ine i+ &Na/a0Statu hou(d be tri,,ered or notE de+au(t i
true.
u&date *o"&onent?@ to u&date 'ith a/a0.
&roce *o"&onent?@ to &roce in &artia( reCuet.
ource *(ient id o+ the ource co"&onent cauin, the reCuet.
&ara" Additiona( &ara"eter to end in a/a0 reCuet.
ontart?@ Aavacri&t ca((bac3 to &roce be+ore endin, the a/a0 reCuetE return
+a(e to cance( the reCuet.
onucce?dataE tatuE 0hrE ar,@ Aavacri&t ca((bac3 to &roce 'hen a/a0 reCuet return 'ith ucce
code. 9a3e +our ar,u"entE 0"( re&oneE tatu codeE
0"(htt&reCuet and o&tiona( ar,u"ent &rovided by ReCuet*ontent
A!I.
onerror?0hrE tatuE e0ce&tion@ Aavacri&t ca((bac3 to &roce 'hen a/a0 reCuet +ai(. 9a3e three
ar,u"entE 0"(htt&reCuetE tatu trin, and e0ce&tion thro'n i+ any.
onco"&(ete?0hrE tatuE ar,@ Aavacri&t ca((bac3 to &roce 'hen a/a0 reCuet co"&(ete. 9a3e
three ar,u"entE 0"(htt&reCuetE tatu trin, and o&tiona( ar,u"ent
&rovided by ReCuet*onte0t A!I.
508
PrimeFaces Users Guide
/-amples
Su&&oe you have a AS# &a,e ca((ed create(ser 'ith a i"&(e +or" and o"e in&ut co"&onent.
<h:form id'(user6orm(>
<h:input!e&t id'(username( value'(./user=ean.user.name0( />
... 5ore components
</h:form>
Mou can &ot a(( the in+or"ation 'ith a/a0 uin,K
#rime6aces.a,a&.CeBuest.handle9/
formId:user6orm
Hsource:user6orm
Hprocess:user6orm
0:;
8ore co"&(e0 e0a"&(e 'ith additiona( o&tionK
#rime6aces.a,a&.CeBuest.handle9/
formId: ?user6orm?H
source: ?user6orm?H
process: ?user6orm?H
update: ?msgs?&
params:/
?paramLname*?:?value*?H
?paramLnameA?:?valueA?
0H
oncomplete:function9&hrH status: /alert9?Done?:;0
0:;
We hi,h(y reco""end uin, &Nre"ote*o"&onent intead o+ (o' (eve( /avacri&t a&i a it ,enerate
the a"e 'ith "uch (e e++ort and (e &oibi(ity to do an error.
PrimeFaces.a,a-."esponse
!ri"e#ace.a/a0.Re&one.hand(e?@ u&date the &eci+ied co"&onent i+ any and ynchroni=e the
c(ient ide AS# tate. D78 u&date are i"&(e"ented uin, /Duery 'hich ue a very +at a(,orith".
509
PrimeFaces Users Guide
5. Dialo& Framewor+
Dia(o, #ra"e'or3 ?D#@ i ued to o&en an e0terna( 0ht"( &a,e in a dia(o, that i ,enerated
dyna"ica((y on runti"e. 9hi i Cuite di++erent to re,u(ar ua,e o+ dia(o, 'ith dec(arative &Ndia(o,
co"&onent a D# i baed on a &ro,ra""atic A!I 'here dia(o, are created and detroyed at
runti"e. <ote that D# and the dec(arative a&&roach are t'o di++erent 'ay and both can even be
ued to,ether. Ua,e i Cuite i"&(eE ReCuet*onte0t ha o&enDia(o, and c(oeDia(o, "ethodK
/WW
W Open a view in dialog.
W Zparam outcome !he logical outcome used to resolve a navigation case.
W/
pu-lic a-stract void openDialog98tring outcome:;
/WW
W Open a view in dialog.
W Zparam outcome !he logical outcome used to resolve a navigation case.
W Zparam options onfiguration options for the dialog.
W Zparam params #arameters to send to the view displayed in a dialog.
W/
pu-lic a-stract void openDialog98tring outcomeH 5ap<8tringHO-,ect> optionsH
5ap<8tringH7ist<8tring>> params:;
/WW
W lose a dialog.
W Zparam data Optional data to pass -ac2 to a dialogCeturn event.
W/
pu-lic a-stract void closeDialog9O-,ect data:;
$on%i&uration
D# reCuire the +o((o'in, con+i,uration to be &reent in +ace con+i, +i(e.
<application>
<action3listener>
org.primefaces.application.Dialog<ction7istener
</action3listener>
<navigation3handler>
org.primefaces.application.DialogJavigation4andler
</navigation3handler>
<view3handler>
org.primefaces.application.Dialog@iew4andler
</view3handler>
</application>
)ettin& Started
Si"&(et ue cae o+ D# i o&enin, an 0ht"( vie' (i3e cars.$html in a dia(o,K
510
PrimeFaces Users Guide
<!DO!"#$ html>
<html &mlns'(http://www.w).org/*+++/&html( &mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:p'(http://primefaces.org/ui(>
<h:head>
<title>ars</title>
</h:head>
<h:-ody>
<p:data!a-le var'(car( value'(./ta-le=ean.cars0(>
//columns
</p:data!a-le>
</h:-ody>
</html>
7n the hot &a,eE ca(( ReCuet*onte0t.o&enDia(o,?Ivie'na"eI@K
<p:command=utton value'(@iew ars( action7istener'(./host=ean.view0( />
pu-lic void view9: /
CeBuestonte&t.geturrentInstance9:.openDialog9(viewars(:;
0
7nce the re&one i received +ro" the reCuet caued by co""and button a dia(o, 'ou(d be
,enerated 'ith the content o+ vie'*ar.0ht"(. 9it(e o+ the dia(o, i retrieved +ro" the tit(e e(e"ent
o+ the vie'*arE in thi caeE *ar.
Dialo& $on%i&uration
7ver(oaded o&enDia(o, "ethod &rovide advanced con+i,uration re,ardin, the viua( o+ dia(o,
a(on, 'ith &ara"eter to end to the dia(o, content.
<p:command=utton value'(@iew ars( action7istener'(./host=ean.viewustomiOed0( />
pu-lic void view9: /
5ap<8tringHO-,ect> options ' new 4ash5ap<8tringH O-,ect>9:;
options.put9(modal(H true:;
options.put9(dragga-le(H false:;
options.put9(resiOa-le(H false:;
options.put9(content4eight(H )A0:;
CeBuestonte&t.geturrentInstance9:.openDialog9(viewars(H optionsH null:;
0
511
PrimeFaces Users Guide
.ere i the +u(( (it o+ con+i,uration o&tionK
Name Default Type Description
"oda( 0 1oo(ean *ontro( "oda(ity o+ the dia(o,.
rei=ab(e 1 1oo(ean When enab(edE "a3e dia(o, rei=ab(e.
dra,,ab(e 1 1oo(ean When enab(edE "a3e dia(o, dra,,ab(e.
'idth auto Inte,er Width o+ the dia(o,.
hei,ht auto Inte,er .ei,ht o+ the dia(o,.
contentWidth 4-0 Inte,er Width o+ the dia(o, content.
content.ei,ht auto Inte,er .ei,ht o+ the dia(o, content.
c(oab(e true 1oo(ean Whether the dia(o, can be c(oed or not.
Data $ommunication
!a,e di&(ayed in the dia(o, can &a data bac3 to the &arent &a,e. 9he tri,,er co"&onent need to
have dialog+eturn a/a0 behavior event to hoo3Bin 'hen data i returned +ro" dia(o,.
<!DO!"#$ html>
<html &mlns'(http://www.w).org/*+++/&html( &mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:p'(http://primefaces.org/ui(>
<h:head>
<title>ars</title>
</h:head>
<h:-ody>
<p:data!a-le var'(car( value'(./ta-le=ean.cars0(>
//columns
<p:column header!e&t'(8elect(>
<p:command=utton icon'(ui3icon3search(
action7istener'(./ta-le=ean.selectar6romDialog9car:0( />
</p:column>
</p:data!a-le>
</h:-ody>
</html>
pu-lic void selectar6romDialog9ar car: /
CeBuestonte&t.geturrentInstance9:.closeDialog9car:;
0
At hot &a,eE the button that tri,,ered the dia(o, hou(d have dialog+eturn event.
512
PrimeFaces Users Guide
<p:command=utton value'(@iew ars( action7istener'(./host=ean.viewars0(>
<p:a,a& event'(dialogCeturn( listener'(./host=ean.handleCeturn0(
</p:command=utton>
pu-lic void view9: /
CeBuestonte&t.geturrentInstance9:.openDialog9(viewars(:;
0
pu-lic void handleCeturn98elect$vent event: /
ar car ' 9ar: event.getO-,ect9:;
0
"emar+s on Dialo& Framewor+
I+ you are uin, A&ache 9rinidad or A1o Rich#aceE !ri"e#ace 9he"e Ga((ery inc(ude
9rinidad
*aab(anca and Rich#ace 1(ueS3y the"e. Mou can ue thee the"e to "a3e
!ri"e#ace (oo3 (i3e 9rinidad or Rich#ace co"&onent durin, "i,ration.
G 9o chan,e the ty(e o+ a &articu(ar co"&onent intead o+ a(( co"&onent o+ a"e ty&e ue
na"e&acin,E e0a"&(e be(o' de"ontrate ho' to chan,e header o+ a(( &ane(.
.ui3panel3title-ar /
//css
0
or
.ui3panel3title-ar.ui3widget3header /
//css
0
9o a&&(y c on a &articu(ar &ane(K
<p:panel stylelass'(custom(>
...
</p:panel>
.custom .ui3panel3title-ar /
//css
0
525
PrimeFaces Users Guide
8. PrimeFaces Push
!ri"e#ace !uh ?!#!@ i a &uh +ra"e'or3 bui(t on to& o+ At"o&here. At"o&here creator
AyncI7 i a &artner co"&any o+ !ri"e9e3 and the deve(o&er o+ !#!. At"o&here i hi,h(y
ca(ab(eE u&&ort evera( container and bro'erE uti(i=e variou tran&ort uch a 'eboc3etE
eeE (on,B&o((in,E trea"in, and /on&. #or "ore in+or"ation &(eae viitK
https://githu-.com/<tmosphere/atmosphere
8.1 Setup
Atmosphere
At"o&here i reCuired to run !ri"e#ace !uhE in your &o".0"( de+ine the de&endency aK
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere3runtime</artifactId>
<version>A.*.)</version>
</dependency>
Push Serlet
!uh Serv(et i ued a a ,ate'ay +or c(ient.
<servlet>
<servlet3name>#ush 8ervlet</servlet3name>
<servlet3class>org.primefaces.push.#ush8ervlet</servlet3class>
<async3supported>true</async3supported>
</servlet>
<servlet3mapping>
<servlet3name>#ush 8ervlet</servlet3name>
<url3pattern>/primepush/W</url3pattern>
</servlet3mapping>
526
PrimeFaces Users Guide
8.2 Annotations
Dei,n o+ !#! i annotation driven centra(i=ed around the "ain b!uhEnd!oint.
GPush/ndPoint
9he eaiet 'ay to create !#! a&&(ication i by uin, the HPushEndPoint annotation. 9hi
annotation i"&(i+ie the &roce to bui(d an a&&(ication uin, !#! avodin, the need to interact 'ith
At"o&here "ore o&hiticated A!I. 9hi annotation i,ni+icant(y reduce the nu"ber o+ code
reCuired to bui(d a &o'er+u( rea( ti"e a&&(ication by tran&arent(y inta((in, At"o&here
co"&onent (i3e heartbeatE id(e connection detectionE diconnect tate recovery etc. It a(o a((o'
the ue o+ e0terna( de&endency in/ection +ra"e'or3 (i3e *DIE S&rin, or Guice. Annotation &rovide
one attribute ca((ed &ath to de+ine the reource &ath.
pat"N 9he &ath to the reource.
9he de+au(t i IQI o i+ your have "a&&ed the !uhServ(et to IQJIE a(( reCuet 'i(( be de(ivered to
your annotated c(a. Mou can a(o cuto"i=e the &ath. 9he &ath va(ue 'i(( be ued to "a& an
inco"in, reCuet uri &ath to an annotated !uhEnd&oint c(a.
Z#ush$nd#oint9(/chat(:
GSin&leton
Sin,(eton annotation i ued to +orce creatin, a in,(eE thread a+e intance o+ a !uhEnd&oint
annotated c(ae. #or e0a"&(eE i+ your a&&(ication et the b!uhEnd&ointZ &ath attribute 'ith a
&athE by de+au(t a ne' intance o+ the annotated c(ae 'i(( be created. When annotated 'ith
Sin,(eton ho'everE a in,(e c(a 'i(( be created.
G;n;pen
9he 7n7&en?@ 'i(( be invo3ed 'hen the under(yin, connection i ready to be uedE e., +or 'rite
o&eration. Annotated "ethod need to ta3e the +or" o+K
ZOnOpen
pu-lic void onOpen9:;
ZOnOpen
pu-lic void onOpen9Cemote$ndpoint r:;
ZOnOpen
pu-lic void onOpen9Cemote$ndpoint rH $vent=us e:;
9he Re"oteEnd&oint re&reent the &hyica( connection and can be ued to 'rite o"e data bac3 to
the bro'er. 9he Event1u can be ued to +ire "ea,e to one or "ore Re"oteEnd&oint uin,
re,e0 e0&reion.
G;nMessa&e
9he 7n8ea,e?@ 'i(( be invo3ed 'hen a "ea,e i ready to be de(iverE e., a a reu(t o+ a
Event1u &ub(ih o&eration or 'hen a bro'er i !7S9in, o"e byte. 9he annotationZ attribute
avai(ab(e areK
527
PrimeFaces Users Guide
encodersN A (it o+ `Encodera?@ that 'i(( be ued to encode the annotated "ethod return va(ue. 9he
returned va(ue o+ an annotated 7n8ea,e "ethod 'i(( be broadcated to a(( reource aociated
'ith the 1roadcaterE aociated 'ith thi annotated c(ae.
decodersN A (it o+ `Decodera?@ ued to decode a broadcated "ea,e into an ob/ect "atchin, the
"ethod i,nature.
1oth o+ the encoder and decoder can be chainedE "eanin, the returned va(ue o+ an encoderB
decoder can be ued a an in&ut +or the ne0t one.
ZOn5essage9encoders ' /Y8OJ$ncoder.class0:
pu-lic 8tring on5essage98tring count: /
return count;
0
7ut o+ the bo0E !ri"e#ace !US. &rovide AS7< i"&(e"entation that areK
B or,.&ri"e+ace.&uh.i"&(.AS7<Encoder
B or,.&ri"e+ace.&uh.i"&(.AS7<Decoder
It i a(o eay to create your o'n encoderBdecoder by i"&(e"entin, org.primefaces.push.Encoder
and org.primefaces.push.'ecoder inter+ace.
G;n$lose
9he b7n*(oe?@ 'i(( be invo3ed 'hen the c(ient diconnectE e., c(oe the connectionE 'hen a
net'or3 outa,e ha&&en or 'hen a &ro0y c(oe the connection. Annotated "ethod need to ta3e the
+or" o+K
ZOnlose
pu-lic void onlose9:;
ZOnlose
pu-lic void onlose9Cemote$ndpoint r:;
ZOnlose
pu-lic void onlose9Cemote$ndpoint rH $vent=us e:;
7n(y one "ethod in a c(a can be annotated 'ith b7n*(oe.
GPathParam
b!ath!ara" i ued to auto"atica((y &are the &ath and ai,n &ath to3en to c(a variab(e.
Z#ush$ndpoint9(/somepath//room0//user0(:
Z8ingleton
pu-lic class hatCesource /
Z#ath#aram9(room(:
private 8tring room;
Z#ath#aram9(user(:
private 8tring username;
//...
528
PrimeFaces Users Guide
8.# API
"emote/ndPoint
9he Re"oteEnd&oint?@ c(a re&reent the re"ote connectionE e., the 1ro'er. An intance o+
Re"oteEnd&oint ho(d in+or"ation about the headerE CueryStrin,E bodyE uriE &ath and &ath e,"ent
that can be ued +or "ani&u(atin, the inco"in, reCuet. I+ you are +a"i(iar 'ith the Serv(et
I.tt&Serv(etReCuetIE the Re"oteEnd&oint can be een a an i"&roved verion. Mou can a(o ue a
Re"oteEnd&ointX'rite to 'rite bac3 "ea,e that 'i(( be de(ivered uniCue(y to the bro'er.
/ent.us
A ditributed (i,ht'ei,ht event bu 'hich can enco"&a "u(ti&(e !uhEnd&oint intance. 9he
event bu i"&(e"ent &ub(ih Q ubcribe and &oint to &oint "ea,in,. 8ea,e ent over the
event bu can be o+ any ty&e. #or &ub(ih Q ubcribeE "ea,e can be &ub(ihed to a Aava c(a
annotated 'ith the `!uhEnd&ointXva(uea?@ uin, one o+ the "ethod annotated 'ith `7n8ea,ea?@.
9he Event1u i the reco""ended 'ay +or de(iverin, "ea,e. Event1u i retrieved viaK
$vent=us event=us ' $vent=us6actory.getDefault9:.event=us9:;
7nce an Event1u intance i avai(ab(eE &ub(ihin, data to ubcriber i done 'ith over(oaded
&ub(ih "ethod.
pu&lis"76&ject o84 #ire ,iven ob/ect to a(( connected Re"oteEnd!oint.
pu&lis"7)tring pat"9 6&ject o84 #ire ,iven ob/ect to Re"oteEnd!oint that connected to the &ath.
pu&lis"7)tring pat"9 6&ject o9 eply reply84 #ire ,iven ob/ect to Re"oteEnd!oint that
connected to the &ath by &ain, a Re&(y intance. Re&(y i an inter+ace 'ith a ca((bac3 ca((ed
completedString path! that i invo3ed 'hen the Event1u de(ivered the "ea,e to the
!uhEnd!oint that "atche the &ath ued to initiate the &ub(ih o&eration.
8.' Soc+et $omponent
Soc3et i a !ri"e#ace co"&onent that hand(e the connection bet'een the erver and the bro'erE
co""on 'ay to ue oc3et i by de+inin, a &ath and a ca((bac3 to hand(e broadcat.
<p:push channel'(/chat( onmessage'(handle#u-lish(/>
See Soc3et co"&onent docu"entation +or the +u(( (it o+ avai(ab(e o&tion.
$lient Side API
Wid,etN PrimeFaces.widget.Soc"et
!et"od Params eturn Type Description
connect?uri@ uri void *onnect to ,iven uri.
&uh?/on@ /on void !uhe data +ro" c(ient ide.
diconnect B void Diconnect +ro" channe(.
529
PrimeFaces Users Guide
8.3 Puttin& It All 1oðer
!ri"e#ace Sho'cae ha variou &uh de"oE in thi ection t'o o+ the" are covered.
8.3.1 $ounter
*ounter i a ,(oba( counter 'here each button c(ic3 incre"ent the count va(ue and ne' va(ue i
&uhed to a(( ubcriber.
>ie' &a,e ha an out&ut9e0t to di&(ay the va(ueE a button to incre"ent current va(ue to &uhE a
oc3et co"&onent to connect to Qcounter channe( and +ina((y the on8ea,e c(ient ide ca((bac3 to
u&date the UI.
<h:form>
<h:output!e&t value'(./counter@iew.count0( stylelass'(display( />
<p:command=utton value'(lic2( action7istener'(./counter@iew.increment0( />
</h:form>
<p:soc2et on5essage'(handle5essage( channel'(/counter( />
<script type'(te&t/,avascript(>
function handle5essage9data: /
V9?.display?:.te&t9data:;
0
</script>
pac2age org.primefaces.e&les.push.counter;
import ,ava.io.8erialiOa-le;
import ,ava&.faces.-ean.<pplication8coped;
import ,ava&.faces.-ean.5anaged=ean;
import org.primefaces.push.$vent=us;
import org.primefaces.push.$vent=us6actory;
Z5anaged=ean
Z<pplication8coped
pu-lic class ounter@iew implements 8erialiOa-le/
private volatile int count;
pu-lic int getount9: /
return count;
0
pu-lic void setount9int count: /
this.count ' count;
0
pu-lic void increment9: /
count>>;
$vent=us event=us ' $vent=us6actory.getDefault9:.event=us9:;
event=us.pu-lish9(/counter(H 8tring.valueOf9count::;
0
0
530
PrimeFaces Users Guide
incre"ent button action(itener +irt add one to the counter va(ueE ,et an Event1u and then
&uhe the ne' va(ue to a(( connected c(ient. #ina( &iece i 'ritin, the *ounterReource to hand(e
"ea,e 'henever a data i &uhed.
pac2age org.primefaces.e&les.push.counter;
import org.primefaces.push.annotation.On5essage;
import org.primefaces.push.annotation.#ush$ndpoint;
import org.primefaces.push.impl.Y8OJ$ncoder;
Z#ush$ndpoint9(/counter(:
pu-lic class ounterCesource /
ZOn5essage9encoders ' /Y8OJ$ncoder.class0:
pu-lic 8tring on5essage98tring count: /
return count;
0
0
In cae youd (i3e to u&date co"&onent andQor invo3e (itener in your bac3in, bean on broadcatE
you can ue the o&tiona( message a/a0 behavior to i"&(e"ent the a"e +unctiona(ity but 'ith an
e0tra reCuet.
<h:form id'(form(>
<h:output!e&t id'(out( value'(./glo-alounter.count0( />
<p:command=utton value'(lic2( action7istener'(./glo-alounter.increment0( />
</h:form>
<p:soc2et channel'(/counter(>
<p:a,a& event'(message( update'(form:out( />
</p:soc2et>
531
PrimeFaces Users Guide
8.3.2 FacesMessa&e
9hi a"&(e ho' ho' to &uh #ace8ea,e +ro" one c(ient to a(( other and di&(ay the" uin,
Gro'( *o"&onent.
<p:growl widget@ar'(growl( showDetail'(true( />
<h:form>
<p:panel header'(Irowl(>
<h:panelIrid columns'(A(>
<p:output7a-el for'(summary( value'(8ummary: ( />
<p:input!e&t id'(summary( value'(./growl=ean.summary0( reBuired'(true( />
<p:output7a-el for'(detail( value'(Detail: ( />
<p:input!e&t id'(detail( value'(./growl=ean.detail0( reBuired'(true( />
</h:panelIrid>
<p:command=utton value'(8end( action7istener'(./growl=ean.send0( />
</p:panel>
</h:form>
<p:soc2et on5essage'(handle5essage( channel'(/notify( />
<script type'(te&t/,avascript(>
function handle5essage9facesmessage: /
facesmessage.severity ' ?info?;
#69?growl?:.show9QfacesmessageS:;
0
</script>
pac2age org.primefaces.e&les.view;
import ,ava&.faces.application.6aces5essage;
import ,ava&.faces.-ean.5anaged=ean;
import ,ava&.faces.-ean.CeBuest8coped;
import ,ava&.faces.conte&t.6acesonte&t;
import ,ava&.faces.event.<ction$vent;
import org.primefaces.push.$vent=us;
import org.primefaces.push.$vent=us6actory;
Z5anaged=ean
ZCeBuest8coped
pu-lic class Irowl=ean /
private final static 8tring 4<JJ$7 ' (/notify(;
private 8tring te&tH summaryH detail;
//getters3setters
pu-lic void send9: /
$vent=us event=us ' $vent=us6actory.getDefault9:.event=us9:;
event=us.pu-lish94<JJ$7H new 6aces5essage9summaryH detail::;
0
0
532
PrimeFaces Users Guide
<oti+yReource i"&(y encode the &uhed "ea,e a AS7<.
pac2age org.primefaces.e&les.push.notify;
import ,ava&.faces.application.6aces5essage;
import org.primefaces.push.annotation.On5essage;
import org.primefaces.push.annotation.#ush$ndpoint;
import org.primefaces.push.impl.Y8OJ$ncoder;
Z#ush$ndpoint9(/notify(:
pu-lic class JotifyCesource /
ZOn5essage9encoders ' /Y8OJ$ncoder.class0:
pu-lic 6aces5essage on5essage96aces5essage message: /
return message;
0
0
533
PrimeFaces Users Guide
8.5 1ips and 1ric+s
Dynamic Paths
*(ient ide A!I 'ou(d be handy to create dyna"ic channe(E channe( na"e o+ the oc3et doe not
need to be tatic and you can create dyna"ic channe( on runti"e ince a channe( i baica((y a &ath
na"e. b!ath!ara" i very handy to auto"atica((y &are the !ath and ai,n the &ath to3en to
variab(e.
See chat a"&(e in ho'cae +or an e0a"&(e o+ dyna"ic channe( ued to end &rivate "ea,e.
Pro-ies
!ro0ie are &rob(e"atic not /ut +or !ri"e#ace !uh B At"o&here o(ution but in a(( o(ution. I+
your &ro0y u&&ort 'eboc3etE "a3e ure to add the neceary con+i,uration. Another o(ution
that i conidered a a 'or3around i to override the de+au(t uri o+ the &uh erver. De+au(t uri i
&rotoco(NQQconte0t!athQ&ri"e&uhQchanne(E +or e0a"&(e !ri"e#ace on(ine ho'cae i runnin, on
/etty that i behind an a&ache "od &ro0y 'hich doent u&&ort 'eboc3et at ti"e o+ the 'ritin,.
So(ution i to con+i,ure !ri"e#ace to ue another &uh erver (i3eK
<conte&t3param>
<param3name>primefaces.#K84L8$C@$CLKC7</param3name>
<param3value>http://www.primefaces.org:G0G0</param3value>
</conte&t3param>
So that oc3et co"&onent by&ae the &ro0y and direct(y co""unicate 'ith the a&&(ication.
Supported Serer and $lient /nironments
At"o&here doe a a,reat /ob in u&&ortin, di++erent erver and bro'er. See the detai(ed (it atK
https://githu-.com/<tmosphere/atmosphere/wi2i/8upported31e-8ervers3and3=rowsers
Scalability
At"o&here i bui(d to ca(e via &(u,in uch a A8SE Redi0E F8!!E .a=e(cat and "ore. Re+er to
at"o&here docu"entation to ee ho' to con+i,ure at"o&here in "ore than one erver.
!uhServ(et e0tend +ro" At"o&hereServ(et o any con+i,uration o&tion +or At"o&hereServ(et
a(o a&&(ie !uhServ(et.
534
PrimeFaces Users Guide
1:. PrimeFaces Mobile
!ri"e#ace 8obi(e ?!#8@ i a UI ;it to create AS# a&&(ication o&ti"i=ed +or "obi(e device. !#8
i bui(t on to& o+ /Duery 8obi(eE a touchBo&ti"i=ed .9865 UI +ra"e'or3 &rovidin, u&&ort +or
variou &(at+or".
In addition to the ea"(e inte,ration 'ith /Duery 8obi(eE !#8 +eature a 8obi(e Render3it +or
&o&u(ar !ri"e#ace co"&onentE a/a0 +ra"e'or3 e0tenionE "obi(e a/a0 behavior eventE
inte,rated navi,ation "ode(E (a=y (oadin, o+ &a,eE re&onive 'id,et and "ore.
1*.1 -etup
8obi(e hi& 'ith !ri"e#ace *ore o no additiona( do'n(oad i reCuired.
$on%i&uration
A "obi(e navi,ation hand(er i neceary inide +ace con+i,uration to enab(e navi,ation u&&ort.
<application>
<navigation3handler>
org.primefaces.mo-ile.application.5o-ileJavigation4andler
</navigation3handler>
</application>
1a&lib
!#8 &rovide "obi(e &eci+ic co"&onent 'ith the +o((o'in, ta,(ib.
&mlns:pm'(http://primefaces.org/mo-ile(
"ender@it
Render;it i the core &art o+ !#8 +eaturin, o&ti"i=ed renderer +or "obi(e environ"ent. 9here
are t'o "ain 'ay to enab(e !#8 Render;it.
*ore vie' ta, ha a render;itId attribute to et the renderer 3it o+ the &a,e.
<f:view renderTitId'(#CI5$6<$8L5O=I7$( />
I+ your a&&(ication +u((y conit o+ "obi(e &a,eE then a ,(oba( con+i,uration in +ace con+i,uration
+i(e hou(d be &re+erred intead o+ &er &a,e con+i,uration.
<application>
<default3render32it3id>#CI5$6<$8L5O=I7$</application>
</application>
535
PrimeFaces Users Guide
1*.2 Pa%e)
A "obi(e &a,e i a re,u(ar +ace(et 0ht"( +i(e 'ith "obi(e &a,e container de+ined 'ith &"N&a,e.
<!DO!"#$ html>
<html &mlns'(http://www.w).org/*+++/&html(
&mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:f'(http://,ava.sun.com/,sf/core(
&mlns:p'(http://primefaces.org/ui(
&mlns:pm'(http://primefaces.org/mo-ile(>
<f:view renderTitId'(#CI5$6<$8L5O=I7$( />
<h:head>
</h:head>
<h:-ody>
<pm:page>
<pm:header title'(=asic #age(></pm:header>
<pm:content></pm:content>
</pm:page>
</h:-ody>
</html>
A in,(e &a,e 0ht"( vie' can have "ore than one &a,e. 1y de+au(t the +irt &a,e i viib(e on (oad.
<!DO!"#$ html>
<html &mlns'(http://www.w).org/*+++/&html(
&mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:f'(http://,ava.sun.com/,sf/core(
&mlns:p'(http://primefaces.org/ui(
&mlns:pm'(http://primefaces.org/mo-ile(>
<f:view renderTitId'(#CI5$6<$8L5O=I7$( />
<h:head>
</h:head>
<h:-ody>
<pm:page id'(main(>
<pm:header title'(5ain #age(></pm:header>
<pm:content></pm:content>
</pm:page>
<pm:page id'(second(>
<pm:header title'(8econd #age(></pm:header>
<pm:content></pm:content>
</pm:page>
</h:-ody>
</html>
536
PrimeFaces Users Guide
1*.2 /a,i%ation)
!#8 u&&ort a(( 3ind o+ tandard navi,ation 'ith the addition o+ a cuto" navi,ation "ode(.
Internal
Interna( navi,ation i bet'een &a,e in the a"e 0ht"( vie'. 7utco"e hou(d have the pm4 &re+i0
+or thi 3ind o+ navi,ation. Uin, the "u(ti &a,e a"&(e at ection 10.1K
<p:-utton outcome'(pm:second( />
<p:lin2 outcome'(pm:second( />
1utton and 6in3 co"&onent di&(ay the &a,e 'hoe id i second. In cae youOd (i3e to navi,ate
a+ter a !7S9 reCuetE ua,e 'ou(d be i"i(ar.
<p:command=utton value'(Io to 8econd( action'(./-ean.go0( />
pu-lic 8tring go9: /
return (pm:second(;
0
/-ternal
E0terna( navi,ation to another 0ht"( in a"e do"ain or a reource in another do"ain i a"e a
tandard a&&roach.
<p:-utton outcome'(/ui/home( value'(4ome( />
<p:-utton href'(http://www.primefaces.org( value'(4ome( />
1ransitions
>ariou ani"ation are avai(ab(e to run durin, the navi,ation. <a"e o+ the e++ect i a&&ended to the
outco"e. In additionE reverse o&tion i &rovided +or bac3 navi,ation.
<p:-utton outcome'(pm:secondMtransition'pop( />
<p:lin2 outcome'(pm:secondMtransition'flipRreverse'true( />
6it o+ &oib(e tranition i fadeE popE flipE turnE flowE slideE slidefadeE slideup and slidedown. #ade
i the de+au(t tranition and to turn o++ ani"ationE et none a the va(ue.
$lient API
A c(ient ide A!I i avai(ab(e to navi,ate "anua((y +ro" a cuto" /avacri&t code. Si,nature iK
PrimeFaces.-obile.navigateto6 cfg!I
#rime6aces.5o-ile.navigate9?.second?H /
reverse: true[falseH
transition: ?fade?
0:;
537
PrimeFaces Users Guide
1*.3 Co'ponent)
1:.#.1 $ontent
*ontent i container co"&onent +or the content area o+ a &a,e.
In%o
9a, content
*o"&onent *(a org.primefaces.mo&ile.component.content.#ontent
*o"&onent 9y&e org.primefaces.mo&ile.#ontent
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.#ontentenderer
Renderer *(a org.primefaces.mo&ile.component.content.#ontentenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
)ettin& Started with the $ontent
*ontent i a chi(dren co"&onent o+ a &a,e.
<pm:page>
<pm:content>
//page content
</pm:content>
</pm:page>
538
PrimeFaces Users Guide
1:.#.2 Field
#ie(d i a re&onive (ayout co"&onent +or (abe(Bin&ut &air.
In%o
9a, field
*o"&onent *(a org.primefaces.mo&ile.component.field.+ield
*o"&onent 9y&e org.primefaces.mo&ile.+ield
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.+ieldenderer
Renderer *(a org.primefaces.mo&ile.component.field.+ieldenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
)ettin& Started with the Field
#ie(d i ued a the container o+ a (abe( and an in&ut co"&onent. A a re&onive co"&onentE +ie(d
di&(ay the o&ti"a( &(ace"ent +or it chi(dren baed on avai(ab(e 'idth.
<pm:field>
<p:output7a-el for'(te&t( value'(!e&t:( />
<p:input!e&t id'(t&t( />
</pm:field>
539
PrimeFaces Users Guide
1:.#.# Footer
#ooter i container co"&onent +or the botto" area o+ a &a,e.
In%o
9a, footer
*o"&onent *(a org.primefaces.mo&ile.component.footer.+ooter
*o"&onent 9y&e org.primefaces.mo&ile.+ooter
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.+ooterenderer
Renderer *(a org.primefaces.mo&ile.component.footer.+ooterenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE 'hen et
to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent intance
in a bac3in, bean
tit(e nu(( Strin, 9it(e te0t o+ the +ooter.
+i0ed +a(e 1oo(ean !oition the +ooter a +i0ed on cro((.
the"e nu(( Strin, S'atch o+ the co"&onent.
ta&9o,,(e true 1oo(ean #or +i0ed +ooterE et 'hether the +i0ed too(barO viibi(ity can be
to,,(ed by ta&&in, on the &a,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
)ettin& Started with the Footer
#ooter i a chi(dren co"&onent o+ a &a,e.
<pm:page>
<pm:footer title'(6ooter(></pm:footer>
</pm:page>
540
PrimeFaces Users Guide
1:.#.' (eader
.eader i container co"&onent +or the to& area o+ a &a,e.
In%o
9a, "eader
*o"&onent *(a org.primefaces.mo&ile.component."eader.(eader
*o"&onent 9y&e org.primefaces.mo&ile.(eader
*o"&onent #a"i(y org.primefaces.mo&ile.component.(eader
Renderer 9y&e org.primefaces.mo&ile.component.(eaderenderer
Renderer *(a org.primefaces.mo&ile.component."eader.(eaderenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE 'hen et
to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent intance
in a bac3in, bean
tit(e nu(( Strin, 9it(e te0t o+ the header.
+i0ed +a(e 1oo(ean !oition the header a +i0ed on cro((.
the"e nu(( Strin, S'atch o+ the co"&onent.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
)ettin& Started with the (eader
.eader i a chi(dren co"&onent o+ a &a,e.
<pm:page>
<pm:header title'(6ooter(></pm:header>
</pm:page>
541
PrimeFaces Users Guide
1:.#.3 InputSlider
In&utS(ider i an in&ut co"&onent 'ith a touch enab(ed (ider.
In%o
9a, input)lider
*o"&onent *(a org.primefaces.mo&ile.component.inputslider..nput)lider
*o"&onent 9y&e org.primefaces.mo&ile..nput)lider
*o"&onent #a"i(y org.primefaces.mo&ile.component.
Renderer 9y&e org.primefaces.mo&ile.component..nput)liderenderer
Renderer *(a org.primefaces.mo&ile.component.inputslider..nput)liderenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not be
rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent.
converter nu(( 7b/ect An e( e0&reion or a (itera( te0t that de+ine a converter
+or the co"&onent. When itZ an E6 e0&reionE itZ
reo(ved to a converter intance. In cae itZ a tatic te0tE
it "ut re+er to a converter id.
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i e0ecuted at
a&&(y reCuet va(ue &hae +or thi co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 7b/ect A "ethod bindin, e0&reion that re+er to a "ethod
va(idation, the in&ut.
va(ue*han,e6itener nu(( 7b/ect A "ethod bindin, e0&reion that re+er to a "ethod +or
hand(in, a va(uechan,eevent.
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
542
PrimeFaces Users Guide
Name Default Type Description
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
"in>a(ue 0 Inte,er 8ini"u" va(ue o+ the (ider.
"a0>a(ue 100 Inte,er 8a0i"u" va(ue o+ the (ider.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
te& 1 Strin, Ste& +actor to a&&(y on (ider "ove.
diab(ed +a(e 1oo(ean Diab(e or enab(e the (ider.
(abe( nu(( Strin, Uer &reentab(e na"e.
hi,h(i,ht +a(e 1oo(ean .i,h(i,ht the va(ue ran,e 'hen enab(ed.
)ettin& Started with the InputSlider
In&utS(ider reCuire an inte,er a it va(ue.
<pm:input8lider value'(50( />
<pm:input8lider value'(./-ac2ing@iew.integer#roperty0( />
.oundaries
0 and 100 are the de+au(t boundarieE thee can be cuto"i=ed uin, min2alue and ma$2alue.
<pm:input8lider min@alue'(*00( ma&@alue'(A00( value'(./-ac2ing@iew.int#roperty0(/>
543
PrimeFaces Users Guide
1:.#.5 Pa&e
!a,e i "ain co"&onent to de+ine an interna( &a,e 'ithin an 0ht"(.
In%o
9a, page
*o"&onent *(a org.primefaces.mo&ile.component.page.Page
*o"&onent 9y&e org.primefaces.mo&ile.Page
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.Pageenderer
Renderer *(a org.primefaces.mo&ile.component.page.Pageenderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE 'hen et
to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent intance
in a bac3in, bean
tit(e nu(( Strin, 9it(e te0t o+ the &a,e.
the"e nu(( Strin, S'atch o+ the &a,e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
(a=y +a(e 1oo(ean 6a=y (oadin, vie' are not rendered on initia( &a,e (oad to i"&rove
&er+or"ance and intead (a=i(y (oaded on de"and 'hen there are
+irt navi,ated to.
)ettin& Started with the Pa&e
!(eae ee ection 10.1 !a,e +or the ua,e and "ore in+or"ation.
544
PrimeFaces Users Guide
1:.#.6 "an&eSlider
Ran,eS(ider i a ,rou&in, co"&onent +or dua( (ider to create a ran,e e(ection.
In%o
9a, range)lider
*o"&onent *(a org.primefaces.mo&ile.component.rangeslider.ange)lider
*o"&onent 9y&e org.primefaces.mo&ile.ange)lider
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.ange)lider
Renderer *(a org.primefaces.mo&ile.component.rangeslider.ange)lider
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the co"&onentE 'hen et
to +a(e co"&onent 'i(( not be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide UI*o"&onent intance
in a bac3in, bean
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
hi,h(i,ht +a(e 1oo(ean .i,h(i,ht the va(ue ran,e 'hen enab(ed.
)ettin& Started with the "an&eSlider
Ran,eS(ider need t'o (ider a chi(drenE +irt (ider i +or the tart o+ ran,e and econd +or the end.
<pm:range8lider>
<pm:input8lider value'(./-ac2ing@iew.start0(/>
<pm:input8lider value'(./-ac2ing@iew.end0(/>
</pm:range8lider>
545
PrimeFaces Users Guide
1:.#.7 Switch
S'itch i an in&ut co"&onent to e(ect a boo(ean va(ue.
In%o
9a, s0itc"
*o"&onent *(a org.primefaces.mo&ile.component.uis0itc".-.)0itc"
*o"&onent 9y&e org.primefaces.mo&ile.-.)0itc"
*o"&onent #a"i(y org.primefaces.mo&ile.component
Renderer 9y&e org.primefaces.mo&ile.component.-.)0itc"enderer
Renderer *(a org.primefaces.mo&ile.component.uis0itc".-.)0itc"enderer
Attributes
Name Default Type Description
id nu(( Strin, UniCue identi+ier o+ the co"&onent
rendered true 1oo(ean 1oo(ean va(ue to &eci+y the renderin, o+ the
co"&onentE 'hen et to +a(e co"&onent 'i(( not
be rendered.
bindin, nu(( 7b/ect An e( e0&reion that "a& to a erver ide
UI*o"&onent intance in a bac3in, bean
va(ue nu(( 7b/ect >a(ue o+ the co"&onent.
converter nu(( 7b/ect An e( e0&reion or a (itera( te0t that de+ine a
converter +or the co"&onent. When itZ an E6
e0&reionE itZ reo(ved to a converter intance. In
cae itZ a tatic te0tE it "ut re+er to a converter id.
i""ediate +a(e 1oo(ean When et trueE &roce va(idation (o,ic i
e0ecuted at a&&(y reCuet va(ue &hae +or thi
co"&onent.
reCuired +a(e 1oo(ean 8ar3 co"&onent a reCuired
va(idator nu(( 7b/ect A "ethod bindin, e0&reion that re+er to a
"ethod va(idation, the in&ut.
va(ue*han,e6itener nu(( 7b/ect A "ethod bindin, e0&reion that re+er to a
"ethod +or hand(in, a va(uechan,eevent.
546
PrimeFaces Users Guide
Name Default Type Description
reCuired8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen reCuired +ie(d va(idation
+ai(.
converter8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen converion +ai(.
va(idator8ea,e nu(( Strin, 8ea,e to be di&(ayed 'hen va(idation +ie(d.
on6abe( on Inte,er 8ini"u" va(ue o+ the (ider.
o++6abe( o++ Inte,er 8a0i"u" va(ue o+ the (ider.
(abe( nu(( Strin, Uer &reentab(e na"e.
ty(e nu(( Strin, In(ine ty(e o+ the co"&onent.
ty(e*(a nu(( Strin, Sty(e c(a o+ the co"&onent.
(abe( nu(( Strin, Uer &reentab(e na"e.
diab(ed +a(e 1oo(ean Diab(e or enab(e the 'itch.
onchan,e +a(e Strin, *(ient ide ca((bac3 to e0ecute on chan,e event.
)ettin& Started with the Switch
>a(ue o+ 'itch hou(d be a boo(ean &ro&ertyE i+ the va(ue i +a(e o++6abe( 'ou(d be di&(ayed and
on6abe( 'ou(d be ued other'ie.
<pm:switch value'(./-ac2ing@iew.-oolean#roperty0( />
547
PrimeFaces Users Guide
1*.4 0ender1it
In addition to the "obi(e co"&onentE variou core co"&onent have been enhanced 'ith "obi(e
renderer o that a"e co"&onent can be o&ti"i=ed +or a "obi(e bro'er. Since ua,e i a"e in
de3to& and "obi(e environ"entE re+er to cha&ter ) +or docu"entation about thee co"&onent.
1*.4.1 AccordionPanel
1*.4.2 AutoCo'plete
1*.4.3 Button
548
PrimeFaces Users Guide
1:.'.' $alendar
1*.4.5 DataLi)t
1:.'.5 Dialo&
1:.'.6 File4pload
549
PrimeFaces Users Guide
1:.'.7 )rowl
1:.'.8 Input1e-t
1:.'.1: Input1e-tarea
1:.'.11 *in+
1:.'.12 Menu
1:.'.1# Panel
550
PrimeFaces Users Guide
1:.'.1' Panel)rid
1:.'.13 Select.oolean$hec+bo-
1:.'.15 Select$hec+bo-Menu
1:.'.16 SelectMany.utton
1:.'.17 SelectMany$hec+bo-
1:.'.18 Select;ne.utton
1:.'.2: Select;neMenu
1:.'.21 Select;ne"adio
1:.'.22 1abMenu
551
PrimeFaces Users Guide
1:.'.2' 1ab<iew
1:.'.23 1oolbar
552
PrimeFaces Users Guide
1*.5 2he'e)
8obi(e the"in, i i"i(ar to the core the"in, docu"ented at cha&ter 2. 8ain di++erence i the
'atch conce&t o+ "obi(e the"e 'here one the"e can contain "u(ti&(e 'atche. De+au(t the"e
ha t'o 'atche a and &. A 'atch can be a&&(ied uin, 'atch attribute 'hen avai(ab(e.
<pm:header title'(4eader( swatch'(-(></pm:header>
$ustom 1heme
9here i a "obi(e the"ero((er a&&(ication to create a cuto" the"e.
http://themeroller.,Buerymo-ile.com
A+ter creatin, the the"e and do'n(oadin, it a a =i& +i(eE a /ar +i(e ha to be created to inta(( the
the"e 'ith the a"e +o(der tructure a a de3to& the"e.
- jar
- META-INF
- resources
- primefaces-mytheme
B theme.css
B images
1@ 9he the"e &ac3a,e do'n(oaded +ro" 9he"eRo((er 'i(( have a the"ena"e.c +i(e and i"a,e
+o(der. E0tract the content o+ the &ac3a,e and rena"e themename.css to theme.css.
%@ I"a,e re+erence in your the"e.c "ut a(o be converted to an e0&reion that AS# reource
(oadin, can undertandE e0a"&(e 'ou(d beK
ur(?Ii"a,eQuiBb,Lhi,h(i,htBhardL100L+9+9+9L10100.&n,I@
hou(d beK
ur(?IXVreource`O&ri"e+aceB"ythe"eNi"a,eQuiBb,Lhi,h(i,htBhardL100L+9+9+9L10100.&n,OaWI@
7nce the /ar o+ your the"e i in c(a&athE you can enab(e the the"e by the +o((o'in, con+i,uration.
<conte&t3param>
<param3name>primefaces.mo-ile.!4$5$</param3name>
<param3value>mytheme</param3value>
</conte&t3param>
&ara"Bva(ue can be an E6 e0&reion a 'e(( to i"&(e"ent dyna"ic the"in,.
553
PrimeFaces Users Guide
1*. 3ra'e4or.
In addition to the UI co"&onentE !#8 &rovide ea"(e inte,ration 'ith /Duery 8obi(e.
1*..1 Ajax 5pdate)
!(ain /Duery 8obi(e UI e(e"ent ue &ro,reive enhance"ent a&&roach that run once on &a,e
(oadE thi brea3 AS# a/a0 u&date ince the u&dated &art cannot be enhanced a,ain. !#8 ta3e care
o+ thi &rob(e" under the hood.
A an e0a"&(eE the &(ain /Cuery "obi(e data(it and in&utte0t 'i(( (oe a(( ty(in, and +unctiona(ity
'hen u&dated 'ith tandard a/a0 co""andbutton 'herea !#8 co""and1utton 'i(( &ro&er(y
u&date the data(it and in&utte0t.
<h:command=utton value'(8tandard(>
<f:a,a& render'(panel*( />
</h:command=utton>
<p:command=utton value'(#65( update'(panelA( icon'(ui3icon3refresh(/>
<h:panelIroup id'(panel*(>
<ul data3role'(listview( data3inset'(true(>
<li><a href'(.(>Item *</a></li>
<li><a href'(.(>Item A</a></li>
<li><a href'(.(>Item )</a></li>
</ul>
<h:input!e&t />
</h:panelIroup>
<p:output#anel id'(panelA(>
<p:menu stylelass'(ui3listview3inset ui3corner3all(>
<p:menuitem value'(Item*( url'(.( />
<p:menuitem value'(ItemA( url'(.( />
<p:menuitem value'(Item)( url'(.( />
</p:menu>
<p:input!e&t />
</p:output#anel>
1*..2 Pa)) 2hrou%h Ele'ent)
/D8 i data attribute drivenE than3 to AS# %.%O dyna"ic attribute u&&ortE !ri"e#ace
*o"&onent can have "obi(e &eci+ic o&tion eai(y. E0a"&(e be(o' add inet ettin, to a data(it.
<p:data7ist value'(./ring=ean.players0( var'(player( pt:data3inset'(true(>
//content
</p:data7ist>
<ote that &t i the tandard ta,(ibK $mlns7ptJ4http7AA$mlns.#cp.orgA#sfApassthrough4. #or the +u(( (it
o+ avai(ab(e data attributeE conu(t the /Duery 8obi(e docu"entation.
554
PrimeFaces Users Guide
1*..3 La67 Pa%e)
#or a "obi(e device 'ith band'ith concernE (oadin, a(( the &a,e in a"e 0ht"( at once in an
ea,er +ahion i not o&ti"a( and "i,ht caue &er+or"ance iue i+ the &a,e i=e i bi,. !#8
u&&ort (a=y (oadin, &a,e 'here a &a,e content i not rendered at +irt but (oaded 'ith a/a0 /ut
be+ore acceed +or the +irt ti"e. 6a=y (oadin, i diab(ed and activated by ettin, la/y o&tion on
&a,e co"&onent.
<!DO!"#$ html>
<html &mlns'(http://www.w).org/*+++/&html(
&mlns:h'(http://,ava.sun.com/,sf/html(
&mlns:f'(http://,ava.sun.com/,sf/core(
&mlns:p'(http://primefaces.org/ui(
&mlns:pm'(http://primefaces.org/mo-ile(>
<f:view renderTitId'(#CI5$6<$8L5O=I7$( />
<h:head></h:head>
<h:-ody>
<pm:page id'(main(>
<pm:header title'(5ain #age(></pm:header>
<pm:content>
<p:lin2 outcome'(pm:second( value'(Io( />
</pm:content>
</pm:page>
<pm:page id'(second( laOy'(true(>
<pm:header title'(8econd #age(></pm:header>
<pm:content>
//7aOy loaded content
</pm:content>
</pm:page>
</h:-ody>
</html>
At +irt &a,e (oadE econd &a,e content are not avai(ab(e on &a,eE c(ic3in, the (in3 +irt "a3e an
a/a0 reCuet to +etch the contentE create the UI and then +ina((y navi,ate to it.
1*..4 2ouch E,ent)
9ouch event (i3e 'i&e are enab(ed in o"e co"&onent. In +o((o'in,E ite" in the (it can be
re"oved by swipeleft or swiperight and detai( i di&(ayed 'ith taphold.
<h:form id'(form(>
<p:growl id'(msgs( showDetail'(true( />
<p:data7ist value'(./ta-le=ean.cars8mall0( var'(car( pt:data3inset'(true(>
<p:a,a& event'(swipeleft( listener'(./ta-le=ean.swipear0(
update'(:form:msgs Zthis(/>
<p:a,a& event'(swiperight( listener'(./ta-le=ean.swipear0(
update'(:form:msgs Zthis(/>
<p:a,a& event'(taphold( listener'(./ta-le=ean.onCow8elect0(
update'(:form:msgs(/>
<h:output!e&t value'(./car.manufacturer0 3 ./car.color0( />
</p:data7ist>
</h:form>
555
PrimeFaces Users Guide
pu-lic void onCow8elect98elect$vent event: /
6aces5essage msg ' new 6aces5essage9(ar 8elected(H
99ar: event.getO-,ect9::.get5odel9::;
6acesonte&t.geturrentInstance9:.add5essage9nullH msg:;
0
pu-lic void swipear98wipe$vent event: /
ar car ' 9ar: event.getData9:;
cars8mall.remove9car:;
6acesonte&t.geturrentInstance9:.add5essage9nullH
new 6aces5essage96aces5essage.8$@$CI!"LIJ6OH
(ar 8wiped(H (Cemoved: ( > car.get5odel9:::;
0
Section 10.- and 10.5 contain u&&orted "obi(e event +or a co"&onent 'hen avai(ab(e.
556
PrimeFaces Users Guide
11. 4tilities
11.1 "eFuest$onte-t
ReCuet*onte0t i a i"&(e uti(ity that &rovide ue+u( ,oodie uch a addin, &ara"eter to a/a0
ca((bac3 +unction. ReCuet*onte0t i avai(ab(e in both a/a0 and nonBa/a0 reCuet.
ReCuet*onte0t can be obtained i"i(ar(y to the #ace*onte0t.
CeBuestonte&t reBuestonte&t ' CeBuestonte&t.geturrentInstance9:;
"eFuest$onte-t API
!et"od Description
iA/a0ReCuet?@ Return a boo(ean va(ue i+ current reCuet i a
!ri"e#ace a/a0 reCuet.
add*a((1ac3!ara"?Strin, na"eE 7b/ect va(ue@ Add &ara"eter to a/a0 ca((bac3 (i3e onco"&(ete.
u&date?Strin, c(ientId@K S&eci+ie co"&onent?@ to u&date at runti"e.
e0ecute?Strin, cri&t@ E0ecute cri&t a+ter a/a0 reCuet co"&(ete or on &a,e
(oad.
cro((9o?Strin, c(ientId@ Scro(( to the co"&onent 'ith ,iven c(ientId a+ter a/a0
reCuet co"&(ete.
$allbac+ Parameters
9here "ay be cae 'here you need va(ue +ro" bac3in, bean in a/a0 ca((bac3. *a((bac3
&ara"eter are eria(i=ed to AS7< and &rovided a an ar,u"ent in a/a0 ca((bac3 +or thi.
<p:command=utton action7istener'(./-ean.validate0(
oncomplete'(handleomplete9&hrH statusH args:( />
pu-lic void validate9: /
//is@alid ' calculate is@alid
CeBuestonte&t reBuestonte&t ' CeBuestonte&t.geturrentInstance9:;
reBuestonte&t.addall-ac2#aram9(is@alid(H true or false:;
0
is2alid &ara"eter 'i(( be avai(ab(e in hand(e*o"&(ete ca((bac3 aK
<script type'(te&t/,avascript(>
function handleomplete9&hrH statusH args: /
var is@alid ' args.is@alid;
0
</script>
Mou can add a "any ca((bac3 &ara"eter a you 'ant 'ith add*a((bac3!ara" A!I. Each &ara"eter
i eria(i=ed a AS7< and acceib(e throu,h ar, &ara"eter o &o/o are a(o u&&orted /ut (i3e
557
PrimeFaces Users Guide
&ri"itive va(ue. #o((o'in, e0a"&(e end a &o/o ca((ed (ser that ha &ro&ertie (i3e +irtna"e and
(atna"e to the c(ient in addition to is2alid boo(ean va(ue.
pu-lic void validate9: /
//is@alid ' calculate is@alid
CeBuestonte&t reBuestonte&t ' CeBuestonte&t.geturrentInstance9:;
reBuestonte&t.addall-ac2#aram9(is@alid(H true or false:;
reBuestonte&t.addall-ac2#aram9(user(H user:;
0
<script type'(te&t/,avascript(>
function handleomplete9&hrH statusH args: /
var firstname ' args.user.firstname;
var lastname ' args.user.lastname;
0
</script>
1y de+au(t validationFailed ca((bac3 &ara"eter i added i"&(icit(y i+ va(idation +ai(.
"untime 4pdates
*onditiona( UI u&date i Cuite co""on 'here di++erent &art o+ the &a,e need to be u&dated baed
on a dyna"ic condition. In thi caeE it i not e++icient to ue dec(arative u&date and de+ined a((
u&date area ince thi 'i(( caue unnceary u&date.9here "ay be cae 'here you need to de+ine
'hich co"&onent?@ to u&date at runti"e rather than &eci+yin, it dec(arative(y. update "ethod i
added to hand(e thi cae. In e0a"&(e be(o'E button action6itener decide 'hich &art o+ the &a,e to
u&date onBtheB+(y.
<p:command=utton value'(8ave( action7istener'(./-ean.save0( />
<p:panel id'(panel(> ... </p:panel>
<p:data!a-le id'(ta-le(> ... </p:panel>
pu-lic void save9: /
//-oolean outcome ' ...
CeBuestonte&t reBuestonte&t ' CeBuestonte&t.geturrentInstance9:;
if9outcome:
reBuestonte&t.update9(panel(:;
else
reBuestonte&t.update9(ta-le(:;
0
When the ave button i c(ic3edE de&endin, on the outco"eE you can either con+i,ure the datatab(e
or the &ane( to be u&dated 'ith a/a0 re&one.
/-ecute !aascript
ReCuet*onte0t &rovide a 'ay to e0ecute /avacri&t 'hen the a/a0 reCuet co"&(eteE thi
a&&roach i eaier co"&ared to &ain, ca((bac3 &ara" and e0ecute conditiona( /avacri&t.
E0a"&(e be(o' hide the dia(o, 'hen a/a0 reCuet co"&(eteK
558
PrimeFaces Users Guide
pu-lic void save9: /
CeBuestonte&t reBuestonte&t ' CeBuestonte&t.geturrentInstance9:;
reBuestonte&t.e&ecute9dialog.hide9::;
0
559
PrimeFaces Users Guide
11.2 /* Functions
!ri"e#ace &rovide bui(tBin E6 e0tenion that are he(&er to co""on ue cae.
$ommon Functions
+unction Description
co"&onent?OidO@ Return c(ientId o+ the co"&onent 'ith &rovided erver id &ara"eter. 9hi +unction
i ue+u( i+ you need to 'or3 'ith /avacri&t.
'id,et>ar?OidO@ !rovide the 'id,et>ar o+ a co"&onent in !#?OO@ +or"at.
*o"&onent
<h:form id'(form*(>
<h:input!e&t id'(name( />
</h:form>
//./p:component9!name:0 returns !form*:name
Wid,et>ar
<p:dialog id'(dlg(>
//contents
</p:dialog>
<p:command=utton type'(-utton( value'(8how( onclic2'(./p:widget@ar9!dlg:0.show9:( />
Pa&e Authori9ation
Authori=ation +unction ue .tt&Serv(etReCuet A!I +or the bac3end in+or"ation.
+unction Description
i+Granted?Strin, ro(e@ Return true i+ uer ha the ,iven ro(eE e(e +a(e.
i+A((Granted?Strin, ro(e@ Return true i+ uer ha a(( o+ the ,iven ro(eE e(e +a(e.
i+AnyGranted?Strin, ro(e@ Return true i+ uer ha any o+ the ,iven ro(eE e(e +a(e.
i+<otGranted?Strin, ro(e@ Return true i+ uer ha none o+ the ,iven ro(eE e(e +a(e.
re"oteUer?@ Return the na"e o+ the (o,,ed in uer.
uer!rinci&a(?@ Return the &rinci&a( intance o+ the (o,,ed in uer.
<p:command=utton rendered'(./p:ifIranted9?CO7$L<D5IJ?:0( />
<h:input!e&t disa-led'(./p:ifIranted9?CO7$LIK$8!?:0( />
<p:input5as2 rendered'(./p:if<llIranted9?CO7$L$DI!OCH CO7$LC$<D$C?:0( />
560
PrimeFaces Users Guide
11.# /-ception (andler
!ri"e#ace &rovide a bui(tBin e0ce&tion hand(er to ta3e care o+ e0ce&tion in a/a0 and nonBa/a0
reCuet eai(y.
$on%i&uration
E0ce&tion.and(er and an E(Reo(ver con+i,ured i reCuired in +ace con+i,uration +i(e.
<application>
<el3resolver>
org.primefaces.application.e&ceptionhandler.#rime$&ception4andler$7Cesolver
</el3resolver>
</application>
<factory>
<e&ception3handler3factory>
org.primefaces.application.e&ceptionhandler.#rime$&ception4andler6actory
</e&ception3handler3factory>
</factory>
/rror Pa&es
E0ce&tion.and(er i inte,rated 'ith errorB&a,e "echani" o+ Serv(et A!I. At a&&(ication tartu&E
!ri"e#ace &are the error &a,e and ue thi in+or"ation to +ind the a&&ro&riate &a,e to redirect
to baed on the e0ce&tion ty&e. .ere i an e0a"&(e 'eb.0"( con+i,uration 'ith a ,eneric &a,e +or
e0ce&tion and a &ecia( &a,e +or >ie'E0&iredE0ce&tion ty&e.
<M&ml version'(*.0( encoding'(K!63G(M>
<we-3app version'(A.5(
&mlns'(http://,ava.sun.com/&ml/ns/,avaee(
&mlns:&si'(http://www.w).org/A00*/N578chema3instance(
&si:schema7ocation'(http://,ava.sun.com/&ml/ns/,avaee
http://,ava.sun.com/&ml/ns/,avaee/we-3appLAL5.&sd( >
<!33 Other application configuration 33>
<error3page>
<e&ception3type>,ava.lang.!hrowa-le</e&ception3type>
<location>/ui/error/error.,sf</location>
</error3page>
<error3page>
<e&ception3type>,ava&.faces.application.@iew$&pired$&ception</e&ception3type>
<location>/ui/error/view$&pired.,sf</location>
</error3page>
</we-3app>
561
PrimeFaces Users Guide
/-ception In%ormation
In the error &a,eE in+or"ation about the e0ce&tion i &rovided via the &+E0ce&tion.and(er E6
3ey'ord. .ere i the (it o+ e0&oed &ro&ertie.
B e0ce&tionN 9hro'ab(e intance.
B ty&eN 9y&e o+ the e0ce&tion.
B "ea,eN E0ce&tion "ea,eN
B tac39raceN An array o+ /ava.(an,.Stac39raceE(e"ent intance.
B +or"attedStac39raceN Stac3 trace a &reentab(e trin,.
B ti"eta"&N 9i"eta"& a date.
B +or"atted9i"eta"&N 9i"eta"& a &reentab(e trin,.
In error &a,eE e0ce&tion "etadata i acceed uin, E6K
<h:output!e&t value'(5essage:./pf$&ception4andler.message0( />
<h:output!e&t value'(./pf$&ception4andler.formatted8tac2!race0( escape'(false( />
A,a- /-ception (andler $omponent
A &ecia(i=ed e0ce&tion hand(er co"&onent &rovide a 'ay to e0ecute ca((bac3 on c(ient ideE
u&date other co"&onent on the a"e &a,e. 9hi i Cuite ue+u( in cae you donOt 'ant to create a
e&arate error &a,e. #o((o'in, e0a"&(e ho' the e0ce&tion in a dia(o, on the a"e &a,e.
<p:a,a&$&ception4andler type'(,ava&.faces.application.@iew$&pired$&ception(
update'(e&ceptionDialog( one&ception'(#69?e&ceptionDialog?:.show9:;( />
<p:dialog id'(e&ceptionDialog( header'($&ception: ./pf$&ception4andler.type0
occured!( widget@ar'(e&ceptionDialog( height'(500p&(>
5essage: ./pf$&ception4andler.message0 <-r/>
8tac2!race: <h:output!e&t value'(./pf$&ception4andler.formatted8tac2!race0(
escape'(false( />
<p:-utton onclic2'(document.location.href ' document.location.href;(
value'(Ceload!(/>
</p:dialog>
Idea( (ocation +or &Na/a0E0ce&tion.and(er co"&onent i the +ace(et te"&(ate o that it ,et
inc(uded in every &a,e. Re+er to co"&onent docu"entation o+ &Na/a0E0ce&tion.and(er +or the
avai(ab(e attribute.
"ender "esponse /-ceptions
9o u&&ort e0ce&tion hand(in, in the +E='E+>+ESP,=SE &haeE itO reCuired to et the
#ava$.faces.FACE&ETS>)(FFE+>S*KE &ara"eter. 7ther'ie you 'i(( &robab(y ee a
Serv(etE0ce&tion 'ith IRe&one a(ready co""ittedI "ea,e.
562
PrimeFaces Users Guide
11.' .ean<alidation 1rans%ormation
Since AavaEE 4E va(idation "etadata i a(ready avai(ab(e +or "any co"&onent via the va(ue
re+erence and 1ean>a(idation ?e.,. b<ot<u((E bSi=e@. 9he AS# I"&(e"entation ue thi
in+or"ation +or erver ide va(idation and !ri"e#ace enhance thi +eature 'ith c(ient ide
va(idation +ra"e'or3.
!ri"e#ace "a3e ue o+ thee "etadata by tran+or"in, the" to co"&onent and ht"( attribute.
#or e0a"&(e o"eti"e itZ reCuired to "anua((y "aintain the reCuired or "a0(en,th attribute +or
in&ut co"&onent. 9he reCuired attribute a(o contro( the behavior o+ &Nout&ut6abe( to ho' or
hide the reCuired indicator ?J@ 'herea the ma$length attribute i ued to (i"it the character on
in&ut +ie(d. 1ean>a(idation tran+or"ation +eature enab(e avoidin, "anua((y "aintainin, thee
attribute any"ore by i"&(ici(ity hand(in, the" behind the cene.
$on%i&uration
9o tart 'ithE tran+or"ation hou(d be enab(ed.
<conte&t3param>;
<param3name>primefaces.!C<J86OC5L5$!<D<!<</param3name>
<param3value>true</param3value>
</conte&t3param>
4sa&e
De+ine contraint at bean (eve(.
ZJotJull
Z5a&9)0:
private 8tring firstname;
*o"&onent at vie' doe not have any contraintK
<p:input!e&t value'(./-ean.firstname0( />
#ina( out&ut ha ht"( "a0(en,th attribute ,enerated +ro" the b8a0 annotationE a(o the co"&onent
intance ha reCuired enab(ed.
<input type'(te&t( ma&length'()0( a />
563
PrimeFaces Users Guide
11.3 PrimeFaces *ocales
*o"&onent "ay reCuire tran(ation and other ettin, baed on di++erent (oca(e. 9hi i hand(ed
'ith a c(ient ide a&i ca((ed !ri"e#ace 6oca(e. A c(ient ide (oca(e i baica((y a /avacri&t ob/ect
'ith variou ettin,E enLUS i the de+au(t (oca(e &rovided out o+ the bo0. In cae you need to
u&&ort another (oca(eE ettin, hou(d be e0tended 'ith the ne' in+or"ation.
A 'i3i &a,e i avai(ab(e +or uer contributed ettin,E the (it i co""unity driven and a ,ood
tartin, &oint a(thou,h it "i,ht be inco"&(ete.
https://code.google.com/p/primefaces/wi2i/#rime6aces7ocales
De%ault *ocale
.ere i the (it o+ a(( 3eyBva(ue &air +or enLUS (oca(e that i &rovided by !ri"e#ace. Date9i"e
re(ated &ro&ertie are uti(i=ed by co"&onent uch a ca(endar and chedu(e. I+ you are uin, *(ient
Side >a(idationE "ea,e &ro&erty i ued a the bund(e +or the (oca(e.
V
closeTe$tN O*(oeOE
prevTe$tN O!reviouOE
ne$tTe$tN O<e0tOE
mont"NamesN `OAanuaryOE O#ebruaryOE O8archOE OA&ri(OE O8ayOE OAuneOE OAu(yOE OAu,utOE OSe&te"berOE
O7ctoberOE O<ove"berOE ODece"berO aE
mont"Names)"ortN `OAanOE O#ebOE O8arOE OA&rOE O8ayOE OAunOE OAu(OE OAu,OE OSe&OE O7ctOE O<ovOE ODecO aE
dayNamesN `OSundayOE O8ondayOE O9uedayOE OWednedayOE O9hurdayOE O#ridayOE OSaturdayOaE
dayNames)"ortN `OSunOE O8onOE O9ueOE OWedOE O9ueOE O#riOE OSatOaE
dayNames!inN `OSOE O8OE O9OE OW OE O9OE O# OE OSOaE
0ee,(eaderN OWee3OE
firstDayN 0E
isT*N +a(eE
s"o0!ont"After:earN +a(eE
year)uffi$NOOE
time6nlyTitleN O7n(y 9i"eOE
timeTe$tN O9i"eOE
"ourTe$tN O9i"eOE
minuteTe$tN O8inuteOE
secondTe$tN OSecondOE
currentTe$tN O*urrent DateOE
ampmN +a(eE
mont"N O8onthOE
0ee,N O'ee3OE
dayN ODayOE
allDayTe$tN OA(( DayOE
messagesN V
;java$.faces.component.-..nput.'<-.'D;N OV0WN >a(idation ErrorN >a(ue i reCuired.OE
;java$.faces.converter..nteger#onverter..NT'/';N OV%WN ]OV0W]O "ut be a nu"ber
conitin, o+ one or "ore di,it.OE
;java$.faces.converter..nteger#onverter..NT'/'=detail;N OV%WN ]OV0W]O "ut be a nu"ber
bet'een B%1-5-2)4-2 and %1-5-2)4-5 E0a"&(eN V1WOE
564
PrimeFaces Users Guide
;java$.faces.converter.Dou&le#onverter.D6-%*';N OV%WN ]OV0W]O "ut be a nu"ber
conitin, o+ one or "ore di,it.OE
;java$.faces.converter.Dou&le#onverter.D6-%*'=detail;N OV%WN ]OV0W]O "ut be a nu"ber
bet'een -.9EB)%- and 1.59549)1)-24%)155E)02 E0a"&(eN V1WOE
;java$.faces.converter.%igDecimal#onverter.D'#.!A*;N OV%WN ]OV0W]O "ut be a i,ned
deci"a( nu"ber.OE
;java$.faces.converter.%igDecimal#onverter.D'#.!A*=detail;N OV%WN ]OV0W]O "ut be a
i,ned deci"a( nu"ber conitin, o+ =ero or "ore di,itE that "ay be +o((o'ed by a deci"a( &oint
and +raction. E0a"&(eN V1WOE
;java$.faces.converter.%ig.nteger#onverter.%./.NT'/';N OV%WN ]OV0W]O "ut be a nu"ber
conitin, o+ one or "ore di,it.OE
;java$.faces.converter.%ig.nteger#onverter.%./.NT'/'=detail;N OV%WN ]OV0W]O "ut be a
nu"ber conitin, o+ one or "ore di,it. E0a"&(eN V1WOE
;java$.faces.converter.%yte#onverter.%:T';N OV%WN ]OV0W]O "ut be a nu"ber bet'een 0 and
%55.OE
;java$.faces.converter.%yte#onverter.%:T'=detail;N OV%WN ]OV0W]O "ut be a nu"ber bet'een
0 and %55. E0a"&(eN V1WOE
;java$.faces.converter.#"aracter#onverter.#(AA#T';N OV1WN ]OV0W]O "ut be a va(id
character.OE
;java$.faces.converter.#"aracter#onverter.#(AA#T'=detail;N OV1WN ]OV0W]O "ut be a
va(id AS*II character.OE
;java$.faces.converter.)"ort#onverter.)(6T;N OV%WN ]OV0W]O "ut be a nu"ber conitin, o+
one or "ore di,it.OE
;java$.faces.converter.)"ort#onverter.)(6T=detail;N OV%WN ]OV0W]O "ut be a nu"ber
bet'een B)%542 and )%545 E0a"&(eN V1WOE
;java$.faces.converter.%oolean#onverter.%66*'AN;N OV1WN ]OV0W]O "ut be ]Otrue]O
or ]O+a(e]OOE
;java$.faces.converter.%oolean#onverter.%66*'AN=detail;N OV1WN ]OV0W]O "ut be ]Otrue]O or
]O+a(e]O. Any va(ue other than ]Otrue]O 'i(( eva(uate to ]O+a(e]O.OE
;java$.faces.validator.*ongangeValidator.!A>.!-!;N OV1WN >a(idation ErrorN >a(ue i
,reater than a((o'ab(e "a0i"u" o+ ]OV0W]OOE
;java$.faces.validator.*ongangeValidator.!.N.!-!;N OV1WN >a(idation ErrorN >a(ue i
(e than a((o'ab(e "ini"u" o+ ]OV0W]OOE
;java$.faces.validator.*ongangeValidator.N6T=.N=AN/';N OV%WN >a(idation ErrorN
S&eci+ied attribute i not bet'een the e0&ected va(ue o+ V0W and V1W.OE
O/ava0.+ace.va(idator.6on,Ran,e>a(idator.9M!EPV0WON O>a(idation ErrorN >a(ue i not o+ the
correct ty&e.OE
;java$.faces.validator.Dou&leangeValidator.!A>.!-!;N OV1WN >a(idation ErrorN >a(ue i
,reater than a((o'ab(e "a0i"u" o+ ]OV0W]OOE
;java$.faces.validator.Dou&leangeValidator.!.N.!-!;N OV1WN >a(idation ErrorN >a(ue i
(e than a((o'ab(e "ini"u" o+ ]OV0W]OOE
;java$.faces.validator.Dou&leangeValidator.N6T=.N=AN/';N OV%WN >a(idation ErrorN
S&eci+ied attribute i not bet'een the e0&ected va(ue o+ V0W and V1WOE
;java$.faces.validator.Dou&leangeValidator.T:P'?{@};N O>a(idation ErrorN >a(ue i not o+
the correct ty&eOE
;java$.faces.converter.+loat#onverter.+*6AT;N OV%WN ]OV0W]O "ut be a nu"ber conitin, o+
one or "ore di,it.OE
;java$.faces.converter.+loat#onverter.+*6AT=detail;N OV%WN ]OV0W]O "ut be a nu"ber
bet'een 1.-EB-5 and ).-0%2%)5E)2 E0a"&(eN V1WOE
;java$.faces.converter.DateTime#onverter.DAT';N OV%WN ]OV0W]O cou(d not be undertood a a
date.OE
565
PrimeFaces Users Guide
;java$.faces.converter.DateTime#onverter.DAT'=detail;N OV%WN ]OV0W]O cou(d not be
undertood a a date. E0a"&(eN V1WOE
;java$.faces.converter.DateTime#onverter.T.!';N OV%WN ]OV0W]O cou(d not be undertood a a
ti"e.OE
;java$.faces.converter.DateTime#onverter.T.!'=detail;N OV%WN ]OV0W]O cou(d not be
undertood a a ti"e. E0a"&(eN V1WOE
;java$.faces.converter.DateTime#onverter.DAT'T.!';N OV%WN ]OV0W]O cou(d not be
undertood a a date and ti"e.OE
;java$.faces.converter.DateTime#onverter.DAT'T.!'=detail;N OV%WN ]OV0W]O cou(d not be
undertood a a date and ti"e. E0a"&(eN V1WOE
;java$.faces.converter.DateTime#onverter.PATT'N=T:P';N OV1WN A ]O&attern]O or ]Oty&e]O
attribute "ut be &eci+ied to convert the va(ue ]OV0W]OOE
;java$.faces.converter.Num&er#onverter.#-'N#:;N OV%WN ]OV0W]O cou(d not be
undertood a a currency va(ue.OE
;java$.faces.converter.Num&er#onverter.#-'N#:=detail;N OV%WN ]OV0W]O cou(d not be
undertood a a currency va(ue. E0a"&(eN V1WOE
;java$.faces.converter.Num&er#onverter.P'#'NT;N OV%WN ]OV0W]O cou(d not be undertood
a a &ercenta,e.OE
;java$.faces.converter.Num&er#onverter.P'#'NT=detail;N OV%WN ]OV0W]O cou(d not be
undertood a a &ercenta,e. E0a"&(eN V1WOE
;java$.faces.converter.Num&er#onverter.N-!%';N OV%WN ]OV0W]O cou(d not be undertood
a a date.OE
;java$.faces.converter.Num&er#onverter.N-!%'=detail;N OV%WN ]OV0W]O i not a nu"ber.
E0a"&(eN V1WOE
;java$.faces.converter.Num&er#onverter.PATT'N;N OV%WN ]OV0W]O i not a nu"ber &attern.OE
;java$.faces.converter.Num&er#onverter.PATT'N=detail;N OV%WN ]OV0W]O i not a nu"ber
&attern. E0a"&(eN V1WOE
;java$.faces.validator.*engt"Validator.!.N.!-!;N OV1WN >a(idation ErrorN 6en,th i (e
than a((o'ab(e "ini"u" o+ ]OV0W]OOE
;java$.faces.validator.*engt"Validator.!A>.!-!;N OV1WN >a(idation ErrorN 6en,th i
,reater than a((o'ab(e "a0i"u" o+ ]OV0W]OOE
;java$.faces.validator.ege$Validator.PATT'N=N6T=)'T;N ORe,e0 &attern "ut be et.OE
;java$.faces.validator.ege$Validator.PATT'N=N6T=)'T=detail;N ORe,e0 &attern "ut
be et to nonBe"&ty va(ue.OE
;java$.faces.validator.ege$Validator.N6T=!AT#('D;N ORe,e0 !attern not "atchedOE
;java$.faces.validator.ege$Validator.N6T=!AT#('D=detail;N ORe,e0 &attern o+ ]OV0W]O
not "atchedOE
;java$.faces.validator.ege$Validator.!AT#(='>#'PT.6N;N OError in re,u(ar
e0&reion.OE
;java$.faces.validator.ege$Validator.!AT#(='>#'PT.6N=detail;N OError in re,u(ar
e0&reionE ]OV0W]OO
W
W
4sa&e
9o add another (oca(e to the A!IE +irt create the (oca(e ob/ect +irt 'ith ettin, and ai,n it a a
&ro&erty o+ !ri"e#ace.(oca(e /avacri&t ob/ect uch aK
PrimeFaces.localesC?de?E J FAAsettingsG
It i u,,eted to &ut thi code in a /avacri&t +i(e and inc(ude the +i(e into your &a,e.
566
PrimeFaces Users Guide
12. Portlets
!ri"e#ace u&&ort &ort(et environ"ent baed on AS# % and !ort(et % A!I. A &ort(et brid,e i
neceary to run a AS# a&&(ication a a &ort(et and 'e u,,et 6i+eray#ace brid,e a the
i"&(e"entation. 1oth tea" 'or3 to,ether ti"e to ti"e to "a3e ure !ri"e#ace run 'e(( on
(i+eray. A 3ic3tart e0a"&(e 'ith neceary con+i,uration i avai(ab(e at 6i+eray#ace De"oK
http://www.liferay.com/community/liferay3pro,ects/liferay3faces/demos
De"o contain a in,(e IAob A&&(icationI &ort(et 'ithin the WAR that de"ontrate evera( o+ the
3ey +eature o+ AS# % and !ri"e#aceK
B Ue the !ri"e#ace S&Nca(endarQT ta, +or a &o&u& date e(ector
B Ue the AS# % S+Na/a0 QT ta, on the &ota( ?=i&@ code +ie(d in order to &rovide the abi(ity to autoB
+i(( +ie(d via A/a0
B Ue the AS# % S+Na/a0 QT ta, on the ho'Qhide co""ent (in3 in order to ho'Qhide the
co""ent +ie(d via A/a0
B 8ode( "ana,edBbean i "ar3ed 'ith the AS# % b>ie'Sco&ed annotation in order to u&&ort a
rich UI 'ith the S+Na/a0 QT ta,
B Ue the AS# % S+Na/a0 QT ta, to ho' navi,ationBru(e e0ecutin, 'ithout +u(( &a,e re+rehe
B #i(e u&(oad ca&abi(itie via ShN+or" encty&ePI"u(ti&artQ+or"BdataIT
B 8ana,edBbean de+ined by "ar3in, !7A7 'ith the AS# % b8ana,ed1ean annotation
B De&endency in/ection o+ "ana,edBbean done via the AS# % b8ana,ed!ro&erty annotation
B Ue the !ri"e#ace &N+i(eU&(oad ta, +or "u(tiB+i(e A/a0Bbaed +i(e u&(oad
B Ue the !ri"e#ace &Ndata9ab(e ta, to (it the u&(oaded +i(e
B Ue the !ri"e#ace &Ncon+ir"Dia(o, ta, to &o&u& a yeQno dia(o, to veri+y +i(e de(etion
567
PrimeFaces Users Guide
1#. "i&ht>1o>*e%t
Ri,htB9oB6e+t (an,ua,e u&&ort in hort R96 i &rovided out o+ the bo0 by a ubet o+ !ri"e#ace
co"&onent. Any co"&onent eCui&&ed 'ith dir attribute ha the o++icia( u&&ort and there i a(o a
,(oba( ettin, to 'itch to R96 "ode ,(oba((y.
.ere i an e0a"&(e o+ an R96 Accordion!ane( enab(ed via dir ettin,.
<p:accordion#anel dir'(rtl(>
//ta-s
</p:accordion#anel>
)lobal $on%i&uration
Uin, primefaces.'*+ ,(oba( ettin, to rt( intruct !ri"e#ace R96 a'are co"&onent uch a
datatab(eE accordionE tabvie'E dia(o,E tree to render in R96 "ode.
<conte&t3param>
<param3name>primefaces.DIC</param3name>
<param3value>rtl</param3value>
</conte&t3param>
!ara"eter va(ue can a(o be an E6 e0&reion +or dyna"ic va(ue.
In u&co"in, !ri"e#ace re(eaeE "ore co"&onent 'i(( receive bui(tBin R96 u&&ort. Unti( then i+
the co"&onent you ue doent &rovide itE overridin, c and /avacri&t in your a&&(ication 'ou(d
be the o(ution.
568
PrimeFaces Users Guide
1'. ID/ Support
1'.1 0et.eans
<et1ean 5.0H bund(e !ri"e#aceE 'hen creatin, a ne' &ro/ect you can e(ect !ri"e#ace +ro"
co"&onent tabK
*ode co"&(etion i u&&orted by <et1ean 4.9H K
569
PrimeFaces Users Guide
!ri"e#ace and <et1ean tea" are in co""unication to dicu the ne0t te& o+ !ri"e#ace
inte,ration in <et1ean at the ti"e o+ 'ritin,.
PrimeFaces $"4D Plu&in
Startin, 'ith <et1ean 2E the IDE &rovide a bui(tBin *RUD &(u,in +or !ri"e#ace out o+ the bo0.
'''.youtube.co"Q'atch$vP5a9#i<0=F#-
9here i a(o another )
rd
&arty &(u,in +or <et1ean ca((ed !ri"e#ace *RUD Generator.
http7AAsourceforge.netApro#ectsAnbpfcrudgenA
1'.2 /clipse
*ode co"&(etion 'or3 out o+ the bo0 +or Ec(i&e 'hen AS# +acet i enab(ed.
570
PrimeFaces Users Guide
13. Pro,ect "esources
Documentation
9hi ,uide i the "ain reource +or docu"entationE +or additiona( docu"entation (i3e a&idocE ta,(ib
docE 'i3i and "ore &(eae viitK
http://www.primefaces.org/documentation.html
Support Forum
!ri"e#ace dicuion ta3e &(ace at the u&&ort +oru". #oru" i &ub(ic to everyone and
re,itration i reCuired to do a &ot.
http://forum.primefaces.org
Source $ode
!ri"e#ace ource i at ,oo,(e code ubverion re&oitory.
http://code.google.com/p/primefaces/source/
Issue 1rac+er
!ri"e#ace iue trac3er ue ,oo,(e code iue "ana,e"ent yte". !(eae ue the +oru"
be+orecreatin, an iue intead.
http://code.google.com/p/primefaces/issues/list
WI@I
!ri"e#ace Wi3i i a co""unity driven additiona( docu"entation reource.
http://wi2i.primefaces.org
Showcase
Sho'cae i a ,reat reource a a (ive docu"entation.
http://www.primefaces.org/showcase
Social 0etwor+s
Mou can +o((o' !ri"e#ace on t'itter uin, b&ri"e+ace and /oin the #aceboo3 ,rou& +or ne'
and "ore.
571
PrimeFaces Users Guide
15. FA2
A. 1"o develops Prime+acesB
!ri"e#ace i deve(o&ed and "aintained by !ri"e9e3E a o+t'are deve(o&"ent co"&any
&ecia(i=ed in UI o(ution +or AavaEE.
C. (o0 can . get supportB
Su&&ort +oru" i the "ain area to a3 +or he(&E it &ub(ic(y avai(ab(e and +ree re,itration i
reCuired be+ore &otin,. !(eae do not e"ai( the deve(o&er o+ !ri"e#ace direct(y and ue u&&ort
+oru" intead.
D. .s enterprise support availa&leB
MeE enter&rie u&&ort i a(o avai(ab(e. !(eae viit u&&ort &a,e on !ri"e#ace 'ebite +or "ore
in+or"ation.
htt&NQQ'''.&ri"e+ace.or,Qu&&ort
E. 1"ere is t"e source for t"e e$ample demo applicationsB
Source code o+ de"o a&&(ication are in the vn re&oitory o+ !ri"e#ace at Qe0a"&(eQtrun3 +o(der.
Sna&hot bui(d o+ a"&(e are de&(oyed at !ri"e#ace Re&oitory ti"e to ti"e.
F. )ome components li,e c"arts do not 0or, in )afari or #"rome &ut t"ere8s no pro&lem 0it"
+irefo$.
9he co""on reaon i the re&one "i"e9y&e 'hen uin, 'ith !ri"e#ace. Mou need to "a3e
ure re&one9y&e i Ite0tQht"(I. Mou can ue the S+Nvie' content9y&ePIte0tQht"(IT to en+orce thi.
G. 1"at is t"e license of Prime+acesB
!ri"e#ace i +ree to ue and (icened under A&ache 6icene >%E E(ite verion are (icened under
E(ite 6icene.
H. #an . use Prime+aces in a commercial soft0areB
MeE A&ache >% 6icene i a co""ercia( +riend(y (ibrary. !ri"e#ace doe not bund(e any third
&arty o+t'are that con+(ict 'ith A&ache. Sa"e ,oe +or E(ite Re(eae +or E6I9E and !R7 uer.
I. 1"ic" &ro0sers are supported &y Prime+acesB
IE 2B9B10B11E Sa+ariE #ire+o0E *hro"e and 7&era.
572
PrimeFaces Users Guide
9.E E<D
573