RichFaces Developer Guide
RichFaces framework with a huge library of
rich components and skinnability support
Copyright © 2007 Red Hat
ii
Table of Contents
1. Introduction ............................................................................................................................... 1
2. Technical Requirements ............................................................................................................. 3
2.1. Supported Java Versions ................................................................................................. 3
2.2. Supported JavaServer Faces Implementations ................................................................... 3
2.3. Supported Servers ........................................................................................................... 3
2.4. Supported Browsers ........................................................................................................ 4
3. Getting Started with RichFaces .................................................................................................. 5
3.1. Downloading RichFaces 3.1.0 .......................................................................................... 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 .............................................................................................................. 7
3.3.5. Deployment ......................................................................................................... 8
4. Settings for different environments ............................................................................................. 9
4.1. Web Application Descriptor Parameters ........................................................................... 9
4.2. Sun JSF RI ................................................................................................................... 11
4.3. Apache MyFaces ........................................................................................................... 12
4.4. Facelets Support ............................................................................................................ 12
4.5. JBoss Seam Support ...................................................................................................... 12
4.6. Portlet Support .............................................................................................................. 15
4.7. Sybase EAServer .......................................................................................................... 15
5. Basic concepts of the RichFaces Framework ............................................................................. 17
5.1. Introduction .................................................................................................................. 17
5.2. RichFaces Architecture Overview .................................................................................. 18
5.3. Limitations and Rules .................................................................................................... 20
5.4. Ajax Request Optimization ............................................................................................ 21
5.4.1. Re-Rendering ..................................................................................................... 21
5.4.2. Queue and Traffic Flood Protection ..................................................................... 23
5.4.3. Data Processing Options ..................................................................................... 23
5.4.4. Action and Navigation ........................................................................................ 24
5.4.5. JavaScript Interactions ........................................................................................ 25
5.4.6. Iteration components Ajax attributes .................................................................... 26
5.4.7. Other useful attributes ........................................................................................ 26
5.5. How To... ..................................................................................................................... 27
5.5.1. Send an Ajax request .......................................................................................... 27
5.5.2. Decide What to Send .......................................................................................... 27
5.5.3. Decide What to Change ...................................................................................... 28
5.6. Filter Configuration ....................................................................................................... 28
5.7. Scripts and Styles Load Strategy .................................................................................... 30
5.8. Request Errors and Session Expiration Handling ............................................................. 31
5.8.1. Request Errors Handling ..................................................................................... 31
RichFaces Developer Guide
iii
5.8.2. Session Expired Handling ................................................................................... 31
5.9. Skinnability .................................................................................................................. 32
5.9.1. Why Skinnability ................................................................................................ 32
5.9.2. Using Skinnability .............................................................................................. 32
5.9.3. Example ............................................................................................................. 33
5.9.4. Skin Parameters Tables in RichFaces ................................................................... 34
5.9.5. Creating and Using Your Own Skin File .............................................................. 36
5.9.6. Built-in skinnability in RichFaces ........................................................................ 36
6. The RichFaces Components ..................................................................................................... 38
6.1. < a4j:ajaxListener > ..................................................................................................... 38
6.1.1. Creating on a page ............................................................................................. 38
6.1.2. Dynamical creation of a component from Java code ............................................. 38
6.1.3. Key attributes and ways of usage ........................................................................ 39
6.1.4. .......................................................................................................................... 39
6.1.5. Relevant resources links ..................................................................................... 39
6.2. < a4j:keepAlive > ........................................................................................................ 39
6.2.1. Creating on a page ............................................................................................. 40
6.2.2. Dynamical creation of a component from Java code ............................................. 40
6.2.3. Key attributes and ways of usage ........................................................................ 40
6.2.4. Relevant resources links ..................................................................................... 41
6.3. < a4j:outputPanel > ...................................................................................................... 41
6.3.1. Description ......................................................................................................... 41
6.3.2. Creating on a page ............................................................................................. 43
6.3.3. Dynamical creation of a component from Java code ............................................. 43
6.3.4. Key attributes and ways of usage ........................................................................ 43
6.3.5. Relevant resources links ..................................................................................... 45
6.4. < a4j:repeat > .............................................................................................................. 45
6.4.1. Description ......................................................................................................... 45
6.4.2. Creating on a page ............................................................................................. 46
6.4.3. Dynamical creation of a component from Java code ............................................. 46
6.4.4. Key attributes and ways of usage ........................................................................ 46
6.4.5. Relevant resources links ..................................................................................... 47
6.5. < a4j:log > .................................................................................................................. 47
6.5.1. Description ......................................................................................................... 47
6.5.2. .......................................................................................................................... 48
6.5.3. Creating on a page ............................................................................................. 48
6.5.4. Dynamical creation of a component from Java code ............................................. 48
6.5.5. Key attributes and ways of usage ........................................................................ 49
6.5.6. Relevant resources links ..................................................................................... 49
6.6. < a4j:include > ............................................................................................................ 49
6.6.1. Description ......................................................................................................... 49
6.6.2. Creating on a page ............................................................................................. 51
6.6.3. Dynamical creation of a component from Java code ............................................. 51
6.6.4. Relevant resources links ..................................................................................... 52
6.7. < a4j:region > .............................................................................................................. 52
RichFaces Developer Guide
iv
6.7.1. Description ......................................................................................................... 52
6.7.2. Creating on a page ............................................................................................. 53
6.7.3. Dynamical creation of a component from Java code ............................................. 53
6.7.4. Key attributes and ways of usage ........................................................................ 53
6.7.5. Relevant resources links ..................................................................................... 55
6.8. < a4j:status > ............................................................................................................... 55
6.8.1. Description ......................................................................................................... 55
6.8.2. Creating on a page ............................................................................................. 57
6.8.3. Dynamical creation of a component from Java code ............................................. 57
6.8.4. Key attributes and ways of usage ........................................................................ 57
6.8.5. Relevant resources links ..................................................................................... 58
6.9. < a4j:jsFunction > ........................................................................................................ 58
6.9.1. Description ......................................................................................................... 58
6.9.2. Creating on a page ............................................................................................. 60
6.9.3. Dynamical creation of a component from Java code ............................................. 61
6.9.4. Key attributes and ways of usage ........................................................................ 61
6.9.5. Relevant resources links ..................................................................................... 62
6.10. < a4j:portlet > ............................................................................................................ 62
6.10.1. Description ....................................................................................................... 62
6.10.2. Creating on a page ........................................................................................... 62
6.10.3. Dynamical creation of a component from Java code ............................................ 62
6.10.4. Key attributes and ways of usage ...................................................................... 63
6.10.5. Relevant resources links .................................................................................... 63
6.11. < a4j:commandLink > ................................................................................................ 63
6.11.1. Description ....................................................................................................... 63
6.11.2. Creating on a page ........................................................................................... 67
6.11.3. Dynamical creation of a component from Java code ............................................ 67
6.11.4. Key attributes and ways of usage ...................................................................... 67
6.11.5. Relevant resources links .................................................................................... 68
6.12. < a4j:mediaOutput > .................................................................................................. 68
6.12.1. Description ....................................................................................................... 68
6.12.2. Creating on a page ........................................................................................... 72
6.12.3. Dynamical creation of a component from Java code ............................................ 73
6.12.4. Key attributes and ways of usage ...................................................................... 73
6.12.5. Relevant resources links .................................................................................... 73
6.13. < a4j:loadStyle > ....................................................................................................... 74
6.13.1. Description ....................................................................................................... 74
6.13.2. Creating on a page ........................................................................................... 74
6.13.3. Dynamical creation of a component from Java code ............................................ 74
6.13.4. Key attributes and ways of usage ...................................................................... 75
6.14. < a4j:form > .............................................................................................................. 75
6.14.1. Description ....................................................................................................... 75
6.14.2. Creating on a page ........................................................................................... 77
6.14.3. Dynamical creation of a component from Java code ............................................ 78
6.14.4. Key attributes and ways of usage ...................................................................... 78
RichFaces Developer Guide
v
6.14.5. Relevant resources links .................................................................................... 78
6.15. < a4j:htmlCommandLink > ......................................................................................... 79
6.15.1. Description ....................................................................................................... 79
6.15.2. Creating on a page ........................................................................................... 82
6.15.3. Dynamical creation of a component from Java code ............................................ 82
6.15.4. Key attributes and ways of usage ...................................................................... 82
6.15.5. Relevant resources links .................................................................................... 82
6.16. < a4j:loadScript > ...................................................................................................... 83
6.16.1. Description ....................................................................................................... 83
6.16.2. Creating on a page ........................................................................................... 83
6.16.3. Dynamical creation of a component from Java code ............................................ 83
6.16.4. Key attributes and ways of usage ...................................................................... 84
6.16.5. Relevant resources links .................................................................................... 84
6.17. < a4j:poll > ............................................................................................................... 84
6.17.1. Description ....................................................................................................... 84
6.17.2. Creating on a page ........................................................................................... 86
6.17.3. Dynamical creation of a component from Java code ............................................ 86
6.17.4. Key attributes and ways of usage ...................................................................... 86
6.17.5. Relevant resources links .................................................................................... 87
6.18. < a4j:loadBundle > .................................................................................................... 88
6.18.1. Creating on a page ........................................................................................... 88
6.18.2. Dynamical creation of a component from Java code ............................................ 88
6.18.3. Key attributes and ways of usage ...................................................................... 89
6.18.4. Relevant resources links .................................................................................... 89
6.19. < a4j:commandButton > ............................................................................................. 89
6.19.1. Description ....................................................................................................... 89
6.19.2. Creating on a page ........................................................................................... 93
6.19.3. Dynamical creation of a component from Java code ............................................ 93
6.19.4. Key attributes and ways of usage ...................................................................... 93
6.19.5. Relevant resources links .................................................................................... 94
6.20. < a4j:page > .............................................................................................................. 94
6.20.1. Description ....................................................................................................... 94
6.20.2. Creating on a page ........................................................................................... 95
6.20.3. Dynamical creation of a component from Java code ............................................ 96
6.20.4. Key attributes and ways of usage ...................................................................... 96
6.20.5. Relevant resources links .................................................................................... 96
6.21. < a4j:support > .......................................................................................................... 96
6.21.1. Description ....................................................................................................... 96
6.21.2. Creating on a page ........................................................................................... 99
6.21.3. Dynamical creation of a component from Java code ............................................ 99
6.21.4. Key attributes and ways of usage ...................................................................... 99
6.21.5. Relevant resources links .................................................................................. 101
6.22. < a4j:actionparam > ................................................................................................. 101
6.22.1. Creating on a page .......................................................................................... 102
6.22.2. Dynamical creation of a component from Java code .......................................... 102
评论2