RichFaces Developer Guide SEO
RichFaces Developer Guide SEO
RichFaces framework
with a huge library of
rich components and
skinnability support
1. Introduction ................................................................................................................. 1
2. Technical Requirements .............................................................................................. 3
2.1. Supported Java Versions .................................................................................... 3
2.2. Supported JavaServer Faces Implementations and Frameworks ............................ 3
2.3. Supported Servers .............................................................................................. 3
2.4. Supported Browsers ............................................................................................ 4
3. Getting Started with RichFaces ................................................................................... 5
3.1. Downloading RichFaces 3.2.1 ............................................................................. 5
3.2. Installation .......................................................................................................... 5
3.3. Simple Ajax Echo Project ................................................................................... 6
3.3.1. JSP Page ................................................................................................ 6
3.3.2. Data Bean ............................................................................................... 7
3.3.3. faces-config.xml ....................................................................................... 7
3.3.4. Web.xml .................................................................................................. 8
3.3.5. Deployment ............................................................................................. 9
4. Settings for different environments ........................................................................... 11
4.1. Web Application Descriptor Parameters .............................................................. 11
4.2. Sun JSF RI ...................................................................................................... 14
4.3. Apache MyFaces .............................................................................................. 15
4.4. Facelets Support ............................................................................................... 15
4.5. JBoss Seam Support ........................................................................................ 16
4.6. Portlet Support .................................................................................................. 19
4.7. Sybase EAServer .............................................................................................. 19
4.8. Oracle AS/OC4J ............................................................................................... 20
5. Basic concepts of the RichFaces Framework ............................................................ 21
5.1. Introduction ....................................................................................................... 21
5.2. RichFaces Architecture Overview ....................................................................... 22
5.3. Limitations and Rules ........................................................................................ 25
5.4. Ajax Request Optimization ................................................................................ 26
5.4.1. Re-Rendering ......................................................................................... 26
5.4.2. Queue and Traffic Flood Protection ......................................................... 28
5.4.3. Data Processing Options ........................................................................ 29
5.4.4. Action and Navigation ............................................................................ 30
5.4.5. JavaScript Interactions ............................................................................ 31
5.4.6. Iteration components Ajax attributes ........................................................ 32
5.4.7. Other useful attributes ............................................................................ 33
5.5. How To... ......................................................................................................... 34
5.5.1. Send an Ajax request ............................................................................. 34
5.5.2. Decide What to Send ............................................................................. 34
5.5.3. Decide What to Change ......................................................................... 34
5.5.4. Decide what to process .......................................................................... 35
5.6. Filter Configuration ............................................................................................ 36
5.7. Scripts and Styles Load Strategy ....................................................................... 38
5.8. Request Errors and Session Expiration Handling ................................................ 39
iii
RichFaces Developer Guide
iv
6.6. < a4j:form > .................................................................................................... 89
6.6.1. Description ............................................................................................. 89
6.6.2. Creating on a page ................................................................................ 92
6.6.3. Creating the Component Dynamically Using Java ..................................... 92
6.6.4. Key attributes and ways of usage ........................................................... 92
6.6.5. Relevant resources links ......................................................................... 93
6.7. < a4j:htmlCommandLink > ................................................................................ 93
6.7.1. Description ............................................................................................. 93
6.7.2. Creating the Component with a Page Tag ............................................... 97
6.7.3. Creating the Component Dynamically Using Java ..................................... 97
6.7.4. Key attributes and ways of usage ........................................................... 97
6.7.5. Relevant resources links ......................................................................... 98
6.8. < a4j:jsFunction > ............................................................................................ 98
6.8.1. Description ............................................................................................. 98
6.8.2. Creating on a page .............................................................................. 100
6.8.3. Creating the Component Dynamically Using Java ................................... 101
6.8.4. Key attributes and ways of usage .......................................................... 101
6.8.5. Relevant resources links ....................................................................... 102
6.9. < a4j:include > ............................................................................................... 102
6.9.1. Description ........................................................................................... 102
6.9.2. Creating on a page .............................................................................. 103
6.9.3. Creating the Component Dynamically Using Java ................................... 104
6.9.4. Relevant resources links ....................................................................... 105
6.10. < a4j:loadBundle > ....................................................................................... 105
6.10.1. Description ......................................................................................... 105
6.10.2. Creating on a page ............................................................................. 105
6.10.3. Creating the Component Dynamically Using Java ................................. 106
6.10.4. Key attributes and ways of usage ........................................................ 106
6.10.5. Relevant resources links ..................................................................... 106
6.11. < a4j:loadScript > ......................................................................................... 106
6.11.1. Description ......................................................................................... 106
6.11.2. Creating on a page ............................................................................. 107
6.11.3. Creating the Component Dynamically Using Java ................................. 107
6.11.4. Key attributes and ways of usage ........................................................ 107
6.11.5. Relevant resources links ..................................................................... 108
6.12. < a4j:loadStyle > .......................................................................................... 108
6.12.1. Description ......................................................................................... 108
6.12.2. Creating on a page ............................................................................. 108
6.12.3. Creating the Component Dynamically Using Java ................................. 109
6.12.4. Key attributes and ways of usage ........................................................ 109
6.12.5. Relevant resources links ..................................................................... 109
6.13. < a4j:log > ................................................................................................... 109
6.13.1. Description ......................................................................................... 109
6.13.2. Creating the Component with a Page Tag ............................................ 111
v
RichFaces Developer Guide
vi
6.20.5. Relevant resources links ..................................................................... 141
6.21. < a4j:repeat > .............................................................................................. 141
6.21.1. Description ......................................................................................... 141
6.21.2. Creating on a page ............................................................................. 142
6.21.3. Creating the Component Dynamically Using Java ................................. 142
6.21.4. Key attributes and ways of usage ........................................................ 142
6.21.5. Relevant resources links ..................................................................... 143
6.22. < a4j:status > .............................................................................................. 144
6.22.1. Description ......................................................................................... 144
6.22.2. Creating on a page ............................................................................. 145
6.22.3. Creating the Component Dynamically Using Java ................................. 146
6.22.4. Key attributes and ways of usage ........................................................ 146
6.22.5. Relevant resources links ..................................................................... 147
6.23. < a4j:support > ............................................................................................ 148
6.23.1. Description ......................................................................................... 148
6.23.2. Creating on a page ............................................................................. 150
6.23.3. Creating the Component Dynamically Using Java ................................. 150
6.23.4. Key attributes and ways of usage ........................................................ 151
6.23.5. Relevant resources links ..................................................................... 154
6.24. < rich:ajaxValidator > ................................................................................... 154
6.24.1. Description ......................................................................................... 154
6.24.2. Key Features ...................................................................................... 154
6.24.3. Creating the Component with a Page Tag ............................................ 156
6.24.4. Creating the Component Dynamically Using Java ................................. 156
6.24.5. Details of Usage ................................................................................. 157
6.24.6. Relevant Resources Links ................................................................... 159
6.25. < rich:graphValidator > ................................................................................. 159
6.25.1. Description ......................................................................................... 159
6.25.2. Key Features ...................................................................................... 159
6.25.3. Creating the Component with a Page Tag ............................................ 160
6.25.4. Creating the Component Dynamically Using Java ................................. 160
6.25.5. Relevant Resources Links ................................................................... 162
6.26. < rich:beanValidator > .................................................................................. 162
6.26.1. Description ......................................................................................... 162
6.26.2. Key Features ...................................................................................... 163
6.26.3. Creating the Component with a Page Tag ............................................ 163
6.26.4. Creating the Component Dynamically Using Java ................................. 163
6.26.5. Details of Usage ................................................................................. 164
6.26.6. Relevant Resources Links ................................................................... 166
6.27. < rich:calendar > .......................................................................................... 166
6.27.1. Description ......................................................................................... 166
6.27.2. Key Features ...................................................................................... 166
6.27.3. Creating the Component with a Page Tag ............................................ 173
6.27.4. Creating the Component Dynamically Using Java ................................. 173
vii
RichFaces Developer Guide
viii
6.32. < rich:datascroller > ..................................................................................... 231
6.32.1. Description ......................................................................................... 231
6.32.2. Key Features ...................................................................................... 231
6.32.3. Creating the Component with a Page Tag ............................................ 236
6.32.4. Creating the Component Dynamically Using Java ................................. 236
6.32.5. Details of Usage ................................................................................. 236
6.32.6. Look-and-Feel Customization .............................................................. 240
6.32.7. Skin Parameters Redefinition .............................................................. 241
6.32.8. Definition of Custom Style Classes ...................................................... 241
6.32.9. Relevant Resources Links ................................................................... 243
6.33. < rich:columns > .......................................................................................... 244
6.33.1. Description ......................................................................................... 244
6.33.2. Key Features ...................................................................................... 244
6.33.3. Creating the Component with a Page Tag ............................................ 246
6.33.4. Creating the Component Dynamically Using Java ................................. 247
6.33.5. Details of Usage ................................................................................. 247
6.33.6. Look-and-Feel Customization .............................................................. 251
6.33.7. Skin Parameters Redefinition .............................................................. 251
6.33.8. Definition of Custom Style Classes ...................................................... 251
6.33.9. Relevant Resources Links ................................................................... 253
6.34. < rich:columnGroup > ................................................................................... 253
6.34.1. Description ......................................................................................... 253
6.34.2. Key Features ...................................................................................... 254
6.34.3. Creating the Component with a Page Tag ............................................ 255
6.34.4. Creating the Component Dynamically Using Java ................................. 256
6.34.5. Details of Usage ................................................................................. 256
6.34.6. Look-and-Feel Customization .............................................................. 259
6.34.7. Skin Parameters Redefinition .............................................................. 259
6.34.8. Definition of Custom Style Classes ...................................................... 259
6.34.9. Relevant Resources Links ................................................................... 261
6.35. < rich:column > ............................................................................................ 261
6.35.1. Description ......................................................................................... 261
6.35.2. Key Features ...................................................................................... 262
6.35.3. Creating the Component with a Page Tag ............................................ 264
6.35.4. Creating the Component Dynamically Using Java ................................. 264
6.35.5. Details of Usage ................................................................................. 265
6.35.6. Sorting and Filtering ........................................................................... 268
6.35.7. Look-and-Feel Customization .............................................................. 274
6.35.8. Skin Parameters Redefinition .............................................................. 274
6.35.9. Definition of Custom Style Classes ...................................................... 275
6.35.10. Relevant Resources Links ................................................................. 276
6.36. < rich:dataGrid > .......................................................................................... 276
6.36.1. Description ......................................................................................... 276
6.36.2. Key Features ...................................................................................... 277
ix
RichFaces Developer Guide
x
6.41. < rich:subTable > ......................................................................................... 320
6.41.1. Description ......................................................................................... 320
6.41.2. Key Features ...................................................................................... 320
6.41.3. Creating the Component with a Page Tag ............................................ 324
6.41.4. Creating the Component Dynamically Using Java ................................. 324
6.41.5. Details of Usage ................................................................................. 324
6.41.6. Look-and-Feel Customization .............................................................. 325
6.41.7. Skin Parameters Redefinition .............................................................. 325
6.41.8. Definition of Custom Style Classes ...................................................... 325
6.42. < rich:dndParam > ....................................................................................... 329
6.42.1. Description ......................................................................................... 329
6.42.2. Creating the Component with a Page Tag ............................................ 330
6.42.3. Creating the Component Dynamically Using Java ................................. 330
6.42.4. Details of Usage ................................................................................. 330
6.42.5. Look-and-Feel Customization .............................................................. 332
6.42.6. Relevan Resources Links .................................................................... 332
6.43. < rich:dragIndicator > ................................................................................... 332
6.43.1. Description ......................................................................................... 332
6.43.2. Key Features ...................................................................................... 332
6.43.3. Creating the Component with a Page Tag ............................................ 333
6.43.4. Creating the Component Dynamically Using Java ................................. 333
6.43.5. Details of Usage ................................................................................. 334
6.43.6. Look-and-Feel Customization .............................................................. 336
6.43.7. Relevant Resources Links ................................................................... 336
6.44. < rich:dragSupport > .................................................................................... 336
6.44.1. Description ......................................................................................... 336
6.44.2. Key Features ...................................................................................... 337
6.44.3. Creating the Component with a Page Tag ............................................ 340
6.44.4. Creating the Component Dynamically Using Java ................................. 340
6.44.5. Details of Usage ................................................................................. 341
6.44.6. Look-and-Feel Customization .............................................................. 343
6.44.7. Relevant Resources Links ................................................................... 343
6.45. < rich:dropSupport > .................................................................................... 343
6.45.1. Description ......................................................................................... 343
6.45.2. Key Features ...................................................................................... 343
6.45.3. Creating the Component with a Page Tag ............................................ 347
6.45.4. Creating the Component Dynamically Using Java ................................. 347
6.45.5. Details of Usage ................................................................................. 347
6.45.6. Look-and-Feel Customization .............................................................. 350
6.45.7. Relevant Resources Links ................................................................... 350
6.46. < rich:dragListener > .................................................................................... 350
6.46.1. Description ......................................................................................... 350
6.46.2. Key Features ...................................................................................... 350
6.46.3. Creating the Component with a Page Tag ............................................ 351
xi
RichFaces Developer Guide
xii
6.51.5. Details of Usage ................................................................................. 388
6.51.6. Look-and-Feel Customization .............................................................. 390
6.51.7. Skin Parameters Redefinition .............................................................. 390
6.51.8. Definition of Custom Style Classes ..................................................... 391
6.51.9. Relevant Resources Links ................................................................... 393
6.52. < rich:menuSeparator > ................................................................................ 393
6.52.1. Description ......................................................................................... 393
6.52.2. Creating the Component with a Page Tag ............................................ 394
6.52.3. Creating the Component Dynamically Using Java ................................. 394
6.52.4. Look-and-Feel Customization .............................................................. 394
6.52.5. Skin Parameters Redefinition .............................................................. 395
6.52.6. Definition of Custom Style Classes ...................................................... 395
6.52.7. Relevant Resources Links ................................................................... 396
6.53. < rich:effect > .............................................................................................. 396
6.53.1. Description ......................................................................................... 396
6.53.2. Key Features ...................................................................................... 396
6.53.3. Creating the Component with a Page Tag ............................................ 397
6.53.4. Creating the Component Dynamically Using Java ................................. 397
6.53.5. Details of Usage ................................................................................. 398
6.53.6. Look-and-Feel Customization .............................................................. 400
6.53.7. Relevant Resources Links ................................................................... 400
6.54. < rich:fileUpload > ........................................................................................ 400
6.54.1. Description ......................................................................................... 400
6.54.2. Key Features ...................................................................................... 400
6.54.3. Creating the Component with a Page Tag ............................................ 405
6.54.4. Creating the Component Dynamically Using Java ................................. 405
6.54.5. Details of Usage ................................................................................. 405
6.54.6. JavaScript API .................................................................................... 413
6.54.7. Look-and-Feel Customization .............................................................. 416
6.54.8. Skin Parameters Redefinition .............................................................. 416
6.54.9. Definition of Custom Style Classes ...................................................... 417
6.54.10. Relevant Resources Links ................................................................. 421
6.55. < rich:gmap > .............................................................................................. 421
6.55.1. Description ......................................................................................... 421
6.55.2. Key Features ...................................................................................... 421
6.55.3. Creating the Component with a Page Tag ............................................ 424
6.55.4. Creating the Component Dynamically Using Java ................................. 424
6.55.5. Details of Usage ................................................................................. 424
6.55.6. Look-and-Feel Customization .............................................................. 427
6.55.7. Definition of Custom Style Classes ...................................................... 427
6.55.8. Relevant Resources Links ................................................................... 429
6.56. < rich:virtualEarth > ...................................................................................... 430
6.56.1. Description ......................................................................................... 430
6.56.2. Key Features ...................................................................................... 430
xiii
RichFaces Developer Guide
xiv
6.60.7. Skin Parameters Redefinition .............................................................. 472
6.60.8. Definition of Custom Style Classes ...................................................... 472
6.60.9. Relevant Resources Links ................................................................... 474
6.61. < rich:inputNumberSpinner > ........................................................................ 474
6.61.1. Description ......................................................................................... 474
6.61.2. Key Features ...................................................................................... 475
6.61.3. Creating the Component with a Page Tag ............................................ 478
6.61.4. Creating the Component Dynamically Using Java ................................. 479
6.61.5. Details of Usage ................................................................................. 479
6.61.6. Look-and-Feel Customization .............................................................. 480
6.61.7. Skin Parameters Redefinition .............................................................. 480
6.61.8. Definition of Custom Style Classes ...................................................... 481
6.61.9. Relevant Resources Links ................................................................... 482
6.62. < rich:insert > .............................................................................................. 483
6.62.1. Description ......................................................................................... 483
6.62.2. Key Features ...................................................................................... 483
6.62.3. Creating the Component with a Page Tag ............................................ 484
6.62.4. Creating the Component Dynamically Using Java ................................. 484
6.62.5. Details of Usage ................................................................................. 484
6.62.6. Look-and-Feel Customization .............................................................. 485
6.62.7. Relevant Resources Links ................................................................... 485
6.63. < rich:jQuery > ............................................................................................. 485
6.63.1. Description ......................................................................................... 485
6.63.2. Key Features ...................................................................................... 485
6.63.3. Creating the Component with a Page Tag ............................................ 486
6.63.4. Creating the Component Dynamically Using Java ................................. 487
6.63.5. Details of Usage ................................................................................. 487
6.63.6. Look-and-Feel Customization .............................................................. 491
6.63.7. Relevant Resources Links ................................................................... 491
6.64. < rich:listShuttle > ........................................................................................ 491
6.64.1. Description ......................................................................................... 491
6.64.2. Key Features ...................................................................................... 491
6.64.3. Creating the Component with a Page Tag ............................................ 495
6.64.4. Creating the Component Dynamically Using Java ................................. 495
6.64.5. Details of Usage ................................................................................. 495
6.64.6. JavaScript API .................................................................................... 500
6.64.7. Look-and-Feel Customization .............................................................. 500
6.64.8. Skin Parameters Redefinition .............................................................. 501
6.64.9. Definition of Custom Style Classes ...................................................... 503
6.64.10. Relevant Resources Links ................................................................. 507
6.65. < rich:message > ......................................................................................... 507
6.65.1. Description ......................................................................................... 507
6.65.2. Key Features ...................................................................................... 507
6.65.3. Creating the Component with a Page Tag ............................................ 510
xv
RichFaces Developer Guide
xvi
6.70. < rich:panel > .............................................................................................. 554
6.70.1. Description ......................................................................................... 554
6.70.2. Key Features ...................................................................................... 554
6.70.3. Creating the Component with a Page Tag ............................................ 555
6.70.4. Creating the Component Dynamically Using Java ................................. 556
6.70.5. Details of Usage ................................................................................. 556
6.70.6. Look-and-Feel Customization .............................................................. 558
6.70.7. Skin Parameters Redefinition .............................................................. 558
6.70.8. Definition of Custom Style Classes ...................................................... 559
6.70.9. Relevant Resources Links ................................................................... 561
6.71. < rich:panelBar > ......................................................................................... 561
6.71.1. Description ......................................................................................... 561
6.71.2. Key Features ...................................................................................... 561
6.71.3. Creating the Component with a Page Tag ............................................ 563
6.71.4. Creating the Component Dynamically Using Java ................................. 564
6.71.5. Details of Usage ................................................................................. 564
6.71.6. Look-and-Feel Customization .............................................................. 564
6.71.7. Skin Parameters Redefinition .............................................................. 564
6.71.8. Definition of Custom Style Classes ...................................................... 565
6.71.9. Relevant Resources Links ................................................................... 567
6.72. < rich:panelBarItem > ................................................................................... 567
6.72.1. Description ......................................................................................... 567
6.72.2. Key Features ...................................................................................... 567
6.72.3. Creating the Component with a Page Tag ............................................ 568
6.72.4. Creating the Component Dynamically Using Java ................................. 569
6.72.5. Details of Usage ................................................................................. 569
6.72.6. Look-and-Feel Customization .............................................................. 570
6.72.7. Skin Parameters Redefinition .............................................................. 570
6.72.8. Definition of Custom Style Classes ...................................................... 570
6.73. < rich:panelMenu > ...................................................................................... 573
6.73.1. Description ......................................................................................... 573
6.73.2. Key Features ...................................................................................... 573
6.73.3. Creating the Component with a Page Tag ............................................ 579
6.73.4. Creating the Component Dynamically Using Java ................................. 579
6.73.5. Details of Usage ................................................................................. 580
6.73.6. JavaScript API .................................................................................... 582
6.73.7. Look-and-Feel Customization .............................................................. 583
6.73.8. Definition of Custom Style Classes ...................................................... 583
6.73.9. Relevant Resources Links ................................................................... 585
6.74. < rich:panelMenuGroup > ............................................................................. 585
6.74.1. Description ......................................................................................... 585
6.74.2. Key Features ...................................................................................... 585
6.74.3. Creating the Component with a Page Tag ............................................ 591
6.74.4. Creating the Component Dynamically Using Java ................................. 591
xvii
RichFaces Developer Guide
xviii
6.78.7. Look-and-Feel Customization .............................................................. 640
6.78.8. Skin Parameters Redefinition .............................................................. 641
6.78.9. Definition of Custom Style Classes ...................................................... 642
6.78.10. Relevant Resources Links ................................................................. 646
6.79. < rich:separator > ........................................................................................ 646
6.79.1. Description ......................................................................................... 646
6.79.2. Key Features ...................................................................................... 646
6.79.3. Creating the Component with a Page Tag ............................................ 647
6.79.4. Creating the Component Dynamically Using Java ................................. 648
6.79.5. Details of Usage ................................................................................. 648
6.79.6. Look-and-Feel Customization .............................................................. 649
6.79.7. Definition of Custom Style Classes ...................................................... 649
6.79.8. Relevant Resources Links ................................................................... 650
6.80. < rich:simpleTogglePanel > ........................................................................... 650
6.80.1. Description ......................................................................................... 650
6.80.2. Key Features ...................................................................................... 651
6.80.3. Creating the Component with a Page Tag ............................................ 654
6.80.4. Creating the Component Dynamically Using Java ................................. 655
6.80.5. Details of Usage ................................................................................. 655
6.80.6. Look-and-Feel Customization .............................................................. 656
6.80.7. Skin Parameters Redefinition .............................................................. 656
6.80.8. Definition of Custom Style Classes ...................................................... 657
6.80.9. Relevant Resources Links ................................................................... 659
6.81. < rich:spacer > ............................................................................................ 659
6.81.1. Description ......................................................................................... 659
6.81.2. Key Features ...................................................................................... 660
6.81.3. Creating the Component with a Page Tag ............................................ 661
6.81.4. Creating the Component Dynamically Using Java ................................. 661
6.81.5. Details of Usage ................................................................................. 662
6.81.6. Look-and-Feel Customization .............................................................. 662
6.81.7. Relevant Resources Links ................................................................... 662
6.82. < rich:suggestionbox > ................................................................................. 662
6.82.1. Description ......................................................................................... 662
6.82.2. Key Features ...................................................................................... 663
6.82.3. Creating the Component with a Page Tag ............................................ 669
6.82.4. Creating the Component Dynamically Using Java ................................. 670
6.82.5. Details of Usage ................................................................................. 670
6.82.6. JavaScript API .................................................................................... 673
6.82.7. Look-and-Feel Customization .............................................................. 674
6.82.8. Skin Parameters Redefinition .............................................................. 674
6.82.9. Definition of Custom Style Classes ...................................................... 675
6.82.10. Relevant Resources Links ................................................................. 677
6.83. < rich:tabPanel > ......................................................................................... 677
6.83.1. Description ......................................................................................... 677
xix
RichFaces Developer Guide
xx
6.88. < rich:toolBarGroup > ................................................................................... 720
6.88.1. Description ......................................................................................... 720
6.88.2. Key Features ...................................................................................... 720
6.88.3. ......................................................................................................... 722
6.88.4. Creating the Component with a Page Tag ............................................ 722
6.88.5. Creating the Component Dynamically Using Java ................................. 723
6.88.6. Details of Usage ................................................................................. 723
6.88.7. Look-and-Feel Customization .............................................................. 724
6.88.8. Definition of Custom Style Classes ...................................................... 724
6.88.9. Relevant resources links ..................................................................... 725
6.89. < rich:toolTip > ............................................................................................ 725
6.89.1. Description ......................................................................................... 725
6.89.2. Key Features ...................................................................................... 725
6.89.3. Creating the Component with a Page Tag ............................................ 728
6.89.4. Creating the Component Dynamically Using Java ................................. 729
6.89.5. Details of Usage ................................................................................. 729
6.89.6. JavaScript API .................................................................................... 732
6.89.7. Look-and-Feel Customization .............................................................. 732
6.89.8. Skin Parameters Redefinition .............................................................. 732
6.89.9. Definition of Custom Style Classes ...................................................... 733
6.89.10. Relevant Resources Links ................................................................. 734
6.90. < rich:tree > ................................................................................................. 734
6.90.1. Description ......................................................................................... 734
6.90.2. Key Features ...................................................................................... 735
6.90.3. Creating the Component with a Page Tag ............................................ 741
6.90.4. Creating the Component Dynamically Using Java ................................. 741
6.90.5. Details of Usage ................................................................................. 742
6.90.6. Built-In Drag and Drop ........................................................................ 746
6.90.7. Events handling .................................................................................. 748
6.90.8. Look-and-Feel Customization .............................................................. 749
6.90.9. Skin Parameters Redefinition: ............................................................. 749
6.90.10. Definition of Custom Style Classes .................................................... 749
6.90.11. Relevant Resources Links ................................................................. 751
6.91. < rich:treeNode > ......................................................................................... 751
6.91.1. Description ......................................................................................... 751
6.91.2. Key Features ...................................................................................... 752
6.91.3. Creating the Component with a Page Tag ............................................ 756
6.91.4. Creating the Component Dynamically Using Java ................................. 756
6.91.5. Details of Usage ................................................................................. 757
6.91.6. Built-in Drag and Drop ........................................................................ 758
6.91.7. Events Handling ................................................................................. 758
6.91.8. Look-and-Feel Customization .............................................................. 758
6.91.9. Skin Parameters Redefinition .............................................................. 759
6.91.10. Definition of Custom Style Classes .................................................... 759
xxi
RichFaces Developer Guide
xxii
Chapter 1.
Introduction
RichFaces is an open source framework that adds Ajax capability into existing JSF applications
without resorting to JavaScript.
• Intensify the whole set of JSF benefits while working with Ajax. RichFaces is fully integrated into
the JSF lifecycle. While other frameworks only give you access to the managed bean facility,
RichFaces advantages the action and value change listeners, as well as invokes server-side
validators and converters during the Ajax request-response cycle.
• Add Ajax capability to the existing JSF applications. Framework provides two components
libraries (Core Ajax and UI). The Core library sets Ajax functionality into existing pages, so
there is no need to write any JavaScript code or to replace existing components with new Ajax
ones. RichFaces enables page-wide Ajax support instead of the traditional component-wide
support and it gives the opportunity to define the event on the page. An event invokes an Ajax
request and areas of the page which become synchronized with the JSF Component Tree after
changing the data on the server by Ajax request in accordance with events fired on the client.
• Create quickly complex View basing on out of the box components. RichFaces UI library
contains components for adding rich user interface features to JSF applications. It extends
the RichFaces framework to include a large (and growing) set of powerful rich Ajax-enabled
components that come with extensive skins support. In addition, RichFaces components are
designed to be used seamlessly with other 3d-party component libraries on the same page, so
you have more options for developing your applications.
• Write your own custom rich components with built-in Ajax support. We're always working on
improvement of Component Development Kit (CDK) that was used for RichFaces UI library
creation. The CDK includes a code-generation facility and a templating facility using a JSP-
like syntax. These capabilities help to avoid a routine process of a component creation.
The component factory works like a well-oiled machine allowing the creation of first-class
rich components with built-in Ajax functionality even more easily than the creation of simpler
components by means of the traditional coding approach.
• Package resources with application Java classes. In addition to its core, Ajax functionality of
RichFaces provides an advanced support for the different resources management: pictures,
JavaScript code, and CSS stylesheets. The resource framework makes possible to pack easily
these resources into Jar files along with the code of your custom components.
1
Chapter 1. Introduction
• Easily generate binary resources on-the-fly. Resource framework can generate images,
sounds, Excel spreadsheets etc.. on-the-fly so that it becomes for example possible to create
images using the familiar approach of the "Java Graphics2D" library.
• Create a modern rich user interface look-and-feel with skins-based technology. RichFaces
provides a skinnability feature that allows easily define and manage different color schemes
and other parameters of the UI with the help of named skin parameters. Hence, it is possible
to access the skin parameters from JSP code and the Java code (e.g. to adjust generated on-
the-fly images based on the text parts of the UI). RichFaces comes with a number of predefined
skins to get you started, but you can also easily create your own custom skins.
• Test and create the components, actions, listeners, and pages at the same time. An automated
testing facility is in our roadmap for the near future. This facility will generate test cases for your
component as soon as you develop it. The testing framework will not just test the components,
but also any other server-side or client-side functionality including JavaScript code. What is
more, it will do all of this without deploying the test application into the Servlet container.
RichFaces UI components come ready to use out-of-the-box, so developers save their time and
immediately gain the advantage of the mentioned above features in Web applications creation.
As a result, usage experience can be faster and easily obtained.
2
Chapter 2.
Technical Requirements
RichFaces was developed with an open architecture to be compatible with the widest possible
variety of environments.
• Java
• JavaServer Faces
• RichFaces framework
• MyFaces 1.2
• Resin 3.1
• Jetty 6.1.x
• Glassfish (J2EE 5)
3
Chapter 2. Technical Requirements
• JBoss 4.2.x - 5
• Safari 2.0-3.1
Note:
This list is composed basing on reports received from our users. We assume the list can be
incomplete and absence of your environment in the list doesn't mean incompatibility.
We appreciate your feedback on platforms and browsers that aren't in the list but are compatible
with RichFaces. It helps us to keep the list up-to-date.
4
Chapter 3.
http://labs.jboss.com/jbossrichfaces/downloads
in the RichFaces project area under JBoss.
3.2. Installation
• Add the following content into the "WEB-INF/web.xml" file of your application:
...
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
• Add the following lines for each JSP page of your application.
5
Chapter 3. Getting Started wi...
<xmlns:a4j="http://richfaces.org/a4j">
<xmlns:rich="http://richfaces.org/rich">
This simple application let you input some text into the <h:inputText> , send data to the server,
and see the server response as a value of <h:outputText> .
Only two tags distinguish this page from a "regular" JSF one. There are <rich:panel> and
<a4j:support> .
The <rich:panel> allows to place the page elements in rectangle panel that can be skinned.
6
Data Bean
The <a4j:support> with corresponding attributes (as it was shown in the previous example) adds
an Ajax support to the parent <h:inputText> tag. This support is bound to "onkeyup" JavaScript
event, so that each time when this event is fired on the parent tag, our application sends an Ajax
request to the server. It means that the text field pointed to our managed bean property contains
up-to-date value of our input.
The value of "reRender" attribute of the <a4j:support> tag defines which part(s) of our page is
(are) to be updated. In this case, the only part of the page to update is the <h:outputText> tag
because its ID value matches to the value of "reRender" attribute. As you see, it's not difficult to
update multiple elements on the page, only list their IDs as the value of "reRender" .
package demo;
3.3.3. faces-config.xml
Next, it's necessary to register your bean inside of the faces-config.xml file:
7
Chapter 3. Getting Started wi...
<property-name>text</property-name>
<value/>
</managed-property>
</managed-bean>
</faces-config>
Note:
3.3.4. Web.xml
It is also necessary to add jar files (see installation chapter) and modify the "web.xml" file:
<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-
app_2_4.xsd">
<display-name>a4jEchoText</display-name>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
8
Deployment
</listener>
3.3.5. Deployment
Finally, you should be able to place this application on your Web server.To start your project, point
your browser at http://localhost:8080/a4jEchoText/echo.jsf
9
10
Chapter 4.
11
Chapter 4. Settings for diffe...
12
Web Application Descriptor Parameters
13
Chapter 4. Settings for diffe...
Note:
java.sun.com [http://java.sun.com/javaee/javaserverfaces/]
14
Apache MyFaces
Additional information how to get ViewExpiredExceptions when using RichFaces with JSF 1.2
you can find here [http://wiki.jboss.org/auth/wiki//RichFacesCookbook/ViewExpiredException].
There are some problems with different filters defined in the web.xml file clashing. To avoid these
problems, the RichFaces filter must be the first one among other filters in the web.xml configuration
file.
There's one more problem while using MyFaces + Seam . If you use this combination you should
use <a4j:page> inside <f:view> (right after it in your code) wrapping another content inside
your pages because of some problems in realization of <f:view> in myFaces.
You should also take into account that some JSF frameworks such as Facelets use their
own ViewHandler and need to have it first in the chain of ViewHandlers and the RichFaces
AjaxViewHandler is not an exception. At first RichFaces installs its ViewHandler in any case, so in
case of two frameworks, for example RichFaces + Facelets, no changes in settings are required.
Although, when more then one framework (except RichFaces) is used, it's possible to use the
VIEW_HANDLERS parameter defining these frameworks view handlers according to its usage order
in it. For example, the declaration:
Example:
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
says that Facelets will officially be the first, however AjaxViewHandler will be a little ahead
temporarily to do some small, but very important job.
15
Chapter 4. Settings for diffe...
Note:
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
</context-param>
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
16
JBoss Seam Support
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.web.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupSer