Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

RichFaces Developer Guide

RichFaces framework with a huge library of rich components and skinnability support


1. Introduction
+2. Technical Requirements
2.1. Supported Java Versions
2.2. Supported JavaServer Faces Implementations and Frameworks
2.3. Supported Servers
2.4. Supported Browsers
+3. Getting Started with RichFaces
3.1. Downloading the RichFaces
+3.2. Simple JSF application with RichFaces
3.2.1. Adding RichFaces libraries into the project
3.2.2. Registering RichFaces in web.xml
3.2.3. Managed bean
3.2.4. Registering bean in faces-cofig.xml
3.2.5. RichFaces Greeter index.jsp
3.3. Relevant Resources Links
+4. Settings for different environments
4.1. Web Application Descriptor Parameters
4.2. Sun JSF RI
4.3. Apache MyFaces
4.4. Facelets Support
4.5. JBoss Seam Support
4.6. Portlet Support
4.7. Sybase EAServer
4.8. Oracle AS/OC4J
+5. Basic concepts of the RichFaces Framework
5.1. Introduction
5.2. RichFaces Architecture Overview
5.3. RichFaces Integral Parts
5.4. Limitations and Rules
+5.5. Ajax Request Optimization
5.5.1. Re-Rendering
5.5.2. Queue and Traffic Flood Protection
+5.5.3. Queue Principles
5.5.3.1. Global default queue, defined in the web.xml file
5.5.3.2. View scoped default queue
5.5.3.3. View scoped named queue
5.5.3.4. Form based default queue
+5.5.3.5. Queue functionality
5.5.3.5.1. Events Similarity
5.5.3.5.2. Similar requests during request delay
5.5.3.5.3. JavaScript API
5.5.4. Data Processing Options
5.5.5. Action and Navigation
5.5.6. JavaScript Interactions
5.5.7. Iteration components Ajax attributes
5.5.8. Other useful attributes
+5.6. How To...
5.6.1. Send an Ajax request
5.6.2. Decide What to Send
5.6.3. Decide What to Change
5.6.4. Decide what to process
5.7. Filter Configuration
5.8. Scripts and Styles Load Strategy
+5.9. Request Errors and Session Expiration Handling
5.9.1. Request Errors Handling
5.9.2. Session Expired Handling
+5.10. Skinnability
5.10.1. Why Skinnability
5.10.2. Using Skinnability
5.10.3. Example
5.10.4. Skin Parameters Tables in RichFaces
5.10.5. Creating and Using Your Own Skin File
5.10.6. Built-in Skinnability in RichFaces
5.10.7. Changing skin in runtime
+5.10.8. Standard Controls Skinning
5.10.8.1. Standard level
5.10.8.2. Extended level
5.10.9. Client-side Script for Extended Skinning Support
5.10.10. XCSS File Format
+5.10.11. Plug-n-Skin
5.10.11.1. Details of Usage
5.11. State Manager API
5.12. Identifing User Roles
+6. The RichFaces Components
+6.1. < a4j:ajaxListener >
6.1.1. Description
6.1.2. Creating on a page
6.1.3. Creating the Component Dynamically Using Java
6.1.4. Key attributes and ways of usage
6.1.5. Relevant resources links
+6.2. < a4j:keepAlive >
6.2.1. Description
6.2.2. Using the tag on a Page
6.2.3. Key attributes and ways of usage
6.2.4. Relevant resources links
+6.3. < a4j:actionparam >
6.3.1. Description
6.3.2. Creating on a page
6.3.3. Creating the Component Dynamically Using Java
6.3.4. Key attributes and ways of usage
6.3.5. Relevant resources links
+6.4. < a4j:commandButton >
6.4.1. Description
6.4.2. Creating on a page
6.4.3. Creating the Component Dynamically Using Java
6.4.4. Key attributes and ways of usage
6.4.5. Relevant resources links
+6.5. < a4j:commandLink >
6.5.1. Description
6.5.2. Creating on a page
6.5.3. Creating the Component Dynamically Using Java
6.5.4. Key attributes and ways of usage
6.5.5. Relevant resources links
+6.6. < a4j:form >
6.6.1. Description
6.6.2. Creating on a page
6.6.3. Creating the Component Dynamically Using Java
6.6.4. Key attributes and ways of usage
6.6.5. Relevant resources links
+6.7. < a4j:htmlCommandLink >
6.7.1. Description
6.7.2. Creating the Component with a Page Tag
6.7.3. Creating the Component Dynamically Using Java
6.7.4. Key attributes and ways of usage
6.7.5. Relevant resources links
+6.8. < a4j:jsFunction >
6.8.1. Description
6.8.2. Creating on a page
6.8.3. Creating the Component Dynamically Using Java
6.8.4. Key attributes and ways of usage
6.8.5. Relevant resources links
+6.9. < a4j:include >
6.9.1. Description
6.9.2. Creating on a page
6.9.3. Creating the Component Dynamically Using Java
6.9.4. Relevant resources links
+6.10. < a4j:loadBundle >
6.10.1. Description
6.10.2. Creating on a page
6.10.3. Creating the Component Dynamically Using Java
6.10.4. Key attributes and ways of usage
6.10.5. Relevant resources links
+6.11. < a4j:loadScript >
6.11.1. Description
6.11.2. Creating on a page
6.11.3. Creating the Component Dynamically Using Java
6.11.4. Key attributes and ways of usage
6.11.5. Relevant resources links
+6.12. < a4j:loadStyle >
6.12.1. Description
6.12.2. Creating on a page
6.12.3. Creating the Component Dynamically Using Java
6.12.4. Key attributes and ways of usage
6.12.5. Relevant resources links
+6.13. < a4j:log >
6.13.1. Description
6.13.2. Creating the Component with a Page Tag
6.13.3. Creating the Component Dynamically Using Java
6.13.4. Key attributes and ways of usage
6.13.5. Relevant resources links
+6.14. < a4j:mediaOutput >
6.14.1. Description
6.14.2. Creating on a page
6.14.3. Creating the Component Dynamically Using Java
6.14.4. Key attributes and ways of usage
6.14.5. Relevant resources links
+6.15. < a4j:outputPanel >
6.15.1. Description
6.15.2. Creating on a page
6.15.3. Creating the Component Dynamically Using Java
6.15.4. Key attributes and ways of usage
6.15.5. Relevant resources links
+6.16. < a4j:page >
6.16.1. Description
6.16.2. Creating on a page
6.16.3. Creating the Component Dynamically Using Java
6.16.4. Facets
6.16.5. Key attributes and ways of usage
6.16.6. Relevant resources links
+6.17. < a4j:poll >
6.17.1. Description
6.17.2. Creating on a page
6.17.3. Creating the Component Dynamically Using Java
6.17.4. Key attributes and ways of usage
6.17.5. Relevant resources links
+6.18. < a4j:portlet >
6.18.1. Description
6.18.2. Creating the Component with a Page Tag
6.18.3. Creating the Component Dynamically Using Java
6.18.4. Key attributes and ways of usage
6.18.5. Relevant resources links
+6.19. < a4j:push >
6.19.1. Description
6.19.2. Creating on a page
6.19.3. Creating the Component Dynamically Using Java
6.19.4. Key attributes and ways of usage
6.19.5. Relevant resources links
+6.20. < a4j:queue >
6.20.1. Description
6.20.2. Creating on a page
6.20.3. Creating the Component Dynamically Using Java
6.20.4. Key attributes and ways of usage
6.20.5. JavaScript API
6.20.6. Relevant resources links
+6.21. < a4j:region >
6.21.1. Description
6.21.2. Creating on a page
6.21.3. Creating the Component Dynamically Using Java
6.21.4. Key attributes and ways of usage
6.21.5. Relevant resources links
+6.22. < a4j:repeat >
6.22.1. Description
6.22.2. Creating on a page
6.22.3. Creating the Component Dynamically Using Java
6.22.4. Key attributes and ways of usage
6.22.5. Relevant resources links
+6.23. < a4j:status >
6.23.1. Description
6.23.2. Creating on a page
6.23.3. Creating the Component Dynamically Using Java
6.23.4. Facets
6.23.5. Key attributes and ways of usage
6.23.6. Relevant resources links
+6.24. < a4j:support >
6.24.1. Description
6.24.2. Creating on a page
6.24.3. Creating the Component Dynamically Using Java
6.24.4. Key attributes and ways of usage
6.24.5. Relevant resources links
+6.25. < rich:ajaxValidator >
6.25.1. Description
6.25.2. Key Features
6.25.3. Creating the Component with a Page Tag
6.25.4. Creating the Component Dynamically Using Java
6.25.5. Details of Usage
6.25.6. Relevant Resources Links
+6.26. < rich:graphValidator >
6.26.1. Description
6.26.2. Key Features
6.26.3. Creating the Component with a Page Tag
6.26.4. Creating the Component Dynamically Using Java
6.26.5. Relevant Resources Links
+6.27. < rich:beanValidator >
6.27.1. Description
6.27.2. Key Features
6.27.3. Creating the Component with a Page Tag
6.27.4. Creating the Component Dynamically Using Java
6.27.5. Details of Usage
6.27.6. Relevant Resources Links
+6.28. < rich:calendar >
6.28.1. Description
6.28.2. Key Features
6.28.3. Creating the Component with a Page Tag
6.28.4. Creating the Component Dynamically Using Java
6.28.5. Details of Usage
6.28.6. JavaScript API
6.28.7. Facets
6.28.8. Look-and-Feel Customization
6.28.9. Skin Parameters Redefinition
6.28.10. Definition of Custom Style Classes
6.28.11. Relevant Resources Links
+6.29. < rich:colorPicker >
6.29.1. Description
6.29.2. Key Features
6.29.3. Creating the Component with a Page Tag
6.29.4. Creating the Component Dynamically Using Java
6.29.5. Details of Usage
6.29.6. Look-and-Feel Customization
6.29.7. Skin Parameters Redefinition
6.29.8. Definition of Custom Style Classes
6.29.9. Relevant Resources Links
+6.30. < rich:comboBox >
6.30.1. Description
6.30.2. Key Features
6.30.3. Creating the Component with a Page Tag
6.30.4. Creating the Component Dynamically Using Java
6.30.5. Details of Usage
6.30.6. JavaScript API
6.30.7. Look-and-Feel Customization
6.30.8. Skin Parameters Redefinition
6.30.9. Definition of Custom Style Classes
6.30.10. Relevant Resources Links
+6.31. < rich:componentControl >
6.31.1. Description
6.31.2. Key Features
6.31.3. Creating the Component with a Page Tag
6.31.4. Creating the Component Dynamically Using Java
6.31.5. Details of Usage
6.31.6. Look-and-Feel Customization
6.31.7. Relevant Resources Links
+6.32. < rich:contextMenu >
6.32.1. Description
6.32.2. Key Features
6.32.3. Creating the Component with a Page Tag
6.32.4. Creating the Component Dynamically Using Java
6.32.5. Details of Usage
6.32.6. JavaScript API
6.32.7. Look-and-Feel Customization
6.32.8. Skin Parameters Redefinition
6.32.9. Definition of Custom Style Classes
6.32.10. Relevant Resources Links
+6.33. < rich:dataFilterSlider >
6.33.1. Description
6.33.2. Key Features
6.33.3. Creating the Component with a Page Tag
6.33.4. Creating the Component Dynamically Using Java
6.33.5. Details of Usage
6.33.6. Look-and-Feel Customization
6.33.7. Relevant Resources Links
+6.34. < rich:datascroller >
6.34.1. Description
6.34.2. Key Features
6.34.3. Creating the Component with a Page Tag
6.34.4. Creating the Component Dynamically Using Java
6.34.5. Details of Usage
6.34.6. Facets
6.34.7. Look-and-Feel Customization
6.34.8. Skin Parameters Redefinition
6.34.9. Definition of Custom Style Classes
6.34.10. Relevant Resources Links
+6.35. < rich:columns >
6.35.1. Description
6.35.2. Key Features
6.35.3. Creating the Component with a Page Tag
6.35.4. Creating the Component Dynamically Using Java
6.35.5. Details of Usage
6.35.6. Facets
6.35.7. Look-and-Feel Customization
6.35.8. Skin Parameters Redefinition
6.35.9. Definition of Custom Style Classes
6.35.10. Relevant Resources Links
+6.36. < rich:columnGroup >
6.36.1. Description
6.36.2. Key Features
6.36.3. Creating the Component with a Page Tag
6.36.4. Creating the Component Dynamically Using Java
6.36.5. Details of Usage
6.36.6. Look-and-Feel Customization
6.36.7. Skin Parameters Redefinition
6.36.8. Definition of Custom Style Classes
6.36.9. Relevant Resources Links
+6.37. < rich:column >
6.37.1. Description
6.37.2. Key Features
6.37.3. Creating the Component with a Page Tag
6.37.4. Creating the Component Dynamically Using Java
6.37.5. Details of Usage
+6.37.6. Sorting and Filtering
6.37.6.1. Sorting
6.37.6.2. Filtering
6.37.7. Facets
6.37.8. Look-and-Feel Customization
6.37.9. Skin Parameters Redefinition
6.37.10. Definition of Custom Style Classes
6.37.11. Relevant Resources Links
+6.38. < rich:dataGrid >
6.38.1. Description
6.38.2. Key Features
6.38.3. Creating the Component with a Page Tag
6.38.4. Creating the Component Dynamically Using Java
6.38.5. Details of Usage
6.38.6. Facets
6.38.7. Look-and-Feel Customization
6.38.8. Skin Parameters Redefinition
6.38.9. Definition of Custom Style Classes
6.38.10. Relevant Resources Links
+6.39. < rich:dataList >
6.39.1. Description
6.39.2. Key Features
6.39.3. Creating the Component with a Page Tag
6.39.4. Creating the Component Dynamically Using Java
6.39.5. Details of Usage
6.39.6. Look-and-Feel Customization
6.39.7. Definition of Custom Style Classes
6.39.8. Relevant Resources Links
+6.40. < rich:dataOrderedList >
6.40.1. Description
6.40.2. Key Features
6.40.3. Creating the Component with a Page Tag
6.40.4. Creating the Component Dynamically Using Java
6.40.5. Details of Usage
6.40.6. Look-and-Feel Customization
6.40.7. Definition of Custom Style Classes
6.40.8. Relevant Resources Links
+6.41. < rich:dataDefinitionList >
6.41.1. Description
6.41.2. Key Features
6.41.3. Creating the Component with a Page Tag
6.41.4. Creating the Component Dynamically Using Java
6.41.5. Details of Usage
6.41.6. Look-and-Feel Customization
6.41.7. Definition of Custom Style Classes
6.41.8. Relevant Resources Links
+6.42. < rich:dataTable >
6.42.1. Description
6.42.2. Key Features
6.42.3. Creating the Component with a Page Tag
6.42.4. Creating the Component Dynamically from Java
6.42.5. Details of Usage
6.42.6. Facets
6.42.7. Look-and-Feel Customization
6.42.8. Skin Parameters Redefinition
6.42.9. Definition of Custom Style Classes
6.42.10. Relevant Resources Links
+6.43. < rich:subTable >
6.43.1. Description
6.43.2. Key Features
6.43.3. Creating the Component with a Page Tag
6.43.4. Creating the Component Dynamically Using Java
6.43.5. Details of Usage
6.43.6. Facets
6.43.7. Look-and-Feel Customization
6.43.8. Skin Parameters Redefinition
6.43.9. Definition of Custom Style Classes
+6.44. < rich:editor >
6.44.1. Description
6.44.2. Key Features
6.44.3. Creating the Component with a Page Tag
6.44.4. Creating the Component Dynamically Using Java
6.44.5. Details of Usage
6.44.6. Look-and-Feel Customization
6.44.7. Skin Parameters Redefinition
6.44.8. Definition of Custom Style Selectors
6.44.9. Relevant Resources Links
+6.45. < rich:dndParam >
6.45.1. Description
6.45.2. Creating the Component with a Page Tag
6.45.3. Creating the Component Dynamically Using Java
6.45.4. Details of Usage
6.45.5. Look-and-Feel Customization
6.45.6. Relevan Resources Links
+6.46. < rich:dragIndicator >
6.46.1. Description
6.46.2. Key Features
6.46.3. Creating the Component with a Page Tag
6.46.4. Creating the Component Dynamically Using Java
+6.46.5. Details of Usage
6.46.5.1. Macro definitions
6.46.5.2. Predefined macro definitions
6.46.5.3. Marker customization
6.46.6. Look-and-Feel Customization
6.46.7. Relevant Resources Links
+6.47. < rich:dragSupport >
6.47.1. Description
6.47.2. Key Features
6.47.3. Creating the Component with a Page Tag
6.47.4. Creating the Component Dynamically Using Java
6.47.5. Details of Usage
6.47.6. Look-and-Feel Customization
6.47.7. Relevant Resources Links
+6.48. < rich:dropSupport >
6.48.1. Description
6.48.2. Key Features
6.48.3. Creating the Component with a Page Tag
6.48.4. Creating the Component Dynamically Using Java
6.48.5. Details of Usage
6.48.6. Look-and-Feel Customization
6.48.7. Relevant Resources Links
+6.49. < rich:dragListener >
6.49.1. Description
6.49.2. Key Features
6.49.3. Creating the Component with a Page Tag
6.49.4. Creating the Component Dynamically Using Java
6.49.5. Details of Usage
6.49.6. Look-and-Feel Customization
+6.50. < rich:dropListener >
6.50.1. Description
6.50.2. Key Features
6.50.3. Creating the Component with a Page Tag
6.50.4. Creating the Component Dynamically Using Java
6.50.5. Details of Usage
6.50.6. Look-and-Feel Customization
+6.51. < rich:dropDownMenu >
6.51.1. Description
6.51.2. Key Features
6.51.3. Creating the Component with a Page Tag
6.51.4. Creating the Component Dynamically Using Java
6.51.5. Details of Usage
6.51.6. Facets
6.51.7. Look-and-Feel Customization
6.51.8. Skin Parameters Redefinition
6.51.9. Definition of Custom Style Classes
6.51.10. Relevant Resources Links
+6.52. < rich:extendedDataTable >
6.52.1. Creating the Component with a Page Tag
6.52.2. Creating the Component Dynamically from Java
6.52.3. Details of Usage
6.52.4. Facets
6.52.5. Look-and-Feel Customization
6.52.6. Skin Parameters Redefinition
6.52.7. Definition of Custom Style Classes
6.52.8. Relevant resources links
+6.53. < rich:menuGroup >
6.53.1. Description
6.53.2. Key Features
6.53.3. Creating the Component with a Page Tag
6.53.4. Creating the Component Dynamically Using Java
6.53.5. Details of Usage
6.53.6. Facets
6.53.7. Look-and-Feel Customization
6.53.8. Skin Parameters Redefinition
6.53.9. Definition of Custom Style Classes
6.53.10. Relevant Resources Links
+6.54. < rich:menuItem >
6.54.1. Description
6.54.2. Key Features
6.54.3. Creating the Component with a Page Tag
6.54.4. Creating the Component Dynamically Using Java
6.54.5. Details of Usage
6.54.6. Facets
6.54.7. Look-and-Feel Customization
6.54.8. Skin Parameters Redefinition
6.54.9. Definition of Custom Style Classes
6.54.10. Relevant Resources Links
+6.55. < rich:menuSeparator >
6.55.1. Description
6.55.2. Creating the Component with a Page Tag
6.55.3. Creating the Component Dynamically Using Java
6.55.4. Look-and-Feel Customization
6.55.5. Skin Parameters Redefinition
6.55.6. Definition of Custom Style Classes
6.55.7. Relevant Resources Links
+6.56. < rich:effect >
6.56.1. Description
6.56.2. Key Features
6.56.3. Creating the Component with a Page Tag
6.56.4. Creating the Component Dynamically Using Java
6.56.5. Details of Usage
6.56.6. Look-and-Feel Customization
6.56.7. Relevant Resources Links
+6.57. < rich:fileUpload >
6.57.1. Description
6.57.2. Key Features
6.57.3. Creating the Component with a Page Tag
6.57.4. Creating the Component Dynamically Using Java
6.57.5. Details of Usage
6.57.6. JavaScript API
6.57.7. Facets
6.57.8. Look-and-Feel Customization
6.57.9. Skin Parameters Redefinition
6.57.10. Definition of Custom Style Classes
6.57.11. Relevant Resources Links
+6.58. < rich:gmap >
6.58.1. Description
6.58.2. Key Features
6.58.3. Creating the Component with a Page Tag
6.58.4. Creating the Component Dynamically Using Java
6.58.5. Details of Usage
6.58.6. Look-and-Feel Customization
6.58.7. Definition of Custom Style Classes
6.58.8. Relevant Resources Links
+6.59. < rich:virtualEarth >
6.59.1. Description
6.59.2. Key Features
6.59.3. Creating the Component with a Page Tag
6.59.4. Creating the Component Dynamically Using Java
6.59.5. Details of Usage
6.59.6. Look-and-Feel Customization
6.59.7. Definition of Custom Style Classes
6.59.8. Relevant Resources Links
+6.60. < rich:hotKey >
6.60.1. Description
6.60.2. Key Features
6.60.3. Creating the Component with a Page Tag
6.60.4. Creating the Component Dynamically Using Java
6.60.5. Details of Usage
6.60.6. JavaScript API
6.60.7. Look-and-Feel Customization
6.60.8. Relevant Resources Links
+6.61. < rich:inplaceInput >
6.61.1. Description
6.61.2. Key Features
6.61.3. Creating the Component with a Page Tag
6.61.4. Creating the Component Dynamically Using Java
6.61.5. Details of Usage
6.61.6. JavaScript API
6.61.7. Facets
6.61.8. Look-and-Feel Customization
6.61.9. Skin Parameters Redefinition
6.61.10. Definition of Custom Style Classes
6.61.11. Relevant Resources Links
+6.62. < rich:inplaceSelect >
6.62.1. Description
6.62.2. Key Features
6.62.3. Creating the Component with a Page Tag
6.62.4. Creating the Component Dynamically Using Java
6.62.5. Details of Usage
6.62.6. JavaScript API
6.62.7. Facets
6.62.8. Look-and-Feel Customization
6.62.9. Skin Parameters Redefinition
6.62.10. Definition of Custom Style Classes
6.62.11. Relevant Resources Links
+6.63. < rich:inputNumberSlider >
6.63.1. Description
6.63.2. Key Features
6.63.3. Creating the Component with a Page Tag
6.63.4. Creating the Component Dynamically Using Java
6.63.5. Details of Usage
6.63.6. Look-and-Feel Customization
6.63.7. Skin Parameters Redefinition
6.63.8. Definition of Custom Style Classes
6.63.9. Relevant Resources Links
+6.64. < rich:inputNumberSpinner >
6.64.1. Description
6.64.2. Key Features
6.64.3. Creating the Component with a Page Tag
6.64.4. Creating the Component Dynamically Using Java
6.64.5. Details of Usage
6.64.6. Look-and-Feel Customization
6.64.7. Skin Parameters Redefinition
6.64.8. Definition of Custom Style Classes
6.64.9. Relevant Resources Links
+6.65. < rich:insert >
6.65.1. Description
6.65.2. Key Features
6.65.3. Creating the Component with a Page Tag
6.65.4. Creating the Component Dynamically Using Java
6.65.5. Details of Usage
6.65.6. Look-and-Feel Customization
6.65.7. Relevant Resources Links
+6.66. < rich:jQuery >
6.66.1. Description
6.66.2. Key Features
6.66.3. Creating the Component with a Page Tag
6.66.4. Creating the Component Dynamically Using Java
6.66.5. Details of Usage
6.66.6. Look-and-Feel Customization
6.66.7. Relevant Resources Links
+6.67. < rich:listShuttle >
6.67.1. Description
6.67.2. Key Features
6.67.3. Creating the Component with a Page Tag
6.67.4. Creating the Component Dynamically Using Java
6.67.5. Details of Usage
6.67.6. JavaScript API
6.67.7. Facets
6.67.8. Look-and-Feel Customization
6.67.9. Skin Parameters Redefinition
6.67.10. Definition of Custom Style Classes
6.67.11. Relevant Resources Links
+6.68. < rich:message >
6.68.1. Description
6.68.2. Key Features
6.68.3. Creating the Component with a Page Tag
6.68.4. Creating the Component Dynamically Using Java
6.68.5. Details of Usage
6.68.6. Facets
6.68.7. Look-and-Feel Customization
6.68.8. Definition of Custom Style Classes
6.68.9. Relevant Resources Links
+6.69. < rich:messages >
6.69.1. Description
6.69.2. Key Features
6.69.3. Creating the Component with a Page Tag
6.69.4. Creating the Component Dynamically Using Java
6.69.5. Details of Usage
6.69.6. Look-and-Feel Customization
6.69.7. Definition of Custom Style Classes
6.69.8. Relevant Resources Links
+6.70. < rich:modalPanel >
6.70.1. Description
6.70.2. Key Features
6.70.3. Creating the Component with a Page Tag
6.70.4. Creating the Component Dynamically Using Java
6.70.5. Details of Usage
6.70.6. JavaScript API
6.70.7. Facets
6.70.8. Look-and-Feel Customization
6.70.9. Skin Parameters Redefinition
6.70.10. Definition of Custom Style Classes
6.70.11. Relevant Resources Links
+6.71. < rich:orderingList >
6.71.1. Description
6.71.2. Key Features
6.71.3. Creating the Component with a Page Tag
6.71.4. Creating the Component Dynamically Using Java
6.71.5. Details of Usage
6.71.6. JavaScript API
6.71.7. Facets
6.71.8. Look-and-Feel Customization
6.71.9. Skin Parameters Redefinition
6.71.10. Definition of Custom Style Classes
6.71.11. Relevant Resources Links
+6.72. < rich:paint2D >
6.72.1. Description
6.72.2. Key Features
6.72.3. Creating the Component with a Page Tag
6.72.4. Creating the Component Dynamically Using Java
6.72.5. Details of Usage
6.72.6. Look-and-Feel Customization
6.72.7. Relevant Resources Links
+6.73. < rich:panel >
6.73.1. Description
6.73.2. Key Features
6.73.3. Creating the Component with a Page Tag
6.73.4. Creating the Component Dynamically Using Java
6.73.5. Details of Usage
6.73.6. Facets
6.73.7. Look-and-Feel Customization
6.73.8. Skin Parameters Redefinition
6.73.9. Definition of Custom Style Classes
6.73.10. Relevant Resources Links
+6.74. < rich:panelBar >
6.74.1. Description
6.74.2. Key Features
6.74.3. Creating the Component with a Page Tag
6.74.4. Creating the Component Dynamically Using Java
6.74.5. Details of Usage
6.74.6. Look-and-Feel Customization
6.74.7. Skin Parameters Redefinition
6.74.8. Definition of Custom Style Classes
6.74.9. Relevant Resources Links
+6.75. < rich:panelBarItem >
6.75.1. Description
6.75.2. Key Features
6.75.3. Creating the Component with a Page Tag
6.75.4. Creating the Component Dynamically Using Java
6.75.5. Details of Usage
6.75.6. Facets
6.75.7. Look-and-Feel Customization
6.75.8. Skin Parameters Redefinition
6.75.9. Definition of Custom Style Classes
+6.76. < rich:panelMenu >
6.76.1. Description
6.76.2. Key Features
6.76.3. Creating the Component with a Page Tag
6.76.4. Creating the Component Dynamically Using Java
6.76.5. Details of Usage
6.76.6. JavaScript API
6.76.7. Look-and-Feel Customization
6.76.8. Definition of Custom Style Classes
6.76.9. Relevant Resources Links
+6.77. < rich:panelMenuGroup >
6.77.1. Description
6.77.2. Key Features
6.77.3. Creating the Component with a Page Tag
6.77.4. Creating the Component Dynamically Using Java
6.77.5. Details of Usage
6.77.6. JavaScript API
6.77.7. Look-and-Feel Customization
6.77.8. Skin Parameters Redefinition
6.77.9. Definition of Custom Style Classes
6.77.10. Relevant resources links
+6.78. < rich:panelMenuItem >
6.78.1. Description
6.78.2. Key Features
6.78.3. Creating the Component with a Page Tag
6.78.4. Creating the Component Dynamically Using Java
6.78.5. Details of Usage
6.78.6. Look-and-Feel Customization
6.78.7. Skin Parameters Redefinition
6.78.8. Definition of Custom Style Classes
6.78.9. Relevant resources links
+6.79. < rich:pickList >
6.79.1. Description
6.79.2. Key Features
6.79.3. Creating the Component with a Page Tag
6.79.4. Creating the Component Dynamically Using Java
6.79.5. Details of Usage
6.79.6. Facets
6.79.7. Look-and-Feel Customization
6.79.8. Skin Parameters Redefinition
6.79.9. Definition of Custom Style Classes
6.79.10. Relevant Resources Links
+6.80. < rich:progressBar >
6.80.1. Description
6.80.2. Key Features
6.80.3. Creating the Component with a Page Tag
6.80.4. Creating the Component Dynamically Using Java
6.80.5. Details of Usage
6.80.6. JavaScript API
6.80.7. Facets
6.80.8. Look-and-Feel Customization
6.80.9. Skin Parameters Redefinition
6.80.10. Definition of Custom Style Classes
6.80.11. Relevant Resources Links
+6.81. < rich:scrollableDataTable >
6.81.1. Description
6.81.2. Key Features
+6.82. < rich:separator >
6.82.1. Description
6.82.2. Key Features
6.82.3. Creating the Component with a Page Tag
6.82.4. Creating the Component Dynamically Using Java
6.82.5. Details of Usage
6.82.6. Look-and-Feel Customization
6.82.7. Definition of Custom Style Classes
6.82.8. Relevant Resources Links
+6.83. < rich:simpleTogglePanel >
6.83.1. Description
6.83.2. Key Features
6.83.3. Creating the Component with a Page Tag
6.83.4. Creating the Component Dynamically Using Java
6.83.5. Details of Usage
6.83.6. Facets
6.83.7. Look-and-Feel Customization
6.83.8. Skin Parameters Redefinition
6.83.9. Definition of Custom Style Classes
6.83.10. Relevant Resources Links
+6.84. < rich:spacer >
6.84.1. Description
6.84.2. Key Features
6.84.3. Creating the Component with a Page Tag
6.84.4. Creating the Component Dynamically Using Java
6.84.5. Details of Usage
6.84.6. Look-and-Feel Customization
6.84.7. Relevant Resources Links
+6.85. < rich:suggestionbox >
6.85.1. Description
6.85.2. Key Features
6.85.3. Creating the Component with a Page Tag
6.85.4. Creating the Component Dynamically Using Java
6.85.5. Details of Usage
6.85.6. JavaScript API
6.85.7. Facets
6.85.8. Look-and-Feel Customization
6.85.9. Skin Parameters Redefinition
6.85.10. Definition of Custom Style Classes
6.85.11. Relevant Resources Links
+6.86. < rich:tabPanel >
6.86.1. Description
6.86.2. Key Features
6.86.3. Creating the Component with a Page Tag
6.86.4. Creating the Component Dynamically Using Java
6.86.5. Details of Usage
6.86.6. Look-and-Feel Customization
6.86.7. Skin Parameters Redefinition
6.86.8. Definition of Custom Style Classes
6.86.9. Relevant Resources Links
+6.87. < rich:tab >
6.87.1. Description
6.87.2. Key Features
6.87.3. Creating the Component with a Page Tag
6.87.4. Creating the Component Dynamically Using Java
6.87.5. Details of Usage
6.87.6. Facets
6.87.7. Look-and-Feel Customization
6.87.8. Skin Parameters Redefinition
6.87.9. Definition of Custom Style Classes
+6.88. < rich:togglePanel >
6.88.1. Description
6.88.2. Key Features
6.88.3. Creating the Component with a Page Tag
6.88.4. Creating the Component Dynamically Using Java
6.88.5. Details of Usage
6.88.6. Look-and-Feel Customization
6.88.7. Definition of Custom Style Classes
6.88.8. Relevant Resources Links
+6.89. < rich:toggleControl >
6.89.1. Description
6.89.2. Key Features
6.89.3. Creating the Component with a Page Tag
6.89.4. Creating the Component Dynamically Using Java
6.89.5. Details of Usage
6.89.6. Look-and-Feel Customization
6.89.7. Definition of Custom Style Classes
+6.90. < rich:toolBar >
6.90.1. Description
6.90.2. Key Features
6.90.3. Creating the Component with a Page Tag
6.90.4. Creating the Component Dynamically Using Java
6.90.5. Details of Usage
6.90.6. Facets
6.90.7. Look-and-Feel Customization
6.90.8. Skin Parameters Redefinition
6.90.9. Definition of Custom Style Classes
6.90.10. Relevant Resources Links
+6.91. < rich:toolBarGroup >
6.91.1. Description
6.91.2. Key Features
6.91.3.
6.91.4. Creating the Component with a Page Tag
6.91.5. Creating the Component Dynamically Using Java
6.91.6. Details of Usage
6.91.7. Look-and-Feel Customization
6.91.8. Definition of Custom Style Classes
6.91.9. Relevant resources links
+6.92. < rich:toolTip >
6.92.1. Description
6.92.2. Key Features
6.92.3. Creating the Component with a Page Tag
6.92.4. Creating the Component Dynamically Using Java
6.92.5. Details of Usage
6.92.6. JavaScript API
6.92.7. Facets
6.92.8. Look-and-Feel Customization
6.92.9. Skin Parameters Redefinition
6.92.10. Definition of Custom Style Classes
6.92.11. Relevant Resources Links
+6.93. < rich:tree >
6.93.1. Description
6.93.2. Key Features
6.93.3. Creating the Component with a Page Tag
6.93.4. Creating the Component Dynamically Using Java
6.93.5. Details of Usage
6.93.6. Built-In Drag and Drop
6.93.7. Events handling
6.93.8. Facets
6.93.9. Look-and-Feel Customization
6.93.10. Skin Parameters Redefinition:
6.93.11. Definition of Custom Style Classes
6.93.12. Relevant Resources Links
+6.94. < rich:treeNode >
6.94.1. Description
6.94.2. Key Features
6.94.3. Creating the Component with a Page Tag
6.94.4. Creating the Component Dynamically Using Java
6.94.5. Details of Usage
6.94.6. Built-in Drag and Drop
6.94.7. Events Handling
6.94.8. Facets
6.94.9. Look-and-Feel Customization
6.94.10. Skin Parameters Redefinition
6.94.11. Definition of Custom Style Classes
6.94.12. Relevant Resources Links
+6.95. < rich:changeExpandListener >
6.95.1. Description
6.95.2. Key Features
6.95.3. Creating the Component with a Page Tag
6.95.4. Creating the Component Dynamically Using Java
6.95.5. Details of Usage
6.95.6. Look-and-Feel Customization
+6.96. < rich:nodeSelectListener >
6.96.1. Description
6.96.2. Key Features
6.96.3. Creating the Component with a Page Tag
6.96.4. Creating the Component Dynamically Using Java
6.96.5. Details of Usage
6.96.6. Look-and-Feel Customization
+6.97. < rich:recursiveTreeNodesAdaptor >
6.97.1. Description
6.97.2. Key Features
6.97.3. Creating the Component with a Page Tag
6.97.4. Creating the Component Dynamically Using Java
6.97.5. Details of Usage
6.97.6. Relevant resources links
+6.98. < rich:treeNodesAdaptor >
6.98.1. Description
6.98.2. Key Features
6.98.3. Creating the Component with a Page Tag
6.98.4. Creating the Component Dynamically Using Java
6.98.5. Details of Usage
6.98.6. Relevant Resources Links
7. IDE Support
8. Links to information resources

RichFaces is an open source framework that adds Ajax capability into existing JSF applications without resorting to JavaScript.

RichFaces leverages JavaServer Faces framework including lifecycle, validation, conversion facilities and management of static and dynamic resources. RichFaces components with built-in Ajax support and a highly customizable look-and-feel can be easily incorporated into JSF applications.

RichFaces allows to:

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.

RichFaces was developed with an open architecture to be compatible with the widest possible variety of environments.

This is what you need to start working with RichFaces 3.3.0:

  • Java

  • JavaServer Faces

  • Java application server or servlet container

  • Browser (on client side)

  • RichFaces framework

This chapter describes all necessary actions and configurations that should be done for plugging the RichFaces components into a JSF appplication. The description relies on a simple JSF with RichFaces application creation process from downloading the libraries to running the application in a browser. The process of application creation described here is common and does not depend on used IDE.

The latest release of RichFaces components is available for download at JBoss RichFaces Downloads area at JBoss community. Binary files (uploaded there in *.bin.zip or *.bin.tar.gz archives) contains compiled, ready-to-use version of RichFaces with set of basic skins.

To start with RichFaces in computer file system create new folder with name "RichFaces", download and unzip the archive with binaries there.

For those who want to download and compile the RichFaces by themselfs there is an article at JBoss community that describes the RichFaces repository's structure overview and some aspects of working with it.

"RichFaces Greeter"—the simple application—is hello-world like application but with one difference: the world of RichFaces will say "Hello!" to user first.

Create standard JSF 1.2 project with all necessary libraries; name the project "Greeter" and follow the decription.

After RichFaces libraries where added into the project it is necessary to register them in project web.xml file. Add following lines in web.xml:


...
<!-- Plugging the "Blue Sky" skin into the project -->
<context-param>
   <param-name>org.richfaces.SKIN</param-name>
   <param-value>blueSky</param-value>
</context-param>

<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
      <param-name>org.richfaces.CONTROL_SKINNING</param-name>
      <param-value>enable</param-value>
</context-param>
 
<!-- Defining and mapping the RichFaces filter -->
<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>
...

For more information on how to work with RichFaces skins read "Skinnabilty" chapter.

Finally the web.xml should look like this:


<?xml version="1.0"?>
<web-app version="2.5" 
                xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Greeter</display-name>
  
<context-param>
   <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
   <param-value>server</param-value>
</context-param>
  
<context-param>
   <param-name>org.richfaces.SKIN</param-name>
   <param-value>blueSky</param-value>
</context-param>

<context-param>
      <param-name>org.richfaces.CONTROL_SKINNING</param-name>
      <param-value>enable</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>
</listener>
  
<!-- Faces Servlet -->
<servlet>
   <servlet-name>Faces Servlet</servlet-name>
   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>
 
<!-- Faces Servlet Mapping -->
<servlet-mapping>
   <servlet-name>Faces Servlet</servlet-name>
   <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
  
<login-config>
   <auth-method>BASIC</auth-method>
   </login-config>
</web-app>

The "RichFaces Greeter" application has only one JSP page. Create index.jsp page in root of WEB CONTENT folder and add there following code:


<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
 
<html>
      <head>
            <title>RichFaces Greeter</title>
      </head>
      <body>
            <f:view>
                  <a4j:form>
                        <rich:panel header="RichFaces Greeter" style="width: 315px">
                              <h:outputText value="Your name: " />
                              <h:inputText value="#{user.name}" >
                                    <f:validateLength minimum="1" maximum="30" />
                              </h:inputText>
                              
                              <a4j:commandButton value="Get greeting" reRender="greeting" />
                              
                              <h:panelGroup id="greeting" >
                                    <h:outputText value="Hello, " rendered="#{not empty user.name}" />
                                    <h:outputText value="#{user.name}" />
                                    <h:outputText value="!" rendered="#{not empty user.name}" />
                              </h:panelGroup>
                        </rich:panel>
                  </a4j:form>
            </f:view>
      </body>
</html>

The application uses three RichFaces components: <rich:panel> is used as visual container for information; <a4j:commandButton> with built-in Ajax support allows rendering a greeting dynamically after a response comes back and <a4j:form> helps the button to perform the action.

Note, that the RichFaces tag library should be declared on each JSP page. For XHTML pages add following lines for tag library declaration:


<xmlns:a4j="http://richfaces.org/a4j">
<xmlns:rich="http://richfaces.org/rich">

That’s it. Run the application on server. Point your browser to index.jsp page in browser: http://localhost:8080/Greeter/index.jsf


JBoss Developer Studio comes with a tight integration with RichFaces component framework. Following links might be useful for those who already use this IDE and RichFaces for developing applications and those who wish to improve their development process:

  • "Rich Components" chapter in "Getting Started with JBoss Developer Studio Guide" describes how to add RichFaces components into a CRUD application;

  • "JBoss Tools Palette" chapter in "Visual Web Tools Reference Guide" describes advantages that gives Tools Pallete (comes together with JBDS) for quick and easy pages creation processs including RichFaces applications;

  • "RichFaces Toolkit for developing Web application" video tutorial demonstrates some aspects of interaction with JBoss Developer Studio while working with RichFaces.

Read also the quick overview to "Practical RichFaces " book by Max Katz at his blog.

RichFaces comes with support for all tags (components) included in the JavaServer Faces specification. To add RichFaces capabilities to the existing JSF project you should just put the RichFaces libraries into the lib folder of the project and add filter mapping. The behavior of the existing project doesn't change just because of RichFaces.

RichFaces doesn't require any parameters to be defined in your web.xml. But the RichFaces parameters listed below may help with development and may increase the flexibility of RichFaces usage.

Table 4.1. Initialization Parameters

NameDefaultDescription
org.richfaces.SKINDEFAULTIs a name of a skin used in an application. It can be a literal string with a skin name, or the EL expression (#{...}) pointed to a String property (skin name) or a property of a org.richfaces.framework.skin type. Skin in last case, this instance is used as a current skin
org.richfaces.LoadScriptStrategyDEFAULTDefines how the RichFaces script files are loaded to application. Possible values are: ALL, DEFAULT, NONE. For more information see "Scripts and Styles Load Strategy".
org.richfaces.LoadStyleStrategyDEFAULTDefines how the RichFaces style files are loaded to application. Possible values are: ALL, DEFAULT, NONE. For more information see "Scripts and Styles Load Strategy".
org.ajax4jsf.LOGFILEnoneIs an URL to an application or a container log file (if possible). If this parameter is set, content from the given URL is shown on a Debug error page in the iframe window
org.ajax4jsf.VIEW_HANDLERSnoneIs a comma-separated list of custom ViewHandler instances for inserting in chain. Handlers are inserted BEFORE RichFaces viewhandlers in the given order. For example, in facelets application this parameter must contain com.sun.facelets.FaceletViewHandler, instead of declaration in faces-config.xml
org.ajax4jsf.CONTROL_COMPONENTSnoneIs a comma-separated list of names for a component as a special control case, such as messages bundle loader, alias bean components, etc. Is a type of component got by a reflection from the static field COMPONENT_TYPE . For components with such types encode methods always are called in rendering Ajax responses, even if a component isn't in an updated part
org.ajax4jsf.ENCRYPT_RESOURCE_DATAfalseFor generated resources, such as encrypt generation data, it's encoded in the resource URL. For example, URL for an image generated from the mediaOutput component contains a name of a generation method, since for a hacker attack, it is possible to create a request for any JSF baked beans or other attributes. To prevent such attacks, set this parameter to "true" in critical applications (works with JRE > 1.4 )
org.ajax4jsf.ENCRYPT_PASSWORDrandomIs a password for encryption of resources data. If isn't set, a random password is used
org.ajax4jsf.COMPRESS_SCRIPTtrueIt doesn't allow framework to reformat JavaScript files (makes it impossible to debug)
org.ajax4jsf.RESOURCE_URI_PREFIXa4j Defines prefix which is added to all URIs of generated resources. This prefix designed to handle RichFaces generated resources requests
org.ajax4jsf.GLOBAL_RESOURCE_URI_PREFIXa4j/g Defines prefix which is added to URIs of global resources. This prefix designed to handle RichFaces generated resources requests
org.ajax4jsf.SESSION_RESOURCE_URI_PREFIXa4j/s Defines prefix which is used for session tracking for generated resources. This prefix designed to handle RichFaces generated resources requests
org.ajax4jsf.DEFAULT_EXPIRE86400 Defines in seconds how long streamed back to browser resources can be cached
org.ajax4jsf.SERIALIZE_SERVER_STATEfalse If enabled the component state (not the tree) will be serialized before being stored in the session. This may be desirable for applications that may have issues with view state being sensitive to model changes. Instead of this parameter can use com.sun.faces.serializeServerState and org.apache.myfaces.SERIALIZE_STATE_IN_SESSION parameters for corresponding environments.



RichFaces now works out-of-the-box with JBoss Seam and Facelets running inside JBoss AS 4.0.4 and higher. There is no more shared JAR files needed. You just have to package the RichFaces library with your application.

Your web.xml for Seam 1.2 must be like this:


<?xml version="1.0" ?>
<web-app 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"
                   version="2.4">

     <!-- richfaces -->

     <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>

     <!-- Seam -->

     <listener>
          <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
     </listener>

     <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>

     <!-- MyFaces -->

     <listener>
          <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
     </listener>

     <!-- JSF -->

     <context-param>
          <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
          <param-value>client</param-value>
     </context-param>

     <context-param>
          <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
         <param-value>.xhtml</param-value>
     </context-param>

     <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
     </servlet>

     <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.seam</url-pattern>
     </servlet-mapping>
</web-app>

Seam 2 supports RichFaces Filter. Thus your web.xml for Seam 2 must be like this:


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
                   xmlns="http://java.sun.com/xml/ns/javaee"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

     <context-param>
          <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
          <param-value>com.sun.facelets.FaceletViewHandler</param-value>
     </context-param>

     <!-- Seam -->

     <listener>
          <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
     </listener>

     <servlet>
          <servlet-name>Seam Resource Servlet</servlet-name>
          <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</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.servlet.SeamFilter</filter-class>
     </filter>

     <filter-mapping>
          <filter-name>Seam Filter</filter-name>
          <url-pattern>/*</url-pattern>
     </filter-mapping>

     <!-- JSF -->

     <context-param>
          <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
          <param-value>.xhtml</param-value>
     </context-param>

     <context-param>
          <param-name>facelets.DEVELOPMENT</param-name>
          <param-value>true</param-value>
     </context-param>

     <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
     </servlet>

     <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.seam</url-pattern>
     </servlet-mapping>
</web-app>

Only one issue still persists while using Seam with MyFaces. Look at myFaces part of this section.

Detailed information on how to integrate Richfaces and Trinidad and how to hide ".seam" postfix in the URL you can find here

5.1. Introduction
5.2. RichFaces Architecture Overview
5.3. RichFaces Integral Parts
5.4. Limitations and Rules
+5.5. Ajax Request Optimization
5.5.1. Re-Rendering
5.5.2. Queue and Traffic Flood Protection
+5.5.3. Queue Principles
5.5.3.1. Global default queue, defined in the web.xml file
5.5.3.2. View scoped default queue
5.5.3.3. View scoped named queue
5.5.3.4. Form based default queue
+5.5.3.5. Queue functionality
5.5.3.5.1. Events Similarity
5.5.3.5.2. Similar requests during request delay
5.5.3.5.3. JavaScript API
5.5.4. Data Processing Options
5.5.5. Action and Navigation
5.5.6. JavaScript Interactions
5.5.7. Iteration components Ajax attributes
5.5.8. Other useful attributes
+5.6. How To...
5.6.1. Send an Ajax request
5.6.2. Decide What to Send
5.6.3. Decide What to Change
5.6.4. Decide what to process
5.7. Filter Configuration
5.8. Scripts and Styles Load Strategy
+5.9. Request Errors and Session Expiration Handling
5.9.1. Request Errors Handling
5.9.2. Session Expired Handling
+5.10. Skinnability
5.10.1. Why Skinnability
5.10.2. Using Skinnability
5.10.3. Example
5.10.4. Skin Parameters Tables in RichFaces
5.10.5. Creating and Using Your Own Skin File
5.10.6. Built-in Skinnability in RichFaces
5.10.7. Changing skin in runtime
+5.10.8. Standard Controls Skinning
5.10.8.1. Standard level
5.10.8.2. Extended level
5.10.9. Client-side Script for Extended Skinning Support
5.10.10. XCSS File Format
+5.10.11. Plug-n-Skin
5.10.11.1. Details of Usage
5.11. State Manager API
5.12. Identifing User Roles

Next figure lists several important elements of the RichFaces framework


Ajax Filter.

To get all benefits of RichFaces , you should register a Filter in web.xml file of your application. The Filter recognizes multiple request types. Necessary information about Filter configuration can be found in the "Filter configuration" section. The sequence diagram on Figure 3 shows the difference in processing of a "regular" JSF request and an Ajax request.

In the first case the whole JSF tree will be encoded, in the second one option it depends on the "size" of the Ajax region. As you can see, in the second case the filter parses the content of an Ajax response before sending it to the client side.

Have a look at the next picture to understand these two ways:


In both cases, the information about required static or dynamic resources that your application requests is registered in the ResourseBuilder class.

When a request for a resource comes (Figure 4), the RichFaces filter checks the Resource Cache for this resource and if it is there, the resource is sent to the client. Otherwise, the filter searches for the resource among those that are registered by the ResourceBuilder. If the resource is registered, the RichFaces filter will send a request to the ResourceBuilder to create (deliver) the resource.

Next Figure shows the ways of resource request processing.


AJAX Action Components

There are Ajax Action Components: <a4j:commandButton> , <a4j:commandLink> , <a4j:poll> and <a4j:support> and etc. You can use them to send Ajax requests from the client side.

AJAX Containers

AjaxContainer is an interface that describes an area on your JSF page that should be decoded during an Ajax request. AjaxViewRoot and AjaxRegion are implementations of this interface.

JavaScript Engine

RichFaces JavaScript Engine runs on the client-side. It knows how to update different areas on your JSF page based on the information from the Ajax response. Do not use this JavaScript code directly, as it is available automatically.

The RichFaces comes with a number of integral parts (framework, libraries):

For more information about framework and libraries loading see the following section in the FAQ.

Note:

In order to prevent JavaScript versions conflict you should use only one version of the framework or library. You could find more information about libraries exclusion in the FAQ.

Ajax attributes are common for Ajax components such as <a4j:support> , <a4j:commandButton> , <a4j:jsFunction> , <a4j:poll> , <a4j:push> and so on. Also, most RichFaces components with built-in Ajax support have these attributes for a similar purpose. Ajax components attributes help RichFaces to expose its features. Most of the attributes have default values. Thus, you can start working with RichFaces without knowing the usage of these attribute. However, their usage allows to tune the required Ajax behavior very smoothly.

"reRender" is a key attribute. The attribute allows to point to area(s) on a page that should be updated as a response on Ajax interaction. The value of the "reRender" attribute is an id of the JSF component or an id list.

A simple example is placed below:


...
<a4j:commandButton value="update" reRender="infoBlock"/>
...
<h:panelGrid id="infoBlock">
    ...
</h:panelGrid>
...

The value of "reRender" attribute of the <a4j:commandButton> tag defines which part(s) of your page is (are) to be updated. In this case, the only part of the page to update is the <h:panelGrid> 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" .

"reRender" uses UIComponent.findComponent() algorithm (with some additional exceptions) to find the component in the component tree. As can you see, the algorithm presumes several steps. Each other step is used if the previous step is not successful. Therefore, you can define how fast the component is found mentioning it more precisely. The following example shows the difference in approaches (both buttons will work successfully):


...
<h:form id="form1">
    ...
    <a4j: commandButton value="Usual Way" reRender="infoBlock, infoBlock2" />
    <a4j:commandButton value="Shortcut" reRender=":infoBlockl,:sv:infoBlock2" />
    ...
</h:form>
<h:panelGrid id="infoBlock">
    ...
</h:panelGrid>
...
<f:subview id="sv">
    <h:panelGrid id="infoBlock2">
        ...
    </h:panelGrid>
    ...
</f:subview>
...

It's also possible to use JSF EL expression as a value of the reRender attribute. It might be a property of types Set, Collection, Array or simple String. The EL for reRender is resolved right before the Render Response phase. Hence, you can calculate what should be re-rendered on any previous phase during the Ajax request processing.

Most common problem with using reRender is pointing it to the component that has a "rendered" attribute. Note, that JSF does not mark the place in the browser DOM where the outcome of the component should be placed in case the "rendered" condition returns false. Therefore, after the component becomes rendered during the Ajax request, RichFaces delivers the rendered code to the client, but does not update a page, because the place for update is unknown. You need to point to one of the parent components that has no "rendered" attribute. As an alternative, you can wrap the component with <a4j:outputPanel> layout="none" .

"ajaxRendered" attribute of the <a4j:outputPanel> set to "true" allows to define the area of the page that will be re-rendered even if it is not pointed in the reRender attribute explicitly. It might be useful if you have an area on a page that should be updated as a response on any Ajax request. For example, the following code allows to output error messages regardless of what Ajax request causes the Validation phase failed.


...
<a4j:outputPanel ajaxRendered="true">
    <h:messages />
</a4j:outputPanel>
...

"limitToList" attribute allows to dismiss the behavior of the <a4j:outputPanel> "ajaxRendered" attribute. limitToList = "false" means to update only the area(s) that mentioned in the "reRender" attribute explicitly. All output panels with ajaxRendered="true" is ignored. An example is placed below:


...
<h:form>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" limitToList="true"/>
    </h:inputText>
    <h:outputText value="#{person.name}" id="test"/>
</form>
...

"eventsQueue" attribute defines the name of the queue that will be used to order upcoming Ajax requests. By default, RichFaces does not queue Ajax requests. If events are produced simultaneously, they will come to the server simultaneously. JSF implementations (especially, the very first ones) does not guaranty that the request that comes first will be served or passed into the JSF lifecycle first. The order how the server side data will be modified in case of simultaneous request might be unpredictable. Usage of eventsQueue attribute allows to avoid possible mess. Define the queue name explicitly, if you expect intensive Ajax traffic in your application.

The next request posted in the same queue will wait until the previos one is not processed and Ajax Response is returned back if the "eventsQueue" attribute is defined. In addition, RichFaces starts to remove from the queue "similar" requests. "Similar'"requests are the requests produced by the same event. For example, according to the following code, only the newest request will be sent to the server if you type very fast and has typed the several characters already before the previous Ajax Response is back.


...
<h:inputText value="#{userBean.name}">
    <a4j:support event="onkeyup" eventsQueue="foo" reRender="bar" />
</h:inputText>
...

"requestDelay" attribute defines the time (in ms) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest "similar" request is in a queue already .

"ignoreDupResponses" attribute orders to ignore the Ajax Response produced by the request if the newest "similar" request is in a queue already. ignoreDupResponses"="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response loses the actuality.

Defining the "eventsQueue" along with "requestDelay" allows to protect against unnecessary traffic flood and synchronizes Ajax requests order. If you have several sources of Ajax requests, you can define the same queue name there. This might be very helpful if you have Ajax components that invoke request asynchronously from the ones produced by events from users. For example, <a4j:poll> or <a4j:push> . In case the requests from such components modify the same data, the synchronization might be very helpful.

More information can be found on the RichFaces Users Forum .

"timeout" attribute is used for setting response waiting time on a particular request. If a response is not received during this time, the request is aborted.

Starting from 3.3.0 version RichFaces has an improved queue.

There are some reasons why the queue has been improved. In previous versions the queue had quite simple implementation: it sent to the server only the last Ajax request out of all requests coming in the queue during request delay.

The improved queue allows to

There are 4 types of the queue:

In this section we will take a closer look at the listed above types of the queue and see in more detail how they differ. Usage details are covered in the <a4j:queue> chapter.

Design details

The view scoped default, named and formed-based types of queue utilize the <a4j:queue> tag to override the settings of the global queue defined in the web.xml file.

You can also programmatically enable/disable the global queue on a single view using the following:


...
<a4j:queue name="org.richfaces.global_queue" disabled="true"... />
...

Hence, to enable the queue for a single view page you need to define the "disable" attribute with "false".

Now, you can override the default settings using the attributes of the <a4j:queue> component. The full list of attributes is given in the "6.20. <a4j:queue>" chapter of the guide.

Example:


...
<a4j:queue name="org.richfaces.global_queue" requestDelay="1000" />
...

View scoped queue can be also added by just definition of the queue without name specified. In this case it should be placed anywhere outside the forms in order not to be recognized as a form-based queue.


...
<a4j:queue ... />
...

This section will cover some queue's functionality aspects.

RichFaces uses form based approach for Ajax request sending. This means each time, when you click an Ajax button or <a4j:poll> produces an asynchronous request, the data from the closest JSF form is submitted with the XMLHTTPRequest object. The form data contains the values from the form input element and auxiliary information such as state saving data.

When "ajaxSingle" attribute value is "true" , it orders to include only a value of the current component (along with <f:param> or <a4j:actionparam> values if any) to the request map. In case of <a4j:support> , it is a value of the parent component. An example is placed below:


...
<h:form>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" ajaxSingle="true"/>
    </h:inputText>
    <h:inputText value="#{person.middleName}"/>
</form>
...

In this example the request contains only the input component causes the request generation, not all the components contained on a form, because of ajaxSingle="true" usage.

Note, that ajaxSingle="true" reduces the upcoming traffic, but does not prevent decoding other input components on the server side. Some JSF components, such as <h:selectOneMenu> do recognize the missing data in the request map value as a null value and try to pass the validation process with a failed result. Thus, use <a4j:region> to limit a part of the component tree that will be processed on the server side when it is required.

"immediate" attribute has the same purpose as any other non-JSF component. The default "ActionListener" should be executed immediately (i.e. during the Apply Request Values phase of a request processing lifecycle), rather than waiting until the Invoke Application phase. Using immediate="true" is one of the ways to have some data model values updated when other cannot be updated because of a problem with passing the Validation phase successfully. This might be important inside the <h:dataTable> like components where using <a4j:region> is impossible due to the <h:dataTable> component architecture.

"bypassUpdates" attribute allows to bypass the Update Model phase. It might be useful if you need to check your input against the available validator, but not to update the model with those data. Note, that an action will be invoked at the end of the Validation phase only if the Validation phase is passed successfully. The listeners of the Application phase will not be invoked in any case.

Ajax component is similar to any other non-Ajax JSF component like <h:commandButton> . It allows to submit the form. You can use "action" and "actionListener" attributes to invoke the action method and define the action event.

"action" method must return null if you want to have an Ajax Response with a partual page update. This is regular mode called "Ajax request generates Non-Ajax Response". In case of action does not return null, but the action outcome that matches one of navigation rules, RichFaces starts to work in "Ajax request generates Non-Ajax Response" mode. This mode might be helpful in two major cases:

RichFaces allows writing Ajax-enabled JSF application without writing any Javascript code. However, you can still invoke the JavaScript code if you need. There are several ajax attributes that helps to do it.

"onsubmit" attribute allows to invoke JavaScript code before an Ajax request is sent. If "onsubmit" returns "false" , the Ajax request is canceled. The code of "onsubmit" is inserted before the RichFaces Ajax call. Hence, the "onsubmit" should not has a "return" statement if you want the Ajax request to be sent. If you are going to invoke a JavaScript function that returns "true" or "false" , use the conditional statement to return something only when you need to cancel the request. For example:


...
onsubmit="if (mynosendfunct()==false){return false}"
...

"onclick" attribute is similar to the "onsubmit" , but for clickable components such as <a4j:commandLink> and <a4j:commandButton> . If it returns "false" , the Ajax request is canceled also.

The "oncomplete" attribute is used for passing JavaScript that would be invoked right after the AJAX response returns back and DOM is updated. It is not recommended to use use keyword this inside the EL-expression, because it will not always point to the component where AJAX request was initiated.

"onbeforedomupdate" attribute defines JavaScript code for call after Ajax response receiving and before updating DOM on a client side.

"data" attribute allows to get the additional data from the server during an Ajax call. You can use JSF EL to point the property of the managed bean and its value will be serialized in JSON format and be available on the client side. You can refer to it using the "data" variable. For example:


...
<a4j:commandButton value="Update" data="#{userBean.name}" oncomplete="showTheName(data.name)" />
...

RichFaces allows to serialize not only primitive types into JSON format, but also complex types including arrays and collections. The beans should be serializable to be refered with "data" .

There is a number of useful functions which can be used in JavaScript:

"status" attribute for Ajax components (such as <a4j:commandButton> , <a4j:poll> , etc.) points to an ID of <a4j:status> component. Use this attribute if you want to share <a4j:status> component between different Ajax components from different regions. The following example shows it.


...
<a4j:region id="extr">
    <h:form>
        <h:outputText value="Status:" />
        <a4j:status id="commonstatus" startText="In Progress...." stopText=""/>
        <h:panelGrid columns="2">
            <h:outputText value="Name"/>
            <h:inputText id="name" value="#{userBean.name}">
                <a4j:support event="onkeyup" reRender="out" />
            </h:inputText>
            <h:outputText value="Job"/>
            <a4j:region  id="intr">
                <h:inputText id="job" value="#{userBean.job}">
                    <a4j:support event="onkeyup"  reRender="out" status="commonstatus"/>
                </h:inputText>
            </a4j:region>
        </h:panelGrid>
        <a4j:region>
            <h:outputText id="out" value="Name: #{userBean.name}, Job: #{userBean.job}" />
            <br />
            <a4j:commandButton ajaxSingle="true" value="Clean Up Form" reRender="name, job, out"  status="commonstatus">
                <a4j:actionparam name="n" value=""  assignTo="#{userBean.name}" />
                <a4j:actionparam name="j" value=""  assignTo="#{userBean.job}" />
            </a4j:commandButton>
        </a4j:region>
    </h:form>
</a4j:region>
...

In the example <a4j:support> and <a4j:commandButton> are defined in different regions. Values of "status" attribute for these components points to an ID of <a4j:support> .Thus, the <a4j:support> component is shared between two components from different regions.

More information could be found here .

Other useful attribute is "focus" . It points to an ID of a component where focus will be set after an Ajax request.

RichFaces uses a filter for a correction of code received on an Ajax request. In case of a "regular" JSF request a browser makes correction independently. In case of Ajax request in order to prevent layout destruction it's needed to use a filter, because a received code could differ from a code validated by a browser and a browser doesn't make any corrections.

An example of how to set a Filter in a web.xml file of your application is placed below.

Example:


...
<filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
...

From RichFaces 3.2 filter configuration becomes more flexible. It's possible to configure different filters for different sets of pages for the same application.

The possible filter types are:

  • TIDY

"TIDY" filter type based on the Tidy parser. This filter is recommended for applications with complicated or non-standard markup when all necessary code corrections are made by the filter when a response comes from the server.

"NEKO" filter type corresponds to the former "Fast Filter" and it's based on the Neko parser. In case of using this filter code isn't strictly verified. Use this one if you are sure that your application markup is really strict for this filter. Otherwise it could cause lot's of errors and corrupt a layout as a result. This filter considerably accelerates all Ajax requests processing.

No correction.

An example of configuration is placed below.

Example:


...
<context-param>
    <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
    <param-value>NONE,NEKO,TIDY</param-value>
</context-param>
<context-param>
    <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
    <param-value>/pages/performance\.xhtml,/pages/default.*\.xhtml</param-value>
</context-param>
<context-param>
    <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
    <param-value>/pages/repeat\.xhtml</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>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>
...

The example shows that ORDER parameter defines the order in which particular filter types are used for pages code correction.

First of all "NONE" type is specified for the filter. Then two different sets of pages are defined for which two filter types (NONE and NEKO) are used correspondingly. If a page relates to the first set that is defined in the following way:


<param-value>/pages/performance\.xhtml,/pages/default.*\.xhtml</param-value>

it's not corrected, because filter type for this page is defined as "NONE". If a page is not from the first set, then "NEKO" type is set.

If a page relates to the second set that is defined in the following way:


<param-value>/pages/repeat\.xhtml</param-value>

then "NEKO" filter type is used for correction. If it's not related to the second set, "TIDY" type is set for the filter ("TIDY" filter type is used for code correction).

Before the version 3.1.3, RichFaces loaded styles and script on demand. I.e. files are loaded only if they are required on a particular page. Since RichFaces 3.1.3, it's possible to manage how the RichFaces script and style files are loaded to application.

org.richfaces.LoadScriptStrategy

The following declaration in your web.xml allows loading the integrated script files.


...
<context-param>
    <param-name>org.richfaces.LoadScriptStrategy</param-name>
    <param-value>ALL</param-value>
</context-param>
...

If you do not declare the org.richfaces.LoadScriptStrategy in the web.xml, it equals to:


...
<context-param>
    <param-name>org.richfaces.LoadScriptStrategy</param-name>
    <param-value>DEFAULT</param-value>
</context-param>
...

The third possible value is "NONE". You have no a special reason to use it unless you obtain the newest (or modified) version of the script and want to include it manually in a page header.

org.richfaces.LoadStyleStrategy

The following declaration allows to load only one integrated style sheet file.


...
<context-param>
    <param-name>org.richfaces.LoadStyleStrategy</param-name>
    <param-value>ALL</param-value>
</context-param>
...

The integrated style sheet contains style for all shipped components. The skinnability feature still works.

The "DEFAULT" value is a classical on-demand variant.

The "NONE" stops loading the styles at all. The earlier introduced plain skin resets all color and font parameters to null. The "NONE" value for org.richfaces.LoadStyleStrategy means that predefined styles for RichFaces are not used.

For more information see RichFaces User Forum .

RichFaces allows to redefine standard handlers responsible for processing of different exceptional situations. It helps to define own JavaScript, which is executed when these situations occur.

Add the following code to web.xml:


<context-param>
    <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
    <param-value>true</param-value>
</context-param>
        

If you have a look at a CSS file in an enterprise application, for example, the one you're working on now, you'll see how often the same color is noted in it. Standard CSS has no way to define a particular color abstractly for defining as a panel header color, a background color of an active pop-up menu item, a separator color, etc. To define common interface styles, you have to copy the same values over and over again and the more interface elements you have the more copy-and-paste activity that needs to be performed.

Hence, if you want to change the application palette, you have to change all interrelating values, otherwise your interface can appear a bit clumsy. The chances of such an interface coming about is very high, as CSS editing usually becomes the duty of a general developer who doesn't necessarily have much knowledge of user interface design.

Moreover, if a customer wishes to have an interface look-and-feel that can be adjusted on-the-fly by an end user, your work is multiplied, as you have to deal with several CSS files variants, each of which contains the same values repeated numerous times.

These problems can be solved with the skinnability system built into the RichFaces project and realized fully in RichFaces. Every named skin has some skin-parameters for the definition of a palette and the other parameters of the user interface. By changing just a few parameters, you can alter the appearance of dozens of components in an application in a synchronized fashion without messing up user interface consistency.

The skinnability feature can't completely replace standard CSS and certainly doesn't eliminate its usage. Skinnability is a high-level extension of standard CSS, which can be used together with regular CSS declarations. You can also refer to skin parameters in CSS via JSF Expression Language. You have the complete ability to synchronize the appearance of all the elements in your pages.

RichFaces provides eight predefined skin parameters (skins) at the simplest level of common customization:

To plug one in, it's necessary to specify a skin name in the org.richfaces.SKIN context-param.

Here is an example of a table with values for one of the main skins, "blueSky" .



Skin "plain" was added from 3.0.2 version. It doesn't have any parameters. It's necessary for embedding RichFaces components into existing projecst which have its own styles.

To get detailed information on particular parameter possibilities, see the chapter where each component has skin parameters described corresponding to its elements.

In order to create your own skin file, do the following:

  • Create a file and define in it skin constants which are used by style classes (see section "Skin Parameters Tables in RichFaces" ). The name of skin file should correspond to the following format: <name>.skin.properties . As an example of such file you can see RichFaces predefined skin parameters (skins): blueSky, classic, deepMarine, etc. These files are located in the richfaces-impl-xxxxx.jar inside the /META-INF/skins folder.

  • Add a skin definition <contex-param> to the web.xml of your application. An example is placed below:

    Example:

    
    ...
    <context-param>
         <param-name>org.richfaces.SKIN</param-name>
         <param-value>name</param-value>
    </context-param>
    ...
  • Put your <name>.skin.properties file in one of the following classpath elements: META-INF/skins/ or classpath folder (e.g. WEB-INF/classes).

RichFaces gives an opportunity to incorporate skinnability into UI design. With this framework you can easily use named skin parameters in properties files to control the appearance of the skins that are applied consistently to a whole set of components. You can look at examples of predefined skins at:

http://livedemo.exadel.com/richfaces-demo/

You may simply control the look-and-feel of your application by using the skinnability service of the RichFaces framework. With the means of this service you can define the same style for rendering standard JSF components and custom JSF components built with the help of RichFaces.

To find out more on skinnability possibilities, follow these steps:

Extra information on custom renderers creation can be found at:

http://java.sun.com/javaee/javaserverfaces/reference/docs/index.html

It's possible to change skins in runtime. In order to do that, define the EL-expression in the web.xml. For example:


<context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>#{skinBean.skin}</param-value>
</context-param>
            

The skinBean code looks as follows:

public class SkinBean {


    private String skin;
    public String getSkin() {
        return skin;
    }
    public void setSkin(String skin) {
        this.skin = skin;
    }
}

Further, it is necessary to set the skin property to the initial value in the configuration file. For example, "classic":


<managed-bean>
    <managed-bean-name>skinBean</managed-bean-name>
    <managed-bean-class>SkinBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
        <property-name>skin</property-name>
        <value>classic</value>
    </managed-property>
</managed-bean>
            

You can also change the default skin, for instance, change the default color. To do this, edit the file properties of the skin. Here is an example of the code for page:


<h:form>
     <div style="display: block; float: left">
          <h:selectOneRadio value="#{skinBean.skin}" border="0" layout="pageDirection" title="Changing skin" style="font-size: 8; font-family: comic" onchange="submit()">
                <f:selectItem itemLabel="plain" itemValue="plain" />
        <f:selectItem itemLabel="emeraldTown" itemValue="emeraldTown" />
        <f:selectItem itemLabel="blueSky" itemValue="blueSky" />
        <f:selectItem itemLabel="wine" itemValue="wine" />
        <f:selectItem itemLabel="japanCherry" itemValue="japanCherry" />
        <f:selectItem itemLabel="ruby" itemValue="ruby" />
        <f:selectItem itemLabel="classic" itemValue="classic" />
        <f:selectItem itemLabel="laguna" itemValue="laguna" />
        <f:selectItem itemLabel="deepMarine" itemValue="deepMarine" />
        <f:selectItem itemLabel="blueSky Modified" itemValue="blueSkyModify" />
          </h:selectOneRadio>
     </div>
     <div style="display: block; float: left">
          <rich:panelBar height="100" width="200">
               <rich:panelBarItem label="Item 1" style="font-family: monospace; font-size: 12;">
         Changing skin in runtime
    </rich:panelBarItem>
    
    <rich:panelBarItem label="Item 2" style="font-family: monospace; font-size: 12;">
         This is a result of the modification "blueSky" skin
    </rich:panelBarItem>
          </rich:panelBar>
     </div>
</h:form>

This is result:


The feature is designed to unify the look and feel of standard HTML element and RichFaces components. Skinning can be applied to all controls on a page basing on elements' name and attribute type (where applicable). Also this feature provides a set of CSS styles so that skinning can be applied assigning rich-* classes to particular elements or to container of elements that nests controls.

Standard controls skinning feature provides 2 levels of skinning: Standard and Extended. The level is based on detecting the browser type. If browser type is not identified, Advanced level is used. However, if you want to explicitly specify the level of skinning you want to be applied, you need to add a context parameter to your web.xml with org.richfaces.CONTROL_SKINNING_LEVEL as the parameter name and value set to either basic or extended.

These are the elements that affected by skinning:

  • input

  • select

  • textarea

  • keygen

  • isindex

  • legend

  • fieldset

  • hr

  • a (together with a:hover, a:visited "pseudo"-elements)

Skinning for standard HTML controls can be initialized in two ways:

  • by adding org.richfaces.CONTROL_SKINNING parameter to web.xml. Values: "enable" and "disable". This way implies that skinning style properties are applied to elements by element name and attribute type (where applicable). No additional steps required. Please find below the table that contains the list of elements to which skinning is applicable.

  • by adding org.richfaces.CONTROL_SKINNING_CLASSES parameter to web.xml file. Possible values "enable" and "disable". When this option is enabled you are provided with a set of predefined CSS classes that you can use for skinning your HTML components.

By setting org.richfaces.CONTROL_SKINNING_CLASSES to "enable" you are provided with style classes applicable to:

  • Basic elements nested inside element having rich-container class, e.g.:

    Example:

    
    ...
    .rich-container select {
       
    //class content
    }
    ...
  • Elements that have class name corresponding to one of the basic elements name/type mapped by the following scheme rich-<elementName>[-<elementType>] . See the example:

    Example:

    
    ...
    .rich-select {
      
    //class content
    }

    .rich-input-text {
      
    //class content
    }

    ...

    Note:

    Elements have classes based on "link" and pseudo class name, e.g.: rich-link, rich-link-hover, rich-link-visited

Additionally, the predefined rich CSS classes that we provide can be used not only as classes for basic HTML elements but also as classes for creation of complex elements .

There is a snippet with some of them for example:


...
<u:selector name=".rich-box-bgcolor-header">
     <u:style name="background-color" skin="headerBackgroundColor" />
</u:selector>
<u:selector name=".rich-box-bgcolor-general">
     <u:style name="background-color" skin="generalBackgroundColor" />
</u:selector>
...
//gradient elements
...
<u:selector name=".rich-gradient-menu">
     <u:style name="background-image">
          <f:resource f:key="org.richfaces.renderkit.html.gradientimages.MenuGradientImage"/>
     </u:style>
     <u:style name="background-repeat" value="repeat-x" />
</u:selector>
<u:selector name=".rich-gradient-tab">
     <u:style name="background-image">
          <f:resource f:key="org.richfaces.renderkit.html.gradientimages.TabGradientImage"/>
     </u:style>
     <u:style name="background-repeat" value="repeat-x" />
</u:selector>
...

To get a better idea of standard component skinning we recommend to explore CSS files located in ui/core/src/main/resources/org/richfaces/ folder of RichFaces svn.
































Note:

Standard skinning level can fail if configuration of ajaxPortlet is as following:


...
<portlet>
   <portlet-name>ajaxPortlet</portlet-name>
   <header-content>
      <script src="/faces/rfRes/org/ajax4jsf/framework.pack.js" type="text/javascript" />
      <script src="/faces/rfRes/org/richfaces/ui.pack.js" type="text/javascript" />
      <link rel="stylesheet" type="text/css" href="/faces/rfRes/org/richfaces/skin.xcss" />
   </header-content>
</portlet>
...

As it was mentioned earlier in the guide, extended skinning of standard HTML controls is applied automatically: the browser type is detected and if a browser doesn't fully support extended skinning feature, only basic skinning is applied.

However, if you don't want the RichFaces components and standard HTML controls to be skinned automatically and perform the skinnability implementation yourself, you might encounter with a problem, namely standard HTML controls in such browsers as Opera and Safari will be affected by standard controls skinning. ( Here you can get more details on how to disable skinnability.)

In brief, to disable the skinnability mechanism of RichFaces you need to set the "org.richfaces.LoadStyleStrategy" parameter to "NONE" in the web.xml file.


...
<context-param>
    <param-name>org.richfaces.LoadStyleStrategy</param-name>
    <param-value>NONE</param-value>
</context-param>
...

Additionally, you should include the style sheets that perform skinning of the RichFaces component and standard HTML controls.

In order to resolve the problem with extended skinning in Opera and Safari a client script (skinning.js) is added to the RichFaces library. The script detects the browser type and enables extended skinning only for those browsers that fully support it.

The script can be activated by inserting this JavaScript code to the page:


<script type="text/javascript">
    window.RICH_FACES_EXTENDED_SKINNING_ON = true;
</script>

When NO script loading strategy is used and extended skinning is turned on then corresponding warning message will appears in the console.

You also need to specify "media" attribute in the <link> tag which includes the "extended_both.xcss" style sheet with "rich-extended-skinning".

This is how you can include the style sheets to the page, in case automatic skinnability implementation is disabled.


<link href='/YOUR_PROJECT_NAME/a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/css/basic_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf' type='text/css' rel='stylesheet' class='component' />
<link media='rich-extended-skinning' href='/ YOUR_PROJECT_NAME /a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf' type='text/css' rel='stylesheet' class='component' />
<link href='/ YOUR_PROJECT_NAME /a4j_3_2_2-SNAPSHOT/org/richfaces/skin.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf' type='text/css' rel='stylesheet' class='component' />

Note

Now it's necessary to use a4j/versionXXX resources prefix instead of a4j_versionXXX. Base64 encoder changed to use '!' instead of '.'.

XCSS files are the core of RichFaces components skinnability.

XCSS is an XML formatted CSS that adds extra functionality to the skinning process. XCSS extends skinning possibilities by parsing the XCSS file that contains all look-and-feel parameters of a particular component into a standard CSS file that a web browser can recognize.

XCSS file contains CSS properties and skin parameters mappings. Mapping of a CSS selector to a skin parameter is performed using < u:selector > and < u:style> XML tags that form the mapping structure. Please study the example below.


...
<u:selector name=".rich-component-name">
    <u:style name="background-color" skin="additionalBackgroundColor" />
    <u:style name="border-color" skin="tableBorderColor" />
    <u:style name="border-width" skin="tableBorderWidth" />
    <u:style name="border-style" value="solid" />
</u:selector>
...

During processing the code in the shown example is parsed into a standard CSS format.


...
.rich-component-name {
     
background-color: additionalBackgroundColor; /*the value of the constant defined by your skin*/
     
border-color: tableBorderColor; /*the value of the constant defined by your skin*/
     
border-width: tableBorderWidth; /*the value of the constant defined by your skin*/
     
border-style: solid;
}
...

The "name" attribute of <u:selector> tag defines the CSS selector, while "name" attribute of the <u:style> tag defines what skin constant is mapped to a CSS property. The "value" attribute of the <u:style> tag can also be used to assign a value to a CSS property.

CSS selectors with identical skinning properties can be set as a comma separated list.


...
<u:selector name=".rich-ordering-control-disabled, .rich-ordering-control-top, .rich-ordering-control-bottom, .rich-ordering-control-up, .rich-ordering-control-down">
    <u:style name="border-color" skin="tableBorderColor" />
</u:selector>
...

Plug-n-Skin is a feature that gives you an opportunity to easily create, customize and plug into your project a custom skin. The skin can be created basing on parameters of some predefined RichFaces skin.

The feature also provides an option to unify the appearance of rich controls with standard HTML elements.

In order to create your own skin using Plug-n-Skin feature, you can follow these step by step instructions.

First of all, you need to create a template for the new skin. Creation of the template can be performed using Maven build and deployment tool. More information on how to configure Maven for RichFaces here . You can copy and paste these Maven instructions to command line and execute them.


...
mvn archetype:create
-DarchetypeGroupId=org.richfaces.cdk
-DarchetypeArtifactId=maven-archetype-plug-n-skin
-DarchetypeVersion=RF-VERSION
-DartifactId=ARTIFACT-ID
-DgroupId=GROUP-ID
-Dversion=VERSION
...

Primary keys for the command:

  • -DarchetypeVersion indicates the RichFaces version. For example, "3.3.1.BETA5"

  • -DartifactId artifact id of the project

  • -DgroupId group id of the project

  • -Dversion the version of the project you create, by default it is "1.0.-SNAPSHOT"

After this operation, a folder with the name of your "ARTIFACT-ID" appears. The folder contains a template of Maven project.

Next steps will guide you though creating of the skin itself.

In the root folder of Maven project (the one that contains "pom.xml" file) you should run the following command in the command line:


...
mvn cdk:add-skin -Dname=SKIN-NAME -Dpackage=SKIN-PACKAGE
...

Primary keys for the command:

  • -Dname defines the name of the new skin

  • -Dpackage base package of the skin. By default "groupId" of the project is used.

Additional optional keys for the command:

  • -DbaseSkin defines the name of the base skin.

  • -DcreateExt if set to "true", extended CSS classes are added. For more information, please, see "Standard controls skinning"

As a result of the performed operations the following files and folders are created:

  • BaseImage.java - the base class to store images. Location: "\src\main\java\SKIN-PACKAGE\SKIN-NAME\images\"

  • BaseImageTest.java - a test version of a class that stores images. Location: "\src\test\java\SKIN-PACKAGE\SKIN-NAME\images\"

  • XCSS files - XCSS files define the new look of RichFaces components affected by the new skin. Location: "\src\main\resources\SKIN-PACKAGE\SKIN-NAME\css\"

  • SKIN-NAME.properties - a file that contains properties of the new skin. Location: "\src\main\resources\SKIN-PACKAGE\SKIN-NAME\css\"

    The following properties are used to configure the SKIN-NAME.properties file:

    • baseSkin – the name of the base skin to be used as basis. The look of the skin you define will be affected by new style properties.

    • generalStyleSheet - a path to the style sheet (SKIN-NAME.xcss) that imports style sheets of the components to be affected by the new skin.

    • extendedStyleSheet - a path to a style sheet that is used to unify the appearance of RichFaces components and standard HTML controls. For additional information please read "Standard controls skinning" chapter.

    • gradientType - a predefined property to set the type of gradient applied to the new skin. Possible values are glass, plastic, plain. More information on gradient implementation you can find further in this chapter.

  • SKIN-NAME.xcss - a XCSS file that imports XCSS files of the components to be affected by the new skin. Location: "src\main\resources\META-INF\skins "

  • XCSS files If the command is executed with the "DcreateExt" key set to "true", the XCSS (extended_classes.xcss and extended.xcss) files that define style for standard controls will be created. Location: "\src\main\resources\SKIN-PACKAGE\SKIN-NAME\css\".

  • SKIN-NAME-ext.xcss If the command is executed with the "DcreateExt" key set to "true", the configuration SKIN-NAME-ext.xcss file that imports XCSS file defining styles for the standard controls will be created. Location: "src\main\resources\META-INF\skins ".

  • SKIN-NAME-resources.xml - the file contains the description of all listed above files. Location: "src\main\config\resources ".

Now you can start editing the XCSS files located in "\src\main\resources\SKIN-PACKAGE\SKIN-NAME\css\". New style properties can be assigned to the selectors (the selectors listed in the XCSS files) in two ways, which are both valid, and it'up to you what way to choose.

  • Standard CSS coding approach, i.e. you can add CSS properties to the given selectors. The only thing, you have to keep in mind is that the selectors must be inside <f:verbatim> <![CDATA[ ...]]> </f:verbatim> tags.

    For example

    
    ...
    .rich-calendar-cell {
         background: #537df8;
    }
    ...
  • Using XCSS coding approach, the same way as XCSS files are normally formed in RichFaces. The XCSS tags have to be placed outside <f:verbatim> <![CDATA[ ...]]> </f:verbatim> tags.

    
    ...
    <u:selector name=".rich-calendar-cell">
         <u:style name="border-bottom-color" skin="panelBorderColor"/>
         <u:style name="border-right-color" skin="panelBorderColor"/>
         <u:style name="background-color" skin="tableBackgroundColor"/>
         <u:style name="font-size" skin="generalSizeFont"/>
         <u:style name="font-family" skin="generalFamilyFont"/>
    </u:selector>
    ...

Having performed described above steps and edited the XCSS files you can proceed to building the new skin and to plugging it into the project. Building the new skin can be done by executing the given below command in the command line in the root folder of you skin project (the one that contains pom.xml file).


...
mvn clean install
...

In addition Plug-n-Skin has a number of predefined gradients that you can also use to make your application look nicer. The given below code snippet shows how a gradient can be used


...
<u:selector name=".rich-combobox-item-selected">
    <u:style name="border-width" value="1px" />
    <u:style name="border-style" value="solid" />
    <u:style name="border-color" skin="newBorder" />
    <u:style name="background-position" value="0% 50%" />
    <u:style name="background-image">
        <f:resource f:key="org.richfaces.renderkit.html.CustomizeableGradient">
            <f:attribute name="valign" value="middle" />
            <f:attribute name="gradientHeight" value="17px" />
            <f:attribute name="baseColor" skin="headerBackgroundColor" />
         </f:resource>
    </u:style>
</u:selector>
...

So, as you can see, the background-image CSS property is defined with <f:resource f:key="org.richfaces.renderkit.html.CustomizeableGradient"> that sets the gradient. While the gradient type can be specified in the SKIN-NAME.properties file with gradientType property. The gradientType property can be set to one of the possible values glass, plastic, plain. The gradient in it's turn can be can be adjusted using baseColor, gradientColor, gradientHeight, valign attributes. Their usage is shown in the snippet above.

Now, you can use your newly-created and customized skin in your project by adding your new skin parameters to web.xml file and placing the jar file with your skin ( the jar file is located in "target" folder of your skin project) to "\WebContent\WEB-INF\lib\".


...
<context-param>
    <param-name>org.ajax4jsf.SKIN</param-name>
    <param-value>SKIN-NAME</param-value>
</context-param>
...

This section will cover some practical aspects of Plug-n-Skin implementation. It's assumed that you have read the section of the guide that tells how the new skin using Plug-n-Skin prototype can be created.

Above all, we need to create a new skin, in order to do that we just have to follow the steps described in the previous section.

This command will be used to create a template of the new skin project.



mvn archetype:create
-DarchetypeGroupId=org.richfaces.cdk
-DarchetypeArtifactId=maven-archetype-plug-n-skin
-DarchetypeVersion=3.3.1.BETA5
-DartifactId=P-n-S
-DgroupId=GROUPID
-Dversion=1.0.-SNAPSHOT

Now you can browse the "P-n-S" folder to view what files and folders were created there.

Next, we will use Maven to add all needed files to the skin project. This will done by the following command:


mvn cdk:add-skin -DbaseSkin=blueSky  -DcreateExt=true -Dname=PlugnSkinDemo -Dpackage=SKINPACKAGE

As you remember from the previous section "-DbaseSkin" key defines what RichFaces built-in skin to be used as a base one, "-DcreateExt=true" determines that the new skin will come with XCSS files that unify the look of the rich components with standard HTML controls.

So, now the files and folder with all needed resources are created and redefining/editing the new skin can be started.

Now we can start editing XCSS files of the rich components. In order to see how the Plug-n-Skin feature works we will change some style attributes of <rich:calendar> and some basic HTML controls to see how they are affected by standard controls skinning.

Thus, it will be demonstrated how to:

In oder to edit the style properties of <rich:calendar> you need to open the "calendar.xcss" file located in "P-n-S\src\main\resources\skinpackage\plugnskindemo\css\". Once, you have opened the file, please find ".rich-calendar-today" selector and amend it as follows: background-color: #075ad1;. The current day's background color can be considered recolored.

Now we will see how font style of a standard HTML submit button can be changed. Please, open "extended.xcss" file located in "P-n-S\src\main\resources\skinpackage\plugnskindemo\css\" and put in font-weight: bold; inside the curly braces of these coma separated selectors button[type="button"], button[type="reset"], button[type="submit"], input[type="reset"], input[type="submit"], input[type="button"]. So, the CSS code should look like this.



button[type=&quot;button&quot;], button[type=&quot;reset&quot;], button[type=&quot;submit&quot;], input[type=&quot;reset&quot;], input[type=&quot;submit&quot;], input[type=&quot;button&quot;] {
    font-weight: bold;
}

All the changes that were planned to be preformed are done and now you can proceed to building the new PlugnSkinDemo skin and import it into the project. As you read in the previous section, the skin should be built in the "P-n-S" folder of the skin project by executing mvn clean install command. This procedure results in creating a "target" folder that contains a .jar file with a compiled new skin, it our case the file is named "P-n-S-1.0.-SNAPSHOT.jar". The next step is to import the new PlugnSkinDemo skin into the project.

What you need to do, in order to have the new skin imported to the project is to

Please, do not forget that standard controls skinning has to be enabled in the "web.xml" file, which can be done by adding the following code to the "web.xml" file:


<context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
</context-param>

The result of both operations is displayed on the figure below.


JSF has an advanced navigation mechanism that allows you to define navigation from view to view. Navigation happens in a Web Application when a user tries to switch from one page to another page either by clicking a button, a hyperlink, or another command component. But there is no switch mechanism between some logical states of the same view. For example in Login/Register dialog an existing user signs in with his user name and password, but if a new user registers an additional field "Confirm" is displayed, buttons labels and methods are changed when the user clicks "To register" link:



RichFaces State API allows easily to define some set of states for the pages and any properties for this states.

Actually States is a map where the entry key is a name of the State and the value is a State map. Particular State map has entries with some names as keys and any objects as values that are used after the state activation. Thus, in the State map you could define any values, method bindings, or just some simple state variables (constants) which have different values for every State.


One of the most convenience features of the RichFaces State API is a navigation between states. The RichFaces State API implements states change as the standard JSF navigation. Action component just returns outcome and the RichFaces State API extension for the JSF navigation handler checks whether this outcome is registered as a state change outcome or not. If the state change outcome is found the corresponding state is activated. Otherwise the standard navigation handling is called.

In order to use RichFaces State API you should follow the next steps:

  • Register State Manager EL resolver and navigation handler in the faces-config.xml:

    
    ...
    <application>
        <navigation-handler>org.richfaces.ui.application.StateNavigationHandler</navigation-handler>
        <el-resolver>org.richfaces.el.StateELResolver</el-resolver>
    </application>
    ...
  • Register an additional application factory in the faces-config.xml:

    
    ...
    <factory>
        <application-factory>org.richfaces.ui.application.StateApplicationFactory</application-factory>
    </factory>
    ...
  • Register two managed beans in the faces-config.xml:

    
    ...
    <managed-bean>
        <managed-bean-name>state</managed-bean-name>
        <managed-bean-class>org.richfaces.ui.model.States</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>states</property-name>
            <property-class>org.richfaces.ui.model.States</property-class>
            <value>#{config.states}</value>
        </managed-property>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>config</managed-bean-name>
        <managed-bean-class>org.richfaces.demo.stateApi.Config</managed-bean-class>
        <managed-bean-scope>none</managed-bean-scope>
    </managed-bean>
    ...

    One bean ("config") defines and stores states as it is shown in the following example:

    ...
    
    public class Config {
        /**
         * @return States
         */
        public States getStates() {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            States states = new States();
            // Registering new User State definition
            states.setCurrentState("register"); // Name of the new state
            // Text labels, properties and Labels for controls in "register" state
            states.put("showConfirm", Boolean.TRUE); // confirm field rendering
            states.put("link", "(To login)"); // Switch State link label
            states.put("okBtn", "Register"); // Login/Register button label
            states.put("stateTitle", "Register New User"); // Panel title
            ExpressionFactory expressionFactory = facesContext.getApplication()
                    .getExpressionFactory();
            // Define "registerbean" available under "bean" EL binding on the page
            ValueExpression beanExpression = expressionFactory
                    .createValueExpression(facesContext.getELContext(),
                            "#{registerbean}", Bean.class);
            states.put("bean", beanExpression);
            // Define "registeraction" available under "action" EL binding on the
            // page
            beanExpression = expressionFactory.createValueExpression(facesContext
                    .getELContext(), "#{registeraction}", RegisterAction.class);
            states.put("action", beanExpression);
            // Define method expression inside registeraction binding for this state
            MethodExpression methodExpression = expressionFactory.createMethodExpression(
                    facesContext.getELContext(), "#{registeraction.ok}",
                    String.class, new Class[] {});
            states.put("ok", methodExpression);
            // Outcome for switching to login state definition
            states.setNavigation("switch", "login");
            // Login Existent User State analogous definition
            states.setCurrentState("login");
            states.put("showConfirm", Boolean.FALSE);
            states.put("link", "(To register)");
            states.put("okBtn", "Login");
            states.put("stateTitle", "Login Existing User");
            beanExpression = expressionFactory.createValueExpression(facesContext
                    .getELContext(), "#{loginbean}", Bean.class);
            states.put("bean", beanExpression);
            beanExpression = expressionFactory.createValueExpression(facesContext
                    .getELContext(), "#{loginaction}", LoginAction.class);
            states.put("action", beanExpression);
            methodExpression = expressionFactory.createMethodExpression(
                    facesContext.getELContext(), "#{loginaction.ok}",
                    String.class, new Class[] {});
            states.put("ok", methodExpression);
            states.setNavigation("switch", "register");
            return states;
        }
    }
    ...

    The other bean ("state") with the type org.richfaces.ui.model.States has the "states" managed property that is bound to the "config" bean which defines states.

  • Use state bindings on the page. See the following example:

    
    ...
    <h:panelGrid columns="3">
        <h:outputText value="username" />
        <h:inputText value="#{state.bean.name}" id="name" required="true" />
        <h:outputText value="password" />
        <h:inputSecret value="#{state.bean.password}" id="password" required="true" />
        <h:outputText value="confirm" rendered="#{state.showConfirm}" />
        <h:inputSecret value="#{state.bean.confirmPassword}" rendered="#{state.showConfirm}" id="confirm" required="true" />
    </h:panelGrid>
    <a4j:commandButton actionListener="#{state.action.listener}" action="#{state.ok}" value="#{state.okBtn}" id="action"/>
    ...

To get full Login/Register dialog example, please, click here.

+6.1. < a4j:ajaxListener >
6.1.1. Description
6.1.2. Creating on a page
6.1.3. Creating the Component Dynamically Using Java
6.1.4. Key attributes and ways of usage
6.1.5. Relevant resources links
+6.2. < a4j:keepAlive >
6.2.1. Description
6.2.2. Using the tag on a Page
6.2.3. Key attributes and ways of usage
6.2.4. Relevant resources links
+6.3. < a4j:actionparam >
6.3.1. Description
6.3.2. Creating on a page
6.3.3. Creating the Component Dynamically Using Java
6.3.4. Key attributes and ways of usage
6.3.5. Relevant resources links
+6.4. < a4j:commandButton >
6.4.1. Description
6.4.2. Creating on a page
6.4.3. Creating the Component Dynamically Using Java
6.4.4. Key attributes and ways of usage
6.4.5. Relevant resources links
+6.5. < a4j:commandLink >
6.5.1. Description
6.5.2. Creating on a page
6.5.3. Creating the Component Dynamically Using Java
6.5.4. Key attributes and ways of usage
6.5.5. Relevant resources links
+6.6. < a4j:form >
6.6.1. Description
6.6.2. Creating on a page
6.6.3. Creating the Component Dynamically Using Java
6.6.4. Key attributes and ways of usage
6.6.5. Relevant resources links
+6.7. < a4j:htmlCommandLink >
6.7.1. Description
6.7.2. Creating the Component with a Page Tag
6.7.3. Creating the Component Dynamically Using Java
6.7.4. Key attributes and ways of usage
6.7.5. Relevant resources links
+6.8. < a4j:jsFunction >
6.8.1. Description
6.8.2. Creating on a page
6.8.3. Creating the Component Dynamically Using Java
6.8.4. Key attributes and ways of usage
6.8.5. Relevant resources links
+6.9. < a4j:include >
6.9.1. Description
6.9.2. Creating on a page
6.9.3. Creating the Component Dynamically Using Java
6.9.4. Relevant resources links
+6.10. < a4j:loadBundle >
6.10.1. Description
6.10.2. Creating on a page
6.10.3. Creating the Component Dynamically Using Java
6.10.4. Key attributes and ways of usage
6.10.5. Relevant resources links
+6.11. < a4j:loadScript >
6.11.1. Description
6.11.2. Creating on a page
6.11.3. Creating the Component Dynamically Using Java
6.11.4. Key attributes and ways of usage
6.11.5. Relevant resources links
+6.12. < a4j:loadStyle >
6.12.1. Description
6.12.2. Creating on a page
6.12.3. Creating the Component Dynamically Using Java
6.12.4. Key attributes and ways of usage
6.12.5. Relevant resources links
+6.13. < a4j:log >
6.13.1. Description
6.13.2. Creating the Component with a Page Tag
6.13.3. Creating the Component Dynamically Using Java
6.13.4. Key attributes and ways of usage
6.13.5. Relevant resources links
+6.14. < a4j:mediaOutput >
6.14.1. Description
6.14.2. Creating on a page
6.14.3. Creating the Component Dynamically Using Java
6.14.4. Key attributes and ways of usage
6.14.5. Relevant resources links
+6.15. < a4j:outputPanel >
6.15.1. Description
6.15.2. Creating on a page
6.15.3. Creating the Component Dynamically Using Java
6.15.4. Key attributes and ways of usage
6.15.5. Relevant resources links
+6.16. < a4j:page >
6.16.1. Description
6.16.2. Creating on a page
6.16.3. Creating the Component Dynamically Using Java
6.16.4. Facets
6.16.5. Key attributes and ways of usage
6.16.6. Relevant resources links
+6.17. < a4j:poll >
6.17.1. Description
6.17.2. Creating on a page
6.17.3. Creating the Component Dynamically Using Java
6.17.4. Key attributes and ways of usage
6.17.5. Relevant resources links
+6.18. < a4j:portlet >
6.18.1. Description
6.18.2. Creating the Component with a Page Tag
6.18.3. Creating the Component Dynamically Using Java
6.18.4. Key attributes and ways of usage
6.18.5. Relevant resources links
+6.19. < a4j:push >
6.19.1. Description
6.19.2. Creating on a page
6.19.3. Creating the Component Dynamically Using Java
6.19.4. Key attributes and ways of usage
6.19.5. Relevant resources links
+6.20. < a4j:queue >
6.20.1. Description
6.20.2. Creating on a page
6.20.3. Creating the Component Dynamically Using Java
6.20.4. Key attributes and ways of usage
6.20.5. JavaScript API
6.20.6. Relevant resources links
+6.21. < a4j:region >
6.21.1. Description
6.21.2. Creating on a page
6.21.3. Creating the Component Dynamically Using Java
6.21.4. Key attributes and ways of usage
6.21.5. Relevant resources links
+6.22. < a4j:repeat >
6.22.1. Description
6.22.2. Creating on a page
6.22.3. Creating the Component Dynamically Using Java
6.22.4. Key attributes and ways of usage
6.22.5. Relevant resources links
+6.23. < a4j:status >
6.23.1. Description
6.23.2. Creating on a page
6.23.3. Creating the Component Dynamically Using Java
6.23.4. Facets
6.23.5. Key attributes and ways of usage
6.23.6. Relevant resources links
+6.24. < a4j:support >
6.24.1. Description
6.24.2. Creating on a page
6.24.3. Creating the Component Dynamically Using Java
6.24.4. Key attributes and ways of usage
6.24.5. Relevant resources links
+6.25. < rich:ajaxValidator >
6.25.1. Description
6.25.2. Key Features
6.25.3. Creating the Component with a Page Tag
6.25.4. Creating the Component Dynamically Using Java
6.25.5. Details of Usage
6.25.6. Relevant Resources Links
+6.26. < rich:graphValidator >
6.26.1. Description
6.26.2. Key Features
6.26.3. Creating the Component with a Page Tag
6.26.4. Creating the Component Dynamically Using Java
6.26.5. Relevant Resources Links
+6.27. < rich:beanValidator >
6.27.1. Description
6.27.2. Key Features
6.27.3. Creating the Component with a Page Tag
6.27.4. Creating the Component Dynamically Using Java
6.27.5. Details of Usage
6.27.6. Relevant Resources Links
+6.28. < rich:calendar >
6.28.1. Description
6.28.2. Key Features
6.28.3. Creating the Component with a Page Tag
6.28.4. Creating the Component Dynamically Using Java
6.28.5. Details of Usage
6.28.6. JavaScript API
6.28.7. Facets
6.28.8. Look-and-Feel Customization
6.28.9. Skin Parameters Redefinition
6.28.10. Definition of Custom Style Classes
6.28.11. Relevant Resources Links
+6.29. < rich:colorPicker >
6.29.1. Description
6.29.2. Key Features
6.29.3. Creating the Component with a Page Tag
6.29.4. Creating the Component Dynamically Using Java
6.29.5. Details of Usage
6.29.6. Look-and-Feel Customization
6.29.7. Skin Parameters Redefinition
6.29.8. Definition of Custom Style Classes
6.29.9. Relevant Resources Links
+6.30. < rich:comboBox >
6.30.1. Description
6.30.2. Key Features
6.30.3. Creating the Component with a Page Tag
6.30.4. Creating the Component Dynamically Using Java
6.30.5. Details of Usage
6.30.6. JavaScript API
6.30.7. Look-and-Feel Customization
6.30.8. Skin Parameters Redefinition
6.30.9. Definition of Custom Style Classes
6.30.10. Relevant Resources Links
+6.31. < rich:componentControl >
6.31.1. Description
6.31.2. Key Features
6.31.3. Creating the Component with a Page Tag
6.31.4. Creating the Component Dynamically Using Java
6.31.5. Details of Usage
6.31.6. Look-and-Feel Customization
6.31.7. Relevant Resources Links
+6.32. < rich:contextMenu >
6.32.1. Description
6.32.2. Key Features
6.32.3. Creating the Component with a Page Tag
6.32.4. Creating the Component Dynamically Using Java
6.32.5. Details of Usage
6.32.6. JavaScript API
6.32.7. Look-and-Feel Customization
6.32.8. Skin Parameters Redefinition
6.32.9. Definition of Custom Style Classes
6.32.10. Relevant Resources Links
+6.33. < rich:dataFilterSlider >
6.33.1. Description
6.33.2. Key Features
6.33.3. Creating the Component with a Page Tag
6.33.4. Creating the Component Dynamically Using Java
6.33.5. Details of Usage
6.33.6. Look-and-Feel Customization
6.33.7. Relevant Resources Links
+6.34. < rich:datascroller >
6.34.1. Description
6.34.2. Key Features
6.34.3. Creating the Component with a Page Tag
6.34.4. Creating the Component Dynamically Using Java
6.34.5. Details of Usage
6.34.6. Facets
6.34.7. Look-and-Feel Customization
6.34.8. Skin Parameters Redefinition
6.34.9. Definition of Custom Style Classes
6.34.10. Relevant Resources Links
+6.35. < rich:columns >
6.35.1. Description
6.35.2. Key Features
6.35.3. Creating the Component with a Page Tag
6.35.4. Creating the Component Dynamically Using Java
6.35.5. Details of Usage
6.35.6. Facets
6.35.7. Look-and-Feel Customization
6.35.8. Skin Parameters Redefinition
6.35.9. Definition of Custom Style Classes
6.35.10. Relevant Resources Links
+6.36. < rich:columnGroup >
6.36.1. Description
6.36.2. Key Features
6.36.3. Creating the Component with a Page Tag
6.36.4. Creating the Component Dynamically Using Java
6.36.5. Details of Usage
6.36.6. Look-and-Feel Customization
6.36.7. Skin Parameters Redefinition
6.36.8. Definition of Custom Style Classes
6.36.9. Relevant Resources Links
+6.37. < rich:column >
6.37.1. Description
6.37.2. Key Features
6.37.3. Creating the Component with a Page Tag
6.37.4. Creating the Component Dynamically Using Java
6.37.5. Details of Usage
+6.37.6. Sorting and Filtering
6.37.6.1. Sorting
6.37.6.2. Filtering
6.37.7. Facets
6.37.8. Look-and-Feel Customization
6.37.9. Skin Parameters Redefinition
6.37.10. Definition of Custom Style Classes
6.37.11. Relevant Resources Links
+6.38. < rich:dataGrid >
6.38.1. Description
6.38.2. Key Features
6.38.3. Creating the Component with a Page Tag
6.38.4. Creating the Component Dynamically Using Java
6.38.5. Details of Usage
6.38.6. Facets
6.38.7. Look-and-Feel Customization
6.38.8. Skin Parameters Redefinition
6.38.9. Definition of Custom Style Classes
6.38.10. Relevant Resources Links
+6.39. < rich:dataList >
6.39.1. Description
6.39.2. Key Features
6.39.3. Creating the Component with a Page Tag
6.39.4. Creating the Component Dynamically Using Java
6.39.5. Details of Usage
6.39.6. Look-and-Feel Customization
6.39.7. Definition of Custom Style Classes
6.39.8. Relevant Resources Links
+6.40. < rich:dataOrderedList >
6.40.1. Description
6.40.2. Key Features
6.40.3. Creating the Component with a Page Tag
6.40.4. Creating the Component Dynamically Using Java
6.40.5. Details of Usage
6.40.6. Look-and-Feel Customization
6.40.7. Definition of Custom Style Classes
6.40.8. Relevant Resources Links
+6.41. < rich:dataDefinitionList >
6.41.1. Description
6.41.2. Key Features
6.41.3. Creating the Component with a Page Tag
6.41.4. Creating the Component Dynamically Using Java
6.41.5. Details of Usage
6.41.6. Look-and-Feel Customization
6.41.7. Definition of Custom Style Classes
6.41.8. Relevant Resources Links
+6.42. < rich:dataTable >
6.42.1. Description
6.42.2. Key Features
6.42.3. Creating the Component with a Page Tag
6.42.4. Creating the Component Dynamically from Java
6.42.5. Details of Usage
6.42.6. Facets
6.42.7. Look-and-Feel Customization
6.42.8. Skin Parameters Redefinition
6.42.9. Definition of Custom Style Classes
6.42.10. Relevant Resources Links
+6.43. < rich:subTable >
6.43.1. Description
6.43.2. Key Features
6.43.3. Creating the Component with a Page Tag
6.43.4. Creating the Component Dynamically Using Java
6.43.5. Details of Usage
6.43.6. Facets
6.43.7. Look-and-Feel Customization
6.43.8. Skin Parameters Redefinition
6.43.9. Definition of Custom Style Classes
+6.44. < rich:editor >
6.44.1. Description
6.44.2. Key Features
6.44.3. Creating the Component with a Page Tag
6.44.4. Creating the Component Dynamically Using Java
6.44.5. Details of Usage
6.44.6. Look-and-Feel Customization
6.44.7. Skin Parameters Redefinition
6.44.8. Definition of Custom Style Selectors
6.44.9. Relevant Resources Links
+6.45. < rich:dndParam >
6.45.1. Description
6.45.2. Creating the Component with a Page Tag
6.45.3. Creating the Component Dynamically Using Java
6.45.4. Details of Usage
6.45.5. Look-and-Feel Customization
6.45.6. Relevan Resources Links
+6.46. < rich:dragIndicator >
6.46.1. Description
6.46.2. Key Features
6.46.3. Creating the Component with a Page Tag
6.46.4. Creating the Component Dynamically Using Java
+6.46.5. Details of Usage
6.46.5.1. Macro definitions
6.46.5.2. Predefined macro definitions
6.46.5.3. Marker customization
6.46.6. Look-and-Feel Customization
6.46.7. Relevant Resources Links
+6.47. < rich:dragSupport >
6.47.1. Description
6.47.2. Key Features
6.47.3. Creating the Component with a Page Tag
6.47.4. Creating the Component Dynamically Using Java
6.47.5. Details of Usage
6.47.6. Look-and-Feel Customization
6.47.7. Relevant Resources Links
+6.48. < rich:dropSupport >
6.48.1. Description
6.48.2. Key Features
6.48.3. Creating the Component with a Page Tag
6.48.4. Creating the Component Dynamically Using Java
6.48.5. Details of Usage
6.48.6. Look-and-Feel Customization
6.48.7. Relevant Resources Links
+6.49. < rich:dragListener >
6.49.1. Description
6.49.2. Key Features
6.49.3. Creating the Component with a Page Tag
6.49.4. Creating the Component Dynamically Using Java
6.49.5. Details of Usage
6.49.6. Look-and-Feel Customization
+6.50. < rich:dropListener >
6.50.1. Description
6.50.2. Key Features
6.50.3. Creating the Component with a Page Tag
6.50.4. Creating the Component Dynamically Using Java
6.50.5. Details of Usage
6.50.6. Look-and-Feel Customization
+6.51. < rich:dropDownMenu >
6.51.1. Description
6.51.2. Key Features
6.51.3. Creating the Component with a Page Tag
6.51.4. Creating the Component Dynamically Using Java
6.51.5. Details of Usage
6.51.6. Facets
6.51.7. Look-and-Feel Customization
6.51.8. Skin Parameters Redefinition
6.51.9. Definition of Custom Style Classes
6.51.10. Relevant Resources Links
+6.52. < rich:extendedDataTable >
6.52.1. Creating the Component with a Page Tag
6.52.2. Creating the Component Dynamically from Java
6.52.3. Details of Usage
6.52.4. Facets
6.52.5. Look-and-Feel Customization
6.52.6. Skin Parameters Redefinition
6.52.7. Definition of Custom Style Classes
6.52.8. Relevant resources links
+6.53. < rich:menuGroup >
6.53.1. Description
6.53.2. Key Features
6.53.3. Creating the Component with a Page Tag
6.53.4. Creating the Component Dynamically Using Java
6.53.5. Details of Usage
6.53.6. Facets
6.53.7. Look-and-Feel Customization
6.53.8. Skin Parameters Redefinition
6.53.9. Definition of Custom Style Classes
6.53.10. Relevant Resources Links
+6.54. < rich:menuItem >
6.54.1. Description
6.54.2. Key Features
6.54.3. Creating the Component with a Page Tag
6.54.4. Creating the Component Dynamically Using Java
6.54.5. Details of Usage
6.54.6. Facets
6.54.7. Look-and-Feel Customization
6.54.8. Skin Parameters Redefinition
6.54.9. Definition of Custom Style Classes
6.54.10. Relevant Resources Links
+6.55. < rich:menuSeparator >
6.55.1. Description
6.55.2. Creating the Component with a Page Tag
6.55.3. Creating the Component Dynamically Using Java
6.55.4. Look-and-Feel Customization
6.55.5. Skin Parameters Redefinition
6.55.6. Definition of Custom Style Classes
6.55.7. Relevant Resources Links
+6.56. < rich:effect >
6.56.1. Description
6.56.2. Key Features
6.56.3. Creating the Component with a Page Tag
6.56.4. Creating the Component Dynamically Using Java
6.56.5. Details of Usage
6.56.6. Look-and-Feel Customization
6.56.7. Relevant Resources Links
+6.57. < rich:fileUpload >
6.57.1. Description
6.57.2. Key Features
6.57.3. Creating the Component with a Page Tag
6.57.4. Creating the Component Dynamically Using Java
6.57.5. Details of Usage
6.57.6. JavaScript API
6.57.7. Facets
6.57.8. Look-and-Feel Customization
6.57.9. Skin Parameters Redefinition
6.57.10. Definition of Custom Style Classes
6.57.11. Relevant Resources Links
+6.58. < rich:gmap >
6.58.1. Description
6.58.2. Key Features
6.58.3. Creating the Component with a Page Tag
6.58.4. Creating the Component Dynamically Using Java
6.58.5. Details of Usage
6.58.6. Look-and-Feel Customization
6.58.7. Definition of Custom Style Classes
6.58.8. Relevant Resources Links
+6.59. < rich:virtualEarth >
6.59.1. Description
6.59.2. Key Features
6.59.3. Creating the Component with a Page Tag
6.59.4. Creating the Component Dynamically Using Java
6.59.5. Details of Usage
6.59.6. Look-and-Feel Customization
6.59.7. Definition of Custom Style Classes
6.59.8. Relevant Resources Links
+6.60. < rich:hotKey >
6.60.1. Description
6.60.2. Key Features
6.60.3. Creating the Component with a Page Tag
6.60.4. Creating the Component Dynamically Using Java
6.60.5. Details of Usage
6.60.6. JavaScript API
6.60.7. Look-and-Feel Customization
6.60.8. Relevant Resources Links
+6.61. < rich:inplaceInput >
6.61.1. Description
6.61.2. Key Features
6.61.3. Creating the Component with a Page Tag
6.61.4. Creating the Component Dynamically Using Java
6.61.5. Details of Usage
6.61.6. JavaScript API
6.61.7. Facets
6.61.8. Look-and-Feel Customization
6.61.9. Skin Parameters Redefinition
6.61.10. Definition of Custom Style Classes
6.61.11. Relevant Resources Links
+6.62. < rich:inplaceSelect >
6.62.1. Description
6.62.2. Key Features
6.62.3. Creating the Component with a Page Tag
6.62.4. Creating the Component Dynamically Using Java
6.62.5. Details of Usage
6.62.6. JavaScript API
6.62.7. Facets
6.62.8. Look-and-Feel Customization
6.62.9. Skin Parameters Redefinition
6.62.10. Definition of Custom Style Classes
6.62.11. Relevant Resources Links
+6.63. < rich:inputNumberSlider >
6.63.1. Description
6.63.2. Key Features
6.63.3. Creating the Component with a Page Tag
6.63.4. Creating the Component Dynamically Using Java
6.63.5. Details of Usage
6.63.6. Look-and-Feel Customization
6.63.7. Skin Parameters Redefinition
6.63.8. Definition of Custom Style Classes
6.63.9. Relevant Resources Links
+6.64. < rich:inputNumberSpinner >
6.64.1. Description
6.64.2. Key Features
6.64.3. Creating the Component with a Page Tag
6.64.4. Creating the Component Dynamically Using Java
6.64.5. Details of Usage
6.64.6. Look-and-Feel Customization
6.64.7. Skin Parameters Redefinition
6.64.8. Definition of Custom Style Classes
6.64.9. Relevant Resources Links
+6.65. < rich:insert >
6.65.1. Description
6.65.2. Key Features
6.65.3. Creating the Component with a Page Tag
6.65.4. Creating the Component Dynamically Using Java
6.65.5. Details of Usage
6.65.6. Look-and-Feel Customization
6.65.7. Relevant Resources Links
+6.66. < rich:jQuery >
6.66.1. Description
6.66.2. Key Features
6.66.3. Creating the Component with a Page Tag
6.66.4. Creating the Component Dynamically Using Java
6.66.5. Details of Usage
6.66.6. Look-and-Feel Customization
6.66.7. Relevant Resources Links
+6.67. < rich:listShuttle >
6.67.1. Description
6.67.2. Key Features
6.67.3. Creating the Component with a Page Tag
6.67.4. Creating the Component Dynamically Using Java
6.67.5. Details of Usage
6.67.6. JavaScript API
6.67.7. Facets
6.67.8. Look-and-Feel Customization
6.67.9. Skin Parameters Redefinition
6.67.10. Definition of Custom Style Classes
6.67.11. Relevant Resources Links
+6.68. < rich:message >
6.68.1. Description
6.68.2. Key Features
6.68.3. Creating the Component with a Page Tag
6.68.4. Creating the Component Dynamically Using Java
6.68.5. Details of Usage
6.68.6. Facets
6.68.7. Look-and-Feel Customization
6.68.8. Definition of Custom Style Classes
6.68.9. Relevant Resources Links
+6.69. < rich:messages >
6.69.1. Description
6.69.2. Key Features
6.69.3. Creating the Component with a Page Tag
6.69.4. Creating the Component Dynamically Using Java
6.69.5. Details of Usage
6.69.6. Look-and-Feel Customization
6.69.7. Definition of Custom Style Classes
6.69.8. Relevant Resources Links
+6.70. < rich:modalPanel >
6.70.1. Description
6.70.2. Key Features
6.70.3. Creating the Component with a Page Tag
6.70.4. Creating the Component Dynamically Using Java
6.70.5. Details of Usage
6.70.6. JavaScript API
6.70.7. Facets
6.70.8. Look-and-Feel Customization
6.70.9. Skin Parameters Redefinition
6.70.10. Definition of Custom Style Classes
6.70.11. Relevant Resources Links
+6.71. < rich:orderingList >
6.71.1. Description
6.71.2. Key Features
6.71.3. Creating the Component with a Page Tag
6.71.4. Creating the Component Dynamically Using Java
6.71.5. Details of Usage
6.71.6. JavaScript API
6.71.7. Facets
6.71.8. Look-and-Feel Customization
6.71.9. Skin Parameters Redefinition
6.71.10. Definition of Custom Style Classes
6.71.11. Relevant Resources Links
+6.72. < rich:paint2D >
6.72.1. Description
6.72.2. Key Features
6.72.3. Creating the Component with a Page Tag
6.72.4. Creating the Component Dynamically Using Java
6.72.5. Details of Usage
6.72.6. Look-and-Feel Customization
6.72.7. Relevant Resources Links
+6.73. < rich:panel >
6.73.1. Description
6.73.2. Key Features
6.73.3. Creating the Component with a Page Tag
6.73.4. Creating the Component Dynamically Using Java
6.73.5. Details of Usage
6.73.6. Facets
6.73.7. Look-and-Feel Customization
6.73.8. Skin Parameters Redefinition
6.73.9. Definition of Custom Style Classes
6.73.10. Relevant Resources Links
+6.74. < rich:panelBar >
6.74.1. Description
6.74.2. Key Features
6.74.3. Creating the Component with a Page Tag
6.74.4. Creating the Component Dynamically Using Java
6.74.5. Details of Usage
6.74.6. Look-and-Feel Customization
6.74.7. Skin Parameters Redefinition
6.74.8. Definition of Custom Style Classes
6.74.9. Relevant Resources Links
+6.75. < rich:panelBarItem >
6.75.1. Description
6.75.2. Key Features
6.75.3. Creating the Component with a Page Tag
6.75.4. Creating the Component Dynamically Using Java
6.75.5. Details of Usage
6.75.6. Facets
6.75.7. Look-and-Feel Customization
6.75.8. Skin Parameters Redefinition
6.75.9. Definition of Custom Style Classes
+6.76. < rich:panelMenu >
6.76.1. Description
6.76.2. Key Features
6.76.3. Creating the Component with a Page Tag
6.76.4. Creating the Component Dynamically Using Java
6.76.5. Details of Usage
6.76.6. JavaScript API
6.76.7. Look-and-Feel Customization
6.76.8. Definition of Custom Style Classes
6.76.9. Relevant Resources Links
+6.77. < rich:panelMenuGroup >
6.77.1. Description
6.77.2. Key Features
6.77.3. Creating the Component with a Page Tag
6.77.4. Creating the Component Dynamically Using Java
6.77.5. Details of Usage
6.77.6. JavaScript API
6.77.7. Look-and-Feel Customization
6.77.8. Skin Parameters Redefinition
6.77.9. Definition of Custom Style Classes
6.77.10. Relevant resources links
+6.78. < rich:panelMenuItem >
6.78.1. Description
6.78.2. Key Features
6.78.3. Creating the Component with a Page Tag
6.78.4. Creating the Component Dynamically Using Java
6.78.5. Details of Usage
6.78.6. Look-and-Feel Customization
6.78.7. Skin Parameters Redefinition
6.78.8. Definition of Custom Style Classes
6.78.9. Relevant resources links
+6.79. < rich:pickList >
6.79.1. Description
6.79.2. Key Features
6.79.3. Creating the Component with a Page Tag
6.79.4. Creating the Component Dynamically Using Java
6.79.5. Details of Usage
6.79.6. Facets
6.79.7. Look-and-Feel Customization
6.79.8. Skin Parameters Redefinition
6.79.9. Definition of Custom Style Classes
6.79.10. Relevant Resources Links
+6.80. < rich:progressBar >
6.80.1. Description
6.80.2. Key Features
6.80.3. Creating the Component with a Page Tag
6.80.4. Creating the Component Dynamically Using Java
6.80.5. Details of Usage
6.80.6. JavaScript API
6.80.7. Facets
6.80.8. Look-and-Feel Customization
6.80.9. Skin Parameters Redefinition
6.80.10. Definition of Custom Style Classes
6.80.11. Relevant Resources Links
+6.81. < rich:scrollableDataTable >
6.81.1. Description
6.81.2. Key Features
+6.82. < rich:separator >
6.82.1. Description
6.82.2. Key Features
6.82.3. Creating the Component with a Page Tag
6.82.4. Creating the Component Dynamically Using Java
6.82.5. Details of Usage
6.82.6. Look-and-Feel Customization
6.82.7. Definition of Custom Style Classes
6.82.8. Relevant Resources Links
+6.83. < rich:simpleTogglePanel >
6.83.1. Description
6.83.2. Key Features
6.83.3. Creating the Component with a Page Tag
6.83.4. Creating the Component Dynamically Using Java
6.83.5. Details of Usage
6.83.6. Facets
6.83.7. Look-and-Feel Customization
6.83.8. Skin Parameters Redefinition
6.83.9. Definition of Custom Style Classes
6.83.10. Relevant Resources Links
+6.84. < rich:spacer >
6.84.1. Description
6.84.2. Key Features
6.84.3. Creating the Component with a Page Tag
6.84.4. Creating the Component Dynamically Using Java
6.84.5. Details of Usage
6.84.6. Look-and-Feel Customization
6.84.7. Relevant Resources Links
+6.85. < rich:suggestionbox >
6.85.1. Description
6.85.2. Key Features
6.85.3. Creating the Component with a Page Tag
6.85.4. Creating the Component Dynamically Using Java
6.85.5. Details of Usage
6.85.6. JavaScript API
6.85.7. Facets
6.85.8. Look-and-Feel Customization
6.85.9. Skin Parameters Redefinition
6.85.10. Definition of Custom Style Classes
6.85.11. Relevant Resources Links
+6.86. < rich:tabPanel >
6.86.1. Description
6.86.2. Key Features
6.86.3. Creating the Component with a Page Tag
6.86.4. Creating the Component Dynamically Using Java
6.86.5. Details of Usage
6.86.6. Look-and-Feel Customization
6.86.7. Skin Parameters Redefinition
6.86.8. Definition of Custom Style Classes
6.86.9. Relevant Resources Links
+6.87. < rich:tab >
6.87.1. Description
6.87.2. Key Features
6.87.3. Creating the Component with a Page Tag
6.87.4. Creating the Component Dynamically Using Java
6.87.5. Details of Usage
6.87.6. Facets
6.87.7. Look-and-Feel Customization
6.87.8. Skin Parameters Redefinition
6.87.9. Definition of Custom Style Classes
+6.88. < rich:togglePanel >
6.88.1. Description
6.88.2. Key Features
6.88.3. Creating the Component with a Page Tag
6.88.4. Creating the Component Dynamically Using Java
6.88.5. Details of Usage
6.88.6. Look-and-Feel Customization
6.88.7. Definition of Custom Style Classes
6.88.8. Relevant Resources Links
+6.89. < rich:toggleControl >
6.89.1. Description
6.89.2. Key Features
6.89.3. Creating the Component with a Page Tag
6.89.4. Creating the Component Dynamically Using Java
6.89.5. Details of Usage
6.89.6. Look-and-Feel Customization
6.89.7. Definition of Custom Style Classes
+6.90. < rich:toolBar >
6.90.1. Description
6.90.2. Key Features
6.90.3. Creating the Component with a Page Tag
6.90.4. Creating the Component Dynamically Using Java
6.90.5. Details of Usage
6.90.6. Facets
6.90.7. Look-and-Feel Customization
6.90.8. Skin Parameters Redefinition
6.90.9. Definition of Custom Style Classes
6.90.10. Relevant Resources Links
+6.91. < rich:toolBarGroup >
6.91.1. Description
6.91.2. Key Features
6.91.3.
6.91.4. Creating the Component with a Page Tag
6.91.5. Creating the Component Dynamically Using Java
6.91.6. Details of Usage
6.91.7. Look-and-Feel Customization
6.91.8. Definition of Custom Style Classes
6.91.9. Relevant resources links
+6.92. < rich:toolTip >
6.92.1. Description
6.92.2. Key Features
6.92.3. Creating the Component with a Page Tag
6.92.4. Creating the Component Dynamically Using Java
6.92.5. Details of Usage
6.92.6. JavaScript API
6.92.7. Facets
6.92.8. Look-and-Feel Customization
6.92.9. Skin Parameters Redefinition
6.92.10. Definition of Custom Style Classes
6.92.11. Relevant Resources Links
+6.93. < rich:tree >
6.93.1. Description
6.93.2. Key Features
6.93.3. Creating the Component with a Page Tag
6.93.4. Creating the Component Dynamically Using Java
6.93.5. Details of Usage
6.93.6. Built-In Drag and Drop
6.93.7. Events handling
6.93.8. Facets
6.93.9. Look-and-Feel Customization
6.93.10. Skin Parameters Redefinition:
6.93.11. Definition of Custom Style Classes
6.93.12. Relevant Resources Links
+6.94. < rich:treeNode >
6.94.1. Description
6.94.2. Key Features
6.94.3. Creating the Component with a Page Tag
6.94.4. Creating the Component Dynamically Using Java
6.94.5. Details of Usage
6.94.6. Built-in Drag and Drop
6.94.7. Events Handling
6.94.8. Facets
6.94.9. Look-and-Feel Customization
6.94.10. Skin Parameters Redefinition
6.94.11. Definition of Custom Style Classes
6.94.12. Relevant Resources Links
+6.95. < rich:changeExpandListener >
6.95.1. Description
6.95.2. Key Features
6.95.3. Creating the Component with a Page Tag
6.95.4. Creating the Component Dynamically Using Java
6.95.5. Details of Usage
6.95.6. Look-and-Feel Customization
+6.96. < rich:nodeSelectListener >
6.96.1. Description
6.96.2. Key Features
6.96.3. Creating the Component with a Page Tag
6.96.4. Creating the Component Dynamically Using Java
6.96.5. Details of Usage
6.96.6. Look-and-Feel Customization
+6.97. < rich:recursiveTreeNodesAdaptor >
6.97.1. Description
6.97.2. Key Features
6.97.3. Creating the Component with a Page Tag
6.97.4. Creating the Component Dynamically Using Java
6.97.5. Details of Usage
6.97.6. Relevant resources links
+6.98. < rich:treeNodesAdaptor >
6.98.1. Description
6.98.2. Key Features
6.98.3. Creating the Component with a Page Tag
6.98.4. Creating the Component Dynamically Using Java
6.98.5. Details of Usage
6.98.6. Relevant Resources Links

The library encompasses ready-made components built based on the Rich Faces CDK .



Additional to the listeners provided by JSF specification, RichFaces add one more: ajax Listener ( <a4j:ajaxListener> ). Ajax Listener is invoked before the Render Response phase. Instead of <f:actionListener> of <f:valueChangeListener> which are not invoked when Validation of Update Model phases failed, ajax Listener is guarantied to be invoked for each Ajax response. Thus, it is a good place for update the list of re-rendered components, for example. Ajax Listener is not invoked for non-Ajax request and when RichFaces works in "Ajax Request generates Non-Ajax Response" mode. Therefore, ajax Listener invocation is a good indicator that Ajax response is going to be processed. Attribute "type" described in the following chapter. It defines the fully qualified Java class name for listener. This class implements org.ajax4jsf.event.AjaxListener interface. You can access to the source of the event (Ajax component) using java.util.EventObject.getSource() call.

Example:


...
<a4j:commandLink id="cLink" value="Click it To Send Ajax Request">
     <a4j:ajaxListener type="demo.Bean"/>
</a4j:commandLink>
...

Example:

package demo;


import org.ajax4jsf.event.AjaxEvent;
public class Bean implements org.ajax4jsf.event.AjaxListener{
... 
    public void processAjax(AjaxEvent arg){
        //Custom Developer Code 
    }
...
}


On the component LiveDemo page you can see the example of <a4j:keepAlive> usage and sources for the given example.

Some additional information about usage of component can be found on theAjax4JSF Users Forum.



On the component LiveDemo page you can see the example of <a4j:actionparam> usage and sources for the given example.

More information can be found on the Ajax4jsf Users Forum.

Table 6.7. a4j : commandButton attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
altAlternate textual description of the element rendered by this component.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledIf "true", disable this component on page.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now.
imageAbsolute or relative URL of the image to be displayed for this button. If specified, this "input" element will be of type "image". Otherwise, it will be of the type specified by the "type" property with a label specified by the "value" property.
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
sizeThis attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
timeoutTimeout ( in ms ) for request.
titleAdvisory title information about markup elements generated for this component
typeThis attribute specifies a type of control to create. The possible values are "submit", "reset", "image" and "button". The default value for this attribute is "submit"
valueThe current value for this component


<a4j:commandButton> is used in the same way as <h:commandButton> , but with definition of the area that is updated after the response comes back from the server.

This definition of the component provides a link, a click on the link causes an Ajax form submit on the server, action1 method performance, and rendering of the component with someData id after the response comes back from the server.

The component <a4j:commandButton> placed on a page generates the following HTML code:


...
<input type="submit" onclick="A4J.AJAX.Submit(...request parameters);return false;" value="sort"/>
...

Hence, the utility method A4J.AJAX.Submit is called on a click, the method performs Ajax request as the <a4j:support> component

The usage of the keyword 'this' in JavaScript code in the "oncomplete" attribute depends on the location of <a4j:commandButton> . If the commandButton is situated outside the re-rendered region you can use keyword 'this' as in the following example:


...
<h:form id="form"> 
  <a4j:commandButton id="cbutton" action="director.rollCamera" onclick="this.disabled=true" oncomplete="this.disabled=false" /> 
</h:form>
...

Otherwise if the commandButton contained in re-rendered region the "oncomplete" attribute has a problem obtaining a reference of the commandButton object when using the keyword 'this'. In this case you can use the "oncomplete" attribute as in the following example:


...
<h:form id="form"> 
     <a4j:commandButton id="cbutton" action="director.rollCamera" 
         onclick="this.disabled=true" 
         oncomplete="document.getElementById('form:cbutton').disabled=false" /> 
</h:form>
...

Common JSF navigation could be performed after an Ajax submit and partial rendering, but Navigation Case must be defined as <redirect/> in order to avoid problems with some browsers.

As any Core Ajax component sending Ajax requests and processing server responses <a4j:commandButton> has all attributes described above (see <a4j:support> chapter) that provide the required behavior of requests sending (delay, limitation of submit area and rendering, and etc.)

Information about the "process" attribute usage you can find " Decide what to process " guide section.

On the component LiveDemo page you can see the example of <a4j:commandButton> usage and sources for the given example.

Table 6.9. a4j : commandLink attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
charsetThe character encoding of a resource designated by this hyperlink
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledIf true, disable this component on page.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
shapeThis attribute specifies the shape of a region. The possible values are "default", "rect", "circle" and "poly".
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
timeoutTimeout ( in ms ) for request.
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
valueThe current value for this component


Vizit CommandLink demo page at RichFaces live demo for examples of component usage and their sources.

Useful articles:

Table 6.11. a4j : form attributes

Attribute NameDescription
acceptThis attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. User agents may use this information to filter out non-conforming files when prompting you to select files to be sent to the server (cf. the INPUT element when type="file")
acceptCharsetThis attribute specifies the list of character encodings for input data that is accepted by the server processing this form. The value is a space- and/or comma-delimited list of charset values. The client must interpret this list as an exclusive-or list, i.e., the server is able to accept any single character encoding per entity received. The default value for this attribute is the reserved string "UNKNOWN". User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
ajaxSubmitIf "true", it becomes possible to set AJAX submission way for any components inside .
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enctypeThis attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file"
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onresetHTML: script expression; a form is reseted. It only applies to the FORM element
onsubmitHTML: script expression; a form is submitted. It only applies to the FORM element
prependIdThe flag indicating whether or not this form should prepend its id to its descendent id during the clientId generation process. If this flag is not set, the default value is "true".
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
timeoutTimeout ( in ms ) for request.


The difference with the original component is that all hidden fields required for command links are always rendered and it doesn't depend on links rendering on the initial page. It solves the problem with invalid links that weren't rendered on a page immediately, but after some Ajax request.

Beginning with release 1.0.5 additional attributes that make this form variant universal have appeared.

If "ajaxSubmit" attribute is true, it becomes possible to set Ajax submission way for any components inside with the help of the javascript A4J.AJAX.Submit(...)call. In this case, the "reRender" attribute contains a list of Ids of components defined for re-rendering. If you have <h:commandButton> or <h:commandLink> inside the form, they work as <a4j:commandButton> .

Example:


<a4j:form id="helloForm" ajaxSubmit="true" reRender="table">
    ...
    <t:dataTable id="table"... >
        ...
    </t:dataTable>
    ...
    <t:datascroller for="table"... >
        ...
    </t:datascroller>
    ...
</a4j:form>

This example shows that in order to make <t:datascroller> submissions to be Ajax ones it's required only to place this <t:datascroller> into <a4j:form> . In the other case it is necessary to redefine renders for its child links elements that are defined as <h:commandLink> and can't be made Ajax ones with using e.g. <a4j:support> .

With the help of "limitToList" attribute you can limit areas, which are updated after the responses. If "limitToList" is true, only the reRender attribute is taken in account. Therefore, if you use blocks of text wrapped with <a4j:outputPanel> and ajaxRendered= "true", blocks of text are ignored.

Information about the "process" attribute usage you can find in the "Decide what to process" guide section.

On the component LiveDemo page you can see the example of <a4j:form> usage and sources for the given example.

Table 6.13. a4j : htmlCommandLink attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
charsetThe character encoding of a resource designated by this hyperlink
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledWhen set for a form control, this boolean attribute disables the control for your input.
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
idEvery component may have a unique id that is automatically created if omitted
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
shapeThis attribute specifies the shape of a region. The possible values are "default", "rect", "circle" and "poly".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
valueThe current value for this component


On RichFaces LiveDemo page you can found some additional information for <a4j:htmlCommandLink> component usage.

On RichFaces LiveDemo page you can found some additional information about <f:param> component.

Table 6.15. a4j : jsFunction attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
nameName of generated JavaScript function definition
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted


As the component uses Ajax request to get data from server - it has all common Ajax Action attributes. Hence, "action" and "actionListener" can be invoked, and reRendering some parts of the page fired after calling function.

When using the <a4j:jsFunction> it's possible to initiate the Ajax request from the JavaScript and perform partial update of a page and/or invoke the JavaScript function with data returned by Ajax response.


...
<body onload="callScript()">
    ...
    <h:form>
      ...
        <a4j:jsFunction name="callScript" data="#{bean.someProperty1}"
            reRender="someComponent" oncomplete="myScript(data.subProperty1, data.subProperty2)">
             <a4j:actionparam name="param_name" assignTo="#{bean.someProperty2}"/>
        </a4j:jsFunction>
        ...
    </h:form>
    ...
</body>
...

The <a4j:jsFunction> allows to use <a4j:actionparam> or pure <f:param> for passing any number of parameters of the JavaScript function into Ajax request. <a4j:jsFunction> is similar to <a4j:commandButton> , but it could be activated from the JavaScript code. It allows to invoke some server side functionality and use the returned data in the JavaScript function invoked from "oncomplete" attribute. Hence it's possible to use <a4j:jsFunction> instead of <a4j:commandButton> . You can put it anywhere, just don't forget to use <h:form> ... </h:form> around it.

Information about the "process" attribute usage you can find " Decide what to process " guide section.

Here you can find additional information and example on how to use <a4j:jsFunction> with JSON.

On the component Live Demo page you can see the example of <a4j:jsFunction> usage and sources for the given example.

On RichFaces LiveDemo page you can found some additional information about <f:param> component.

Table 6.17. a4j : include attributes

Attribute NameDescription
ajaxRenderedDefines, whether the content of this component must be (or not) included in AJAX response created by parent AJAX Container, even if it is not forced by reRender list of ajax action. Ignored if component marked to output by some Ajax action component. Default value is "true".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
idEvery component may have a unique id that is automatically created if omitted
keepTransientFlag for mark all child components to non-transient. If true, all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content ( By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing ).
langCode describing the language used in the generated markup for this component
layoutHTML layout for generated markup. Possible values: "block" for generating an HTML <div> element, "inline" for generating an HTML <span> element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty <span> element with same ID as the child element to use as a placeholder for later processing. Default value is "inline"
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
viewIdviewId for included page.


On the component LiveDemo page you can see the example of <a4j:include> usage and sources for the given example.

Some additional information can be found on the Ajax4Jsf Users Forum.



On RichFaces LiveDemo page you can found some additional information for <a4j:loadBundle> component usage.

On RichFaces LiveDemo page you can found some additional information about <f:loadBundle> component.

On RichFaces LiveDemo page you can found some additional information about <f:view> component.



As it was mentioned above this component returns its value as the value of the "src" attribute passing it to the getResourceURL() method of the ViewHandler for this application, and passing the result through the encodeResourceURL() method of the ExternalContext.

It means that the Context is inserts automatically to the link. And calls like resource:// is properly handled.

Except this - you may be free to put your script links right from the child page while using facelets templates.

On the component LiveDemo page you can see the example of <a4j:loadScript> usage and sources for the given example.



As it was mentioned above this component returns its value as the value of the "src" attribute passing it to the getResourceURL() method of the ViewHandler for this application, and passing the result via the encodeResourceURL() method of the ExternalContext.

It means that the Context is inserted automatically to the link. And calls like resource:// is properly handled.

Except this - you may be free to put your stylesheet links right from the child page while using facelets templates.

Table 6.25. a4j : log attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
heightHeight of pop-up. Default value is "600".
hotkeyKeyboard key for activate ( in combination with CTRL+SHIFT ) log window. Default value is "L"
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
levelLog level. The possible values are "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "ALL". Component sets level 'ALL' by default.
nameName of pop-up window. Default value is "LogWindow"
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
popupRenders log as pop-up window or as div element on the page. Default value is "true".
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
widthWidth of pop-up. Default value is "800".


On the component LiveDemo page you can see the example of <a4j:log> usage and sources for the given example.

Table 6.27. a4j : mediaOutput attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
alignDeprecated. This attribute specifies the position of an IMG, OBJECT, or APPLET with respect to its context. The possible values are "bottom", "middle", "top", "left" and "right". The default value is "middle".
archivespace-separated list of URIs
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderDeprecated. This attribute specifies the width of an IMG or OBJECT border, in pixels. The default value for this attribute depends on the user agent
cacheableIf "true", the resource is cached (on the server and the client sides).
charsetThe character encoding of a resource designated by this hyperlink
classididentifies an implementation
codebasebase URI for classid, data, archive
codetypecontent type for code
converterID of a converter to be used or a reference to a converter.
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
createContentMethod call expression to send generated resource to OutputStream. It must have two parameter with a type of java.io.OutputStream and java.lang.Object ( deserialized value of data attribute )
createContentExpressionMethod call expression to send generated resource to OutputStream. It must have two parameter with a type of java.io.OutputStream and java.lang.Object ( deserialized value of data attribute )
declaredeclare but don't instantiate flag
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
elementName of html element for resource link - may be <a> <img> <object> <applet> <script> or <link>
expiresThe attribute allows to manage caching and defines the period after which a resource is reloaded.
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
hspaceDeprecated. This attribute specifies the amount of white space to be inserted to the left and right of an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
idEvery component may have a unique id that is automatically created if omitted
ismapuse server-side image map
langCode describing the language used in the generated markup for this component
lastModifiedThe attribute allows to manage caching. A browser can send request with the header "If-Modified-Since" for necessity of object reloading. If time of modification is earlier, then the framework doesn't call generation and return code 304.
mimeTypeGeterated content mime-type for append to response header ( 'image/jpeg' etc )
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
sessionIf "true", a session for an object generation is restored.
shapeThis attribute specifies the shape of a region. The possible values are "default", "rect", "circle" and "poly".
standbymessage to show while loading
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
uriAttributeName of attribute for resource-link attribute ( 'href' for <a>, 'src' for <img> or <script>, etc)
usemapuse client-side image map
valueData value calculated at render time and stored in URI (also as part of cache Key ), at generation time passed to send method. Can be used for update cache at change of generating conditions, and for creating beans as "Lightweight" pattern components (request scope). IMPORTANT: Since serialized data stored in URI, avoid using big objects.
vspaceDeprecated. This attribute specifies the amount of white space to be inserted above and below an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length


On the component LiveDemo page you can see the example of <a4j:mediaOutput > usage and sources for the given example.

Table 6.29. a4j : outputPanel attributes

Attribute NameDescription
ajaxRenderedDefines, whether the content of this component must be (or not) included in AJAX response created by parent AJAX Container, even if it is not forced by reRender list of ajax action. Ignored if component marked to output by some Ajax action component. Default value is "false".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
idEvery component may have a unique id that is automatically created if omitted
keepTransientFlag to mark all child components to non-transient. If true, all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content ( By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing ). Default value is "true"
langCode describing the language used in the generated markup for this component
layoutHTML layout for generated markup. Possible values: "block" for generating an HTML <div> element, "inline" for generating an HTML <span> element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty <span> element with same ID as the child element to use as a placeholder for later processing. Default value is "inline"
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component


<a4j:outputPanel> allows marking of a page area, which is updated on Ajax response. Anyway, <a4j:outputPanel> usage is optional, as in RichFaces it's possible to indicate any existing component id on a component view in order to define updating areas. To speed up the performance, RichFaces updates only a component tree. <a4j:outputPanel> usage is recommended for wrapping components that aren't rendered during the primary non-ajax response, as the components don't present in a component tree.

Example:


<a4j:support ... reRender="mypanel"/>
...
<a4j:outputPanel id="mypanel">
    <h:panelGrid rendered="#{not empty foo.bar}">
        ...
    </h:panelGrid>
</a4j:outputPanel>

In addition to the areas directly indicated in "reRender" attribute of Ajax components, <a4j:outputPanel> allows to update a part of a page basing on its own flag. The flag is defined by the "ajaxRendered" attribute. The flag is commonly used when a part of a page must be updated or can be updated on any response.

Example:


<a4j:outputPanel ajaxRendered="true">
    <h:messages/>
</a4j:outputPanel>

On default <a4j:outputPanel> is output as a pair of opening and closing html <span> tag, but with the help of the layout attribute this output way could be changed. There are three variants for this component value:

If layout="block" is chosen, the component is rendered as a pair of opening and closing <div> tag, to which it's possible to apply any available style attributes available for block tags.

layout ="none" helps to avoid an unnecessary tag round a context that could or couldn't be rendered according to the defined "rendered" attribute conditions. If an inner context isn't rendered, <a4j:outputPanel> is rendered as a <span> tag with the id equal to an id of a child component and display:none style. If a child component is rendered, <a4j:outputPanel> doesn't present at all in a final code.

Example:


<a4j:support .... reRender="mypanel"/>
...
<a4j:outputPanel layout="none">
    <h:panelGrid id="mypanel" rendered="#{not empty foo.bar}">
        ...
    </h:panelGrid>
</a4j:outputPanel>

As you see, the code is very similar to the one shown above, but "reRender " attribute refers directly to the updating panelGrid and not to the framing outputPanel, and it's more semantically correct.

<a4j:outPanel> should be used for non-JSF component part framing, which is to be updated on Ajax response, as RichFaces specifies the list of updating areas as a list of an existing JSF component.

On default non-JSF context isn't saved in a component tree, but is rendered anew every time. To accelerate the processing speed and Ajax response input speed, RichFaces saves non-JSF context in a component tree on default. This option could be canceled by "keepTransient" attribute that cancels transient flag forced setting for child components. This flag setting keeps the current value set by child components.

RichFaces allows setting Ajax responses rendering directly basing on component tree nodes without referring to the JSP (XHTML) page code. It could be defined by "selfRendered" attribute setting to "true" on <a4j:region> and could help considerably speed up a response output. However, if a transient flag is kept as it is, this rapid processing could cause missing of transient components that present on view and don't come into a component tree. Hence, for any particular case you could choose a way for you application optimization: speed up processing or redundant memory for keeping tree part earlier defined a transient.

Here you can see the example of <a4j:outputPanel> usage and sources for the given example.

Some additional information about usage of component can be found on the Ajax4JSF Users Forum

See how the <a4j:outputPanel> component can be used in the Ajax Input form with detection of Old/New Values example in the RichFaces cookbook.

Table 6.31. a4j : page attributes

Attribute NameDescription
ajaxListenerMethodExpression representing an action listener method that will be notified when this component is activated by the ajax Request and handle it. The expression must evaluate to a public method that takes an AjaxEvent parameter, with a return type of void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentTypeSet custom mime content type to response
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
formatPage layout format ( html, xhtml, html-transitional, html-3.2 ) for encoding DOCTYPE, namespace and Content-Type definitions
idEvery component may have a unique id that is automatically created if omitted
immediateFlag indicating that, if this component is activated by ajaxrequest, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase
langCode describing the language used in the generated markup for this component
namespaceSet html element default namespace
onloadJavaScript code to execute on a page load.
onunloadJavaScript code to execute on a page unload.
pageTitleString for output as a page title.
renderedIf "false", this component is not rendered
selfRenderedif "true", self-render subtree at InvokeApplication ( or Decode, if immediate property set to true ) phase
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component


The component is mostly used to solve the following problem with MyFaces for erlier Ajax4jsf versions: in MyFaces <f:view> doesn't get control over the RENDER_RESPONSE phase, thus Ajax can't get control and make a response also. To avoid this problem it was necessary to use <a4j:page> on a page round the Ajax updatable area. In the last versions of both frameworks the problem is successfully fixed and no <a4j:page> usage is required.

The component is rendered as a full HTML page template as it is shown in the example. The head section is defined with the help of the corresponding "head" facet. You do not need to use "body" facet in order to define first body section. The second and more body sections is defined with the help of the corresponding "body" facet.

The attribute "format" defines page layout format for encoding DOCTYPE.

The attribute "pageTitle" is rendered as title section.

Example:


<a4j:page format="xhtml" pageTitle="myPage">
    <f:facet name="head">
        <!--Head Content here-->
    </f:facet>
   <!--Page Content Here-->
</a4j:page>

This structure is rendered as:

Example:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head> 
        <title>myPage</title>
        <!--Head Content here-->
    </head> 
    <body>
        <!--Page Content Here-->
    </body> 
</html>

On RichFaces LiveDemo page you can found some additional information for <a4j:page> component usage.

Table 6.34. a4j : poll attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enabledEnables/disables polling. Default value is "true".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
intervalInterval (in ms) for call poll requests. Default value is "1000"ms (1 second).
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onsubmitJavaScript code for call before submission of ajax event
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request


The <a4j:poll> componet is used for periodical polling of server data. In order to use the component it's necessary to set an update interval. The "interval" attribute defines an interval in milliseconds between the previous response and the next request. The total period beetween two requests generated by the <a4j:poll> component is a sum of an "interval" attribute value and server response time. Default value for "interval" attribute is set to "1000" milliseconds (1 second). See an example of definition in the "Creating on a page" section.

The "timeout" attribute defines response waiting time in milliseconds. If a response isn't received during this period a connection is aborted and the next request is sent. Default value for "timeout" attribute isn't set.

The "enabled" attribute defines should the <a4j:poll> send request or not. It's necessary to render the <a4j:poll> to apply the current value of "enabled" attribute. You can use an EL-expression for "enabled" attribute to point to a bean property. An example of usage of mentioned above attributes is placed below:

Example:


...
<a4j:region>
      <h:form>
            <a4j:poll id="poll" interval="1000" enabled="#{userBean.pollEnabled}" reRender="poll,grid"/>
      </h:form>
</a4j:region>
<h:form>
      <h:panelGrid columns="2" width="80%" id="grid">
           <h:panelGrid columns="1">
                <h:outputText value="Polling Inactive" rendered="#{not userBean.pollEnabled}" />
                <h:outputText value="Polling Active" rendered="#{userBean.pollEnabled}" />
                <a4j:commandButton style="width:120px" id="control"
                         value="#{userBean.pollEnabled?'Stop':'Start'} Polling"
                         reRender="poll, grid">
                     <a4j:actionparam name="polling" value="#{!userBean.pollEnabled}"
                          assignTo="#{userBean.pollEnabled}"/>
                </a4j:commandButton>
          </h:panelGrid>
          <h:outputText id="serverDate" style="font-size:16px" value="Server Date: #{userBean.date}"/>
    </h:panelGrid>
</h:form>
...

The example shows how date and time are updated on a page in compliance with data taken from a server. The <a4j:poll> componet sends requests to the server every second. "reRender" attribute for <a4j:poll> contains value of its own Id. Hence, it renders itself for applying the current value of "enabled" attribute.

Note:

The form around the <a4j:poll> component is required.

Note:

To make the <a4j:poll> component send requests periodically when it limitToList is set to "true", pass the <a4j:poll> ID to it reRender attribute.

Information about the "process" attribute usage you can find " Decide what to process " guide section.

Here you can get additional information how to create an image banner using <rich:effect> and <a4j:poll> components and here how to create a HTML banner.

Here you can find information how to make a Slide Show with help of the <rich:effect> and <a4j:poll> components.

Here you can see the example of <a4j:poll> usage and sources for the given example.

The aditional information about component usage you can find here : RichFaces Users Forum .



On RichFaces LiveDemo page you can found some additional information for <a4j:portlet> component usage.

The aditional information about component usage you can find here: Ajax4Jsf Users Forum.

Portlet Sample could be checked out from JBoss SVN: portal-echo application.

Usage instructions for this demo could be found at the corresponding: portal-echo application.

Table 6.38. a4j : push attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enabledEnables/disables pushing. Default value is "true".
eventProducerMethodBinding pointing at method accepting an PushEventListener with return type void. User bean must register this listener and send EventObject to this listener on ready.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
intervalInterval (in ms) for call push requests. Default value is "1000"ms (1 second).
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request


The <a4j:push> implements reverse Ajax technique.

The bean, for example, could be subscribed to Java Messaging Service (JMS) topic or it could be implemented as Message Driven Bean (MDB) in order to send a message to the <a4j:push> component about an event presence. In the presence of the event some action occurs.

Thus, a work paradigm with the <a4j:push> component corresponds to an anisochronous model, but not to pools as for <a4j:poll> component. See the simplest example below:

Example:

...

class MyPushEventListener implements PushEventListener {
    public void onEvent(EventObject evt) {
        System.out.println(evt.getSource());
            //Some action
    }
}    
...

Code for EventListener registration in the bean is placed below:

Example:

...

public void addListener(EventListener listener) {
synchronized (listener) {
                  if (this.listener != listener) {
                            this.listener = (PushEventListener) listener;
                  }
          }
}
...

A page code for this example is placed below.

Example:


...
<a4j:status startText="in progress" stopText="done"/>
     <a4j:form>
          <a4j:region>
                <a4j:push reRender="msg" eventProducer="#{pushBean.addListener}" interval="2000"/>
          </a4j:region>
          <a4j:outputPanel id="msg" >
                    <h:outputText value="#{pushBean.date}">
                         <f:convertDateTime type="time"/>
                    </h:outputText>
         </a4j:outputPanel>
         <a4j:commandButton value="Push!!" action="#{pushBean.push}" ajaxSingle="true"/>
</a4j:form>
...

The example shows how date is updated on a page in compliance with data taken from a server. In the example "interval" attribute has value "2000". This attribute defines an interval in milliseconds between the previous response and the next request. Default value is set to "1000" milliseconds (1 second). It's possible to set value equal to "0". In this case connection is permanent.

The "timeout" attribute defines response waiting time in milliseconds. If a response isn't received during this period a connection is aborted and the next request is sent. Default value for "timeout" attribute isn't set. Usage of "interval" and "timeout" attributes gives an opportunity to set short polls of queue state or long connections.

Note:

The form around the <a4j:push> component is required.

Information about the "process" attribute usage you can find " Decide what to process " guide section.

On RichFaces LiveDemo page you can found some additional information for <a4j:push> component usage.

Table 6.40. a4j : queue attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
disabledIf "true", disables this component on page.
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows you to ignore an Ajax response produced by a request if the newest 'similar' request is in the queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows avoiding unnecessary updates on the client side if the response isn't actual now
nameSpecifies to name for the named queue.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onerrorHTML: a script expression; event fires whenever an JavaScript server side error occurs
onrequestdequeueJavaScript code for call after the request has removed from the queue
onrequestqueueJavaScript code for call after the request has got into the queue
onsizeexceededA script expression; a size is exceed
onsubmitJavaScript code for call before submission of an ajax request
requestDelayAttribute defines the time (in ms) the request will be waiting in the queue before it is ready to be sent.
sizeDefines the number of requests allowed in the queue at one time.
sizeExceededBehaviorDefines the strategies of the queue's behavior if the number of the requests waiting in the queue is exceeded. There are four strategies: dropNext (by default), dropNew, fireNext , fireNew.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutWaiting time for response on a particular request. If no response is received during this time, the request is aborted


This is how you can create a form based queue. All other types of the queue are described in the "Queue Principles" section.

Example:


<h:form>
    <a4j:queue />
    <h:inputText value="#{bean.a}">
        <a4j:support event="onkeyup" />
    </h:inputText>
</h:form>

As it was said earlier the queue implemented in Richfaces has 4 types. In this section we will take a closer look at the form based queue. All other types of queue are similar is usage(except for the "global queue") but different is their scope.

In order to disable or enable the <a4j:queue> component on the page you can use the "disabled" attribute.

The "requestDelay" attribute defines delay time for all the requests fired by the action components.

The "size" attribute specifies the number of request that can be stored in the queue at a time. The attribute can help you prevent overloading of a sever with requests. You can also determine the type of behaviour when the size of the queue is exceeded.

You should use the "sizeExceededBehavior" for the purpose.

The "sizeExceededBehavior" attribute can set 4 the strategies of the queue's behavior if the number of the requests waiting in the queue is exceeded:

Example:


...
<h:form>
    <a4j:queue size="2" requestDelay="500" sizeExceededBehavior="dropNext" onsizeexceeded="alert('The size of the queue is exceeded')" />
    <h:inputText value="#{bean.a}">
        <a4j:support event="onkeyup" />
    </h:inputText>
    <h:inputText value="#{bean.b}">
        <a4j:support event="onblur" />
    </h:inputText>
    <h:selectBooleanCheckbox value="#{bean.check}" id="checkboxID">
        <a4j:support id="checkboxSupport" event="onchange" />
    </h:selectBooleanCheckbox>
</h:form>
...

In this example if the queue has more than 2 requests waiting to be processed the next event will be dropped and a message (the "onsizeexceeded" attribute fires a JavaScript function ) saying that the queues is exceeded will be displayed.

The "ignoreDupResponses" attribute that takes a boolean value can also help optimize your Ajax requests. The idea of the attribute is to cancel similar events and send the latest one to the server. This works only if similar events come sequentially.

Example:


...
<h:form>
    <a4j:queue requestDelay="500" ignoreDupResponses="true" />
    <h:inputText value="#{bean.a}">
        <a4j:support event="onkeyup" />
    </h:inputText>
</h:form>
...

In this example, the requests are glued together and only the last one is submitted.

Another key attribute that easies revers load is "timeout" . The attribute specifies the amount of time an item can be in the queue before the sent event is be aborted and dropped from the queue.

If the request is sent and response is not returned within the time frame defined in this attribute - the request is aborted, and the next one is sent.

Example:


...
<h:form>
    <a4j:queue timeout="1000" />
    <h:inputText value="#{bean.a}" >
        <a4j:support event="onkeyup" />
    </h:inputText>
</h:form>
...

In this case if the sever doesn't respond within a second the request will be aborted.

As you can see the implementation of the queue provides some custom event handlers that you may use to call JavaScript functions.

The "oncomplete" is fired after request completed.

In this event handler request object is be passed as a parameter. Thus queue is be accessible using request.queue. And the element which was a source of the request is available using this.

Example:


...
<h:form  >
    <a4j:queue oncomplete="alert(request.queue.getSize())" requestDelay="1000" />
    <h:inputText value="#{bean.a}">
        <a4j:support event="onkeyup" />
    </h:inputText>
    <h:selectBooleanCheckbox value="#{bean.check}">
        <a4j:support event="onchange"/>
    </h:selectBooleanCheckbox>
</h:form>
...

In this example you can see how the number of requests waiting in the queue change. You will get a message with the number of the requests in the queue.

The "onbeforedomupdate" event handler called before updating DOM on a client side.

The "onrequestqueue" event handler called after the new request has been added to queue. And the "onrequestdequeue" event handler called after the request has been removed from queue.

The "onsubmit" event handler called after request is completed. This attribute allows to invoke JavaScript code before an Ajax request is sent.

On the component LiveDemo page you can see the example of <a4j:queue> usage and sources for the given example.

General queue principals are documented in the "Queue Principles" section.



The region is a component used for manipulation with components sent to the server. It sets particular processing parameters for an area on the server, i.e. the region deals with data input on the server and has no direct impact on output. To read more on the components responsible for out, see "reference" here.

The region marks an area page that is decoded on the server. In most cases it is not necessary to use the region, as ViewRoot is a default region. This component helps to reduce data quantity processed by the server, but the region doesn't influence on the standard submission rules. It means that:

  • The area that is to be submitted onto the server should be embedded in <h:form>/<a4j:form> component.

  • The whole form is submitted on Ajax response and not a region that request is performed from.

Example:


<h:form id="form1">
      <a4j:region>
            <a4j:commandLink reRender="someID" value="Link" id="link1"/>
            <!--..Some content that will be decoded on server after Ajax request.-->
        </a4j:region>
<h:form>

Hence, the <a4j:commandLink> request generation causes full form1 form submission onto the server, the only difference is that a component tree part decoded on the serve is the part included into the region.

The regions could be nested in any order, the server picks out and decodes only the region, which contains a particular component that sends a request.

Example:


<a4j:region>
      <a4j:commandLink reRender="someID" value="Link" id="link1"/>
      <a4j:region>
          <a4j:commandLink reRender="someID" value="Link" id="link2"/>
          <!--..Some content that will be decoded on server after Ajax request.-->
      </a4j:region >
      <!--..Some content that will be decoded on server after Ajax request.-->
</a4j:region >

Therefore, the external region is decoded for the "link1" and the internal one is decoded for the "link2".

RichFaces allows setting Ajax responses rendering directly basing on component tree nodes without referring to the JSP (XHTML) page code. It could be defined by "selfRendered" attribute setting to "true" on <a4j:region> and could help considerably speed up a response output. However, this rapid processing could cause missing of transient components that present on view and don't come into a component tree as well as omitting of <a4j:outputPanel> usage described below.

Example:


<a4j:region selfRendered ="true">
      <a4j:commandLink reRender="someID" value="Link" id="link1"/>
      <!--..Some content with HTML used ("br","h1" and other tags used)-->
</a4j:region >

In this case, the processing is quicker and going on without referring to a page code, but the HTML code that isn't saved in a component tree could be lost. Thus, this optimization should be very carefully performed and a usage of the additional components RichFaces ( <a4j:outputPanel> ) is required.

The processing could be also accelerated if a region decoded for the processing passes straight away into Encode. But to update some data out of the region or on another region, use the "renderRegionOnly" attribute set to "false" ("true" on default) to change this behaviour.

Example:


<a4j:region renderRegionOnly="true">
      <a4j:commandLink reRender="someID2" value="Link1" id="link1"/>
      <h:panelGroup id="someId1" />
</a4j:region>
<a4j:region renderRegionOnly="false">
      <a4j:commandLink reRender="someID1" value="Link2" id="link2"/>
        <h:panelGroup  id="someId1" />
</a4j:region>

This example shows that one of the regions is decoded when a link is used inside. Nevertheless, if after processing the "link1" is clicked, the first region passes into Encode as a root region and encode performance time is reduced. This optimization doesn't allow data update out of the region and should be implemented very carefully. The data out of the region described with renderRegionOnly="false" is updated successfully.

Starting from version 3.2.0 <a4j:region> can be used inside any iterative component (e.g. <rich:column> , <rich:scrollableDataTable> ) and just re-render the components from the same row without updating the whole table and without any additional listeners.

Example:


<rich:column>
       <a4j:region>
              <a4j:commandLink reRender="out"/>
       </a4j:region>
</rich:column>
<rich:column>
        <h:outputText id="out">
</rich:column>

Visit <a4j:region> demo page at RichFaces live demo for examples of component usage and their sources.

Useful articles:



The main difference of this component from iterative components of other libraries is a special "ajaxKeys" attribute. This attribute defines row keys that are updated after an Ajax request. As a result it becomes easier to update several child components separately without updating the whole page.


...
<table>
    <tbody>
        <a4j:repeat value="#{repeatBean.items}" var="item"
                    ajaxKeys="#{updateBean.updatedRow}">
            <tr>
                <td><h:outputText value="#{item.code}" id="item1" /></td>
                <td><h:outputText value="#{item.price}" id="item2" /></td>
            </tr>
        </a4j:repeat>
    </tbody>
</table>
...

One more benefit of this component is absence of strictly defined markup as JSF HTML DataTable and TOMAHAWK DataTable has, hence the components could be used more flexibly anywhere where it's necessary to output the results of selection from some collection.

The next example shows collection output as a plain HTML list:


<ul>
      <a4j:repeat ...>
        <li>...<li/>
                   ...
        <li>...<li/>
      </a4j:repeat>
</ul>

All other general attributes are defined according to the similar attributes of iterative components ( <h:dataTable> or <ui:repeat> ) and are used in the same way.

On the component LiveDemo page you can see the example of <a4j:repeat> usage and sources for the given example.

Table 6.47. a4j : status attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
forID of the AjaxContainer component whose status is indicated (in the format of a javax.faces.UIComopnent.findComponent() call).
forceIdIf true, render the ID of the component in HTML code without JSF modifications.
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
layoutDefine visual layout of panel, can be "block" or "inline".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onstartJavaScript code, called on the start of a request.
onstopJavaScript code, called on the stop of a request.
renderedIf "false", this component is not rendered
startStyleCSS style class for the element displayed on the start of a request.
startStyleClassCSS style class for the element displayed on the start of a request.
startTextText for display on starting request.
stopStyleCSS style for element displayed on request completion.
stopStyleClassCSS style class for element displayed on request
stopTextText for display on request complete.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component


There are two ways for the components or containers definition, which Ajax requests status is tracked by a component.

The component creates two <span> or <div> elements depending on attribute "layout" with content defined for each status, one of the elements (start) is initially hidden. At the beginning of an Ajax request, elements state is inversed, hence the second element is shown and the first is hidden. At the end of a response processing, elements display states return to its initial values.

Example:


<a4j:status startText="Started" stopText="stopped" />

The code shown in the example above is decoded on a page as:


<span id="j_id20:status.start" style="display: none">
      Started
</span>
<span id="j_id20:status.stop">
        Stopped
</span>

and after the generation of an Ajax response is changed to:


<span id="j_id20:status.start">
        Started
</span>
<span id="j_id20:status.stop" style="display: none">
        Stopped
</span>

There is a possibility to group a <a4j:status> elements content into <div> elements, instead of <span> . To use it, just redefine the "layout" attribute from "inline" (default) to "block".

Here you can find information on how to show a "Please Wait" box and block the input while the Ajax request is processed using combination of <a4j:status> and <rich:modalPanel> components .

On the component Live Demo page you can see the example of <a4j:status> usage and sources for the given example.

Table 6.50. a4j : support attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf "true", disable this component on page.
disableDefaultDisables default action for target event ( append "return false;" to JavaScript ). Default value is "false"
eventName of JavaScript event property ( onclick, onchange, etc.) of parent component, for which we will build AJAX submission code
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onsubmitJavaScript code for call before submission of ajax event
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutTimeout (in ms) for request


<a4j:support> addition is very similar to correspondent event redefinition of a component, i.e.

Example:


...
<h:inputText value="#{bean.text}">
    <a4j:support event="onkeyup" reRender="output" action="#{bean.action}"/>
</h:inputText>
...

Is decoded on a page as:

Example:



<input  onkeyup="A4J.AJAX.Submit( Some request parameters )"/>

As you see from the code, the "onkeyup" event calls a utility RichFaces method that submit a form creating a special marks for a filter informing that it is an Ajax request. Thus, any supports quantity could be added to every component, the supports define component behavior on these events.

With the help of "onsubmit" and "oncomplete" attributes the component allows using JavaScript before (for request sending conditions checking) and after an Ajax response processing termination (for performance of user-defined activities on the client)

Example:


<h:selectOneMenu value="#{bean.text}">
    <f:selectItem itemValue="First Item" itemLabel="First Item"/>
    <f:selectItem itemValue=" Second Item" itemLabel="Second Item"/>
    <f:selectItem itemValue=" Third Item" itemLabel="Third Item"/>
        <a4j:support event="onblur" reRender="panel" onsubmit="if(!confirm('Are you sure to change the option ?')) {form.reset(); return false;}" oncomplete="alert('Value succesfully stored')"/>
</h:selectOneMenu>

In example there is the condition checking (confirm) is used before request sending and message printing after the request processing is over.

The components allows different Ajax request managing ways for its various optimization in particular conditions such as:

Example 1:


<h:form>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" ajaxSingle="true"/>
    </h:inputText>
    <h:inputText value="#{person.middleName}"/>
</form>

In this example the request contains only the input component causes the request generation, not all the components contained on a form, because of ajaxSingle="true" usage.

Example 2:


<h:form>
    <a4j:outputPanel ajaxRendered="true">
        <h:messages/>
    </a4j:outputPanel>
    <h:inputText value="#{person.name}">
        <a4j:support event="onkeyup" reRender="test" limitToList="true"/>
    </h:inputText>
    <h:outputText value="#{person.name}" id="test"/>
</form>

In this example the component <h:messages> is always updated (as it capturing all Ajax requests, located in ajaxRendered <a4j:outputPanel> ), except the case when a response is sent from the input component from the example. On sending this component marks that updating area is limited to the defined in it components, it means that on its usage with limitToList="true" the only component updated is the one with id="test".

Information about the "process" attribute usage you can find in the "Decide what to process" guide section.

On the component LiveDemo page you can see the example of <a4j:support> usage and sources for the given example.

Table 6.52. rich : ajaxValidator attributes

Attribute NameDescription
ajaxListenerMethodExpression representing an action listener method that will be notified when this component is activated by the ajax Request and handle it. The expression must evaluate to a public method that takes an AjaxEvent parameter, with a return type of void. Default value is "null"
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefaultDisables default action for target event ( append "return false;" to JavaScript ). Default value is "false"
eventName of JavaScript event property ( onclick, onchange, etc.) of parent component by which validation will be triggered. Default value is "onblur"
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onsubmitJavaScript code for call before submission of ajax event
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
summarySummary message for a validation errors.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted


The <rich:ajaxValidator> component should be added as a child component to an input JSF tag which data should be validated and an event that triggers validation should be specified as well. The component is ajaxSingle by default so only the current field will be validated.

The following example demonstrates how the <rich:ajaxValidator> adds AJAX functionality to standard JSF validators. The request is sent when the input field loses focus, the action is determined by the "event" attribute that is set to "onblur".


...
<rich:panel>
       <f:facet name="header">
              <h:outputText value="User Info:" />
       </f:facet>
       <h:panelGrid columns="3">
              <h:outputText value="Name:" />
              <h:inputText value="#{userBean.name}" id="name" required="true">
                     <f:validateLength minimum="3" maximum="12"/>
                     <rich:ajaxValidator event="onblur"/>
              </h:inputText>
              <rich:message for="name" />
       </h:panelGrid>
</rich:panel>
...

This is the result of the snippet.


In the example above it's show how to work with standard JSF validators. The <rich:ajaxValidator> component also works perfectly with custom validators enhancing their usage with AJAX.

Custom validation can be performed in two ways:

The following example shows how the data entered by user can be validated using Hibernate Validator.


...
<rich:panel>
       <f:facet name="header">
              <h:outputText value="User Info:" />
       </f:facet>
       <h:panelGrid columns="3">
              <h:outputText value="Name:" />
              <h:inputText value="#{validationBean.name}" id="name" required="true">
                     <rich:ajaxValidator event="onblur" />
              </h:inputText>
              <rich:message for="name" />
       </h:panelGrid>
</rich:panel>
...

Here is the source code of the managed bean.

...

package org.richfaces.demo.validation;
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
public class ValidationBean {
    @NotEmpty
    @Length(min=3,max=12)
    private String name;
    @Email (message="wrong email format")
    @NotEmpty
    private String email;
        
    public ValidationBean() {
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
}
...

By default the Hibernate Validator generates an error message in 10 language, though you can redefine the messages that are displayed to a user when validation fails. In the shows example it was done by adding (message="wrong email format") to the @Email annotation.

This is how it looks.


On RichFaces LiveDemo page you can see an example of <rich:ajaxValidator> usage and sources for the given example.



The <rich:graphValidator> component behaves basically the same way as the <rich:beanValidator> The deference between these two components is that in order to validate some input data with a <rich:beanValidator> component, it should be a nested element of an input component, whereas <rich:graphValidator> wraps multiple input components and validates the data received from them.

The following example demonstrate a pattern of how the <rich:graphValidator> can be used.


...
<rich:graphValidator>
       <h:panelGrid columns="3">
              <h:outputText value="Name:" />
              <h:inputText value="#{validationBean.name}" id="name">
                     <f:validateLength minimum="2" />
              </h:inputText>
              <rich:message for="name" />
              <h:outputText value="Email:" />
              <h:inputText value="#{validationBean.email}" id="email" />
              <rich:message for="email" />
       </h:panelGrid>
</rich:graphValidator>
...

The data validation can be also performed using Hibernate Validator, the same way as it is done with <rich:beanValidator> .

The components's architecture provides an option to bind the component to a managed bean, which is done with the <value> attribute. The attribute ensures that the entered data is valid after the model is updated by revalidating the bean properties.

Please look at the example below.


...
<rich:graphValidator summary="Invalid values: " value="#{dayStatistics}">
          <a4j:repeat value="#{dayStatistics.dayPasstimes}" var="pt" id="table">
                    <h:outputText value="#{pt.title}" />
                    <rich:inputNumberSpinner minValue="0" maxValue="24" value="#{pt.time}" id="time" />
                    <rich:message for="time" />
          </a4j:repeat>
</rich:graphValidator>
...

Hence, the given above code will provide the functionality that is illustrated on the images below.


As you can see from the picture the "Games" field did not pass validation, as <rich:graphValidator> can be used to perform validation of a single input item.


The figure above shows that the entered data was revalidated after all fields were completed, and the data did not pass revalidation since the total sum was incorrect.

On RichFaces LiveDemo page you can see an example of <rich:graphValidator> usage and sources for the given example.



Starting from 3.2.2 GA version Rich Faces provides support for model-based constraints defined using Hibernate Validator. Thus it's possible to use Hibernate Validators the same as for Seam based applications.

The <rich:beanValidator> component is defined in the same way as any JSF validator. Look at the example below.


...
<rich:panel>
       <f:facet name="header">
              <h:outputText value="#{validationBean.progressString}" id="progress"/>
       </f:facet>
       <h:panelGrid columns="3">
              <h:outputText value="Name:" />
              <h:inputText value="#{validationBean.name}" id="name">
                     <rich:beanValidator summary="Invalid name"/>
              </h:inputText>
              <rich:message for="name" />
              <h:outputText value="Email:" />
              <h:inputText value="#{validationBean.email}" id="email">
                     <rich:beanValidator summary="Invalid email"/>
              </h:inputText>
              <rich:message for="email" />
              <f:facet name="footer">
                     <a4j:commandButton value="Submit" action="#{validationBean.success}" reRender="progress"/>
              </f:facet>
       </h:panelGrid>
</rich:panel>
...

Please play close attention on the bean code that contains the constraints defined with Hibernate annotation which perform validation of the input data.



package org.richfaces.demo.validation;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;
public class ValidationBean {
    @NotEmpty
    @Length(min=3,max=12)
    private String name;
    @Email
    @NotEmpty
    private String email;
    
    public ValidationBean() {
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
}

The following figure shows what happens if validation fails


As you can see from the example that in order to validate the <rich:beanValidator> should be nested into a input JSF or RichFaces component.

The component has the only attribute - "summary" which displays validation messages about validation errors.

On RichFaces LiveDemo page you can see an example of <rich:beanValidator> usage and sources for the given example.

Table 6.58. rich : calendar attributes

Attribute NameDescription
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only. Default value is "true"
bindingThe attribute takes a value-binding expression for a component property of a backing bean
boundaryDatesModeThis attribute is responsible for behaviour of dates from the previous and next months which are displayed in the current month. Valid values are "inactive" (Default) dates inactive and gray colored, "scroll" boundaries work as month scrolling controls, and "select" boundaries work in the same way as "scroll" but with the date clicked selection. Default value is "inactive".
buttonClassStyle Class attribute for the popup button
buttonIconDefines icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
buttonIconDisabledDefines disabled icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
buttonLabelDefines label for the popup button element. If the attribute is set "buttonIcon" and "buttonIconDisabled" are ignored
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
cellHeightattribute to set fixed cells height
cellWidthattribute to set fixed cells width
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
currentDateDefines current date
currentDateChangeListenerMethodExpression representing an action listener method that will be notified after date selection
dataModelUsed to provide data for calendar elements. If data is not provided, all Data Model related functions are disabled
datePatternDefines date pattern. Default value is "MMM d, yyyy".
dayStyleClassShould be binded to some JS function that will provide style classes for special sets of days highlighting.
defaultTimeDefines time that will be used: 1) to set time when the value is empty 2) to set time when date changes and flag "resetTimeOnDateSelect" is true. Default value is "getDefaultValueOfDefaultTime()"
directionDefines direction of the calendar popup ("top-left", "top-right", "bottom-left", "bottom-right" (Default), "auto"). Default value is "bottom-right".
disabledIf "true", rendered is disabled. In "popup" mode both controls are disabled. Default value is "false".
enableManualInputIf "true" calendar input will be editable and it will be possible to change the date manualy. If "false" value for this attribute makes a text field "read-only", so the value can be changed only from a handle. Default value is "false".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
firstWeekDayGets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France. Default value is "getDefaultFirstWeekDay()". Possible values should be integers from 0 to 6, 0 corresponds to Sunday
focusid of element to set focus after request completed on client side
horizontalOffsetSets the horizontal offset between button and calendar element conjunction point. Default value is "0".
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassStyle Class attribute for the text field
inputSizeDefines the size of an input field. Similar to the "size" attribute of <h:inputText/>
inputStyleStyle attribute for text field
isDayEnabledShould be binded to some JS function that returns day state.
jointPointSet the corner of the button for the popup to be connected with (top-left, top-right, bottom-left (Default), bottom-right, auto). Default value is "bottom-left".
labelA localized user presentable name for this component.
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
localeUsed for locale definition. Default value is "getDefaultLocale()".
minDaysInFirstWeekGets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1. If the minimal days required must be a full week, this method returns 7. Default value is "getDefaultMinDaysInFirstWeek()".
modeValid values: ajax or client. Default value is "client".
monthLabelsAttribute that allows to customize names of the months. Should accept list with the month names
monthLabelsShortAttribute that allows to customize short names of the months. Should accept list with the month names
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onchangedHTML: script expression; to invoke when date or time was changed and applied to input
oncollapseHTML: script expression; calendar was closed
oncompleteJavaScript code for call after request completed on client side
oncurrentdateselectHTML: script expression; to invoke before current month was changed
oncurrentdateselectedHTML: script expression; to invoke after current month was changed
ondatemouseoutHTML: a script expression; a pointer is moved away the date cell
ondatemouseoverHTML: script expression; to invoke when a pointer is moved to the date cell
ondateselectHTML: script expression; to invoke before some date cell was selected.
ondateselectedHTML: script expression; to invoke after some date cell selected.
onexpandHTML: script expression; calendar was opened
oninputblurHTML: script expression; the input field lost the focus
oninputchangeHTML: script expression; the input field is changed
oninputclickHTML: a script expression; the input field is clicked
oninputfocusHTML: script expression; the input field got the focus
oninputkeydownHTML: a script expression; a key for the input field is pressed down
oninputkeypressHTML: a script expression; a key for the input field is pressed and released
oninputkeyupHTML: a script expression; a key for the input field is released
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputselectHTML: script expression; the input field is selected
ontimeselectHTML: script expression; to invoke before new time was selected
ontimeselectedHTML: script expression; to invoke after time selected
popupIf "true" calendar will be rendered initially as hidden with additional elements for calling as popup. Default value is "true".
preloadDateRangeBeginDefine the initial range of date which will be loaded to client from dataModel under rendering. Default value is "getDefaultPreloadBegin(getCurrentDateOrDefault())".
preloadDateRangeEndDefines the last range of date which will be loaded to client from dataModel under rendering. Default value is "getDefaultPreloadEnd(getCurrentDateOrDefault())".
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
readonlyIf "true". Date and time are not selectable. In "popup" mode input is disabled and button is enabled. Default value is "false".
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
resetTimeOnDateSelectIf value is true then calendar should change time to defaultTime for newly-selected dates. Default value is "false"
showApplyButtonIf false ApplyButton should not be shown. Default value is "false".
showFooterIf false Calendar's footer should not be shown. Default value is "true".
showHeaderIf false Calendar's header should not be shown. Default value is "true".
showInput"false" value for this attribute makes text field invisible. It works only if popupMode="true" If showInput is "true" - input field will be shown. Default value is "true".
showWeekDaysBarIf false this bar should not be shown. Default value is "true".
showWeeksBarIf false this bar should not be shown. Default value is "true".
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
tabIndextabIndex
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
timeZoneUsed for current date calculations. Default value is "getDefaultTimeZone()".
todayControlModeThis attribute defines the mode for "today" control. Possible values are "scroll", "select", "hidden". Default value is "select".
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
verticalOffsetSets the vertical offset between button and calendar element conjunction point. Default value is "0".
weekDayLabelsList of the day names displays on the days bar in the following way "Sun, Mon, Tue, Wed, "
weekDayLabelsShortAttribute that allows to customize short names of the weeks. Should accept list with the weeks names.
zindexAttribute is similar to the standard HTML attribute and can specify window placement relative to the content. Default value is "3".


The "popup" attribute defines calendar representation mode on a page. If it's "true" the calendar is represented on a page as an input field and a button. Clicking on the button calls the calendar popup as it's shown on the picture below.


Usage "currentDate" attribute isn't available in the popup mode.

The "value" attribute stores selected date currently.

With help of the "currentDate" attribute you can define month and year which will be displayed currently.

The "todayControlMode" attribute defines the mode for "today" control. Possible values are:

  • "hidden" - in this mode "Today" button will not be displayed

  • "select" - (default) in this state "Today" button activation will scroll the calendar to the current date and it become selected date

  • "scroll" - in this mode "Today" activation will simply scroll the calendar to current month without changing selected day.

With the help of the "readonly" attribute you can make date, time and input field unavailable, but you can look through the next/previous month or the next/previous year.

In order to disable the component, use the "disabled" attribute. With its help both controls are disabled in the "popup" mode.


The <rich:calendar> component can render pages of days in two modes. A mode could be defined with the "mode" attribute with two possible parameters: "ajax" and "client". Default value is "client".

  • Ajax

Calendar requests portions of data from Data Model for a page rendering. If "dataModel" attribute has "null" value, data requests are not sent. In this case the "ajax" mode is equal to the "client".

  • Client

Calendar loads an initial portion of data in a specified range and use this data to render months. Additional data requests are not sent.

Note:

"preloadDateRangeBegin" and "preloadDateRangeEnd" attributes were designed only for the "client" mode to load some data initially.

"ondateselect" attribute is used to define an event that is triggered before date selection.

The "ondateselected" attribute is used to define an event that is triggered after date selection.

For example, to fire some event after date selection you should use <a4j:support> . And it should be bound to "ondateselected" event as it's shown in the example below:


...
<rich:calendar id="date" value="#{bean.dateTest}">
          <a4j:support event="ondateselected" reRender="mainTable"/>
</rich:calendar>
...

Note:

When a timePicker was fulfilled, the "ondateselected" attribute does not allow you to submit a selected date. It happens because this event rose when the date is selected but the input hasn't been updated with new value yet.

"ondateselect" could be used for possibility of date selection canceling. See an example below:


...
<rich:calendar id="date" value="#{bean.dateTest}" ondateselect="if (!confirm('Are you sure to change date?')){return false;}"/>
...

"oncurrentdateselected" event is fired when the "next/previous month" or "next/previous year" button is pressed, and the value is applied.

"oncurrentdateselect" event is fired when the "next/previous month" or "next/previous year" button is pressed, but the value is not applied yet (you can change the logic of applying the value). Also this event could be used for possibility of "next/previous month" or "next/previous year" selection canceling. See an example below:

Example:


...
<rich:calendar id="date" value="#{bean.dateTest}" oncurrentdateselect="if (!confirm('Are you sure to change month(year)?')){return false;}"
          oncurrentdateselected="alert('month(year) select:'+event.rich.date.toString());"/>
...

How to use these attributes see also on the RichFaces Users Forum.

Information about the "process" attribute usage you can find in the corresponding section .

There are three button-related attributes:

  • "buttonLabel" defines a label for the button. If the attribute is set "buttonIcon" and "buttonIconDisabled" are ignored

  • "buttonIcon" defines an icon for the button

  • "buttonIconDisabled" defines an icon for the disabled state of the button

The "direction" and "jointPoint" attributes are used for defining aspects of calendar appearance.

The possible values for the "direction" are:

  • "top-left" - a calendar drops to the top and left

  • "top-right" - a calendar drops to the top and right

  • "bottom-left" - a calendar drops to the bottom and left

  • "bottom-right" - a calendar drops to the bottom and right

  • "auto" - smart positioning activation

By default, the "direction" attribute is set to "bottom-right".

The possible values for the "jointPoint" are:

  • "top-left" - a calendar docked to the top-left point of the button element

  • "top-right" - a calendar docked to the top-right point of the button element

  • "bottom-left" - a calendar docked to the bottom-left point of the button element

  • "bottom-right" - a calendar docked to the bottom-right point of the button element

  • "auto" - smart positioning activation

By default, the "jointPoint" attribute is set to "bottom-left".

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM", {2} for "ShortConverter.SHORT".

The "defaultTime" attribute to set the default time value for the current date in two cases:

  • If time is not set

  • If another date is selected and the value of the "resetTimeOnDateSelect" attribute is set to "true"

The "enableManualInput" attribute enables/disables input field, so when enableManualInput = "false" , user can only pick the date manually and has no possibility to type in the date (default value is "false").

The <rich:calendar> component allows to use "header" , "footer" , "optionalHeader" , "optionalFooter" facets. The following elements are available in these facets: {currentMonthControl}, {nextMonthControl}, {nextYearControl}, {previousYearControl}, {previousMonthControl}, {todayControl}, {selectedDateControl}. These elements could be used for labels output.

Also you can use "weekNumber" facet with available {weekNumber}, {elementId} elements and "weekDay" facet with {weekDayLabel}, {weekDayLabelShort}, {weekDayNumber}, {isWeekend}, {elementId} elements. {weekNumber}, {weekDayLabel}, {weekDayLabelShort}, {weekDayNumber} elements could be used for labels output, {isWeekend}, {elementId} - for additional processing in JavaScript code.

These elements are shown on the picture below.


Simple example of usage is placed below.

Example:


...
<!-- Styles for cells -->
<style>
    
.width100{
        
width:100%;
    
}
    
.talign{
        
text-align:center;
    
}
</style>
 
...

...
<rich:calendar id="myCalendar" popup="true" locale="#{calendarBean.locale}" value="#{bean.date}"
                            preloadRangeBegin="#{bean.date}" preloadRangeEnd="#{bean.date}" cellWidth="40px" cellHeight="40px">

<!-- Customization with usage of facets and accessible elements -->
    <f:facet name="header">
        <h:panelGrid columns="2" width="100%" columnClasses="width100, fake">
            <h:outputText value="{selectedDateControl}" />
            <h:outputText value="{todayControl}"  style="font-weight:bold; text-align:left"/>
        </h:panelGrid>
    </f:facet>
    <f:facet name="weekDay">
        <h:panelGroup style="width:60px; overflow:hidden;" layout="block">
            <h:outputText value="{weekDayLabelShort}"/>
        </h:panelGroup>
    </f:facet>
    <f:facet name="weekNumber">
         <h:panelGroup>
            <h:outputText value="{weekNumber}" style="color:red"/>
        </h:panelGroup>
     </f:facet>
     <f:facet name="footer">
        <h:panelGrid columns="3" width="100%" columnClasses="fake, width100 talign">
            <h:outputText value="{previousMonthControl}" style="font-weight:bold;"/>
            <h:outputText value="{currentMonthControl}" style="font-weight:bold;"/>
            <h:outputText value="{nextMonthControl}" style="font-weight:bold;"/>
        </h:panelGrid>
    </f:facet>
    <h:outputText value="{day}"></h:outputText>
</rich:calendar>
...

This is a result:


As it's shown on the picture above {selectedDateControl}, {todayControl} elements are placed in the "header" facet, {previousMonthControl}, {currentMonthControl}, {nextMonthControl} - in the "footer" facet, {weekDayLabelShort} - in the "weekDay" facet, {nextYearControl}, {previousYearControl} are absent. Numbers of weeks are red colored.

It is possible to show and manage date. Except scrolling controls you can use quick month and year selection feature. It's necessary to click on its field, i.e. current month control, and choose required month and year.


Also the <rich:calendar> component allows to show and manage time. It's necessary to define time in a pattern (for example, it could be defined as "d/M/yy HH:mm"). Then after you choose some data in the calendar, it becomes possible to manage time for this date. For time editing it's necessary to click on its field (see a picture below). To clean the field click on the "Clean".


It's possible to handle events for calendar from JavaScript code. A simplest example of usage JavaScript API is placed below:

Example:


...
         <rich:calendar value="#{calendarBean.selectedDate}" id="calendarID"
                        locale="#{calendarBean.locale}"
                        popup="#{calendarBean.popup}"
                        datePattern="#{calendarBean.pattern}"
                        showApplyButton="#{calendarBean.showApply}" style="width:200px"/>
     <a4j:commandLink onclick="$('formID:calendarID').component.doExpand(event)" value="Expand"/>
...

Also the discussion about this problem can be found on the RichFaces Users Forum.

The <rich:calendar> component provides the possibility to use a special Data Model to define data for element rendering. Data Model includes two major interfaces:

CalendarDataModel provides the following function:

  • CalendarDataModelItem[] getData(Date[]);

This method is called when it's necessary to represent the next block of CalendarDataModelItem. It happens during navigation to the next (previous) month or in any other case when calendar renders. This method is called in "Ajax" mode when the calendar renders a new page.

CalendarDataModelItem provides the following function:

  • Date getDate() - returns date from the item. Default implementation returns date.

  • Boolean isEnabled() - returns "true" if date is "selectable" on the calendar. Default implementation returns "true".

  • String getStyleClass() - returns string appended to the style class for the date span. For example it could be "relevant holyday". It means that the class could be defined like the "rich-cal-day-relevant-holyday" one. Default implementation returns empty string.

  • Object getData() - returns any additional payload that must be JSON-serializable object. It could be used in the custom date representation on the calendar (inside the custom facet).

The <rich:calendar> component provides the possibility to use internationalization method to redefine and localize the labels. You could use application resource bundle and define RICH_CALENDAR_APPLY_LABEL, RICH_CALENDAR_TODAY_LABEL, RICH_CALENDAR_CLOSE_LABEL, RICH_CALENDAR_OK_LABEL, RICH_CALENDAR_CLEAN_LABEL, RICH_CALENDAR_CANCEL_LABEL there.

You could also pack org.richfaces.renderkit.calendar resource bundle with your JARs defining the same properties.

Note:

Only for Internet Explorer 6 and later. To make <rich:calendar> inside <rich:modalPanel> rendered properly, enable the standards-compliant mode. Explore !DOCTYPE reference at MSDN to find out how to do this.






















On the screenshot there are classes names that define styles for component elements.










In order to redefine styles for all <rich:calendar> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-calendar-today {
    
background-color: #FF0000;
}
...

This is a result:


In the example an active cell background color was changed.

Also it's possible to change styles of particular <rich:calendar> component. In this case you should create own style classes and use them in corresponding <rich:calendar> styleClass attributes. An example is placed below:

Example:


...
.myFontClass{
    
font-style: italic;
}
...

The "inputClass" attribute for <rich:calendar> is defined as it's shown in the example below:

Example:


<rich:calendar ... inputClass="myFontClass"/>

This is a result:


As it could be seen on the picture above, the font style for output text was changed.

On the component LiveDemo page you can see the example of <rich:calendar> usage and sources for the given example.

How to use JavaScript API see on the RichFaces Users Forum.

Table 6.88. rich : colorPicker attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
colorModeDefines a color mode for the component input. Possible values are hex, rgb.
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
flatDefines whether the component will be rendered flat.
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
onbeforeshow${prop.xmlEncodedDescription}
onchange${prop.xmlEncodedDescription}
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onhide${prop.xmlEncodedDescription}
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onshow${prop.xmlEncodedDescription}
onsubmit${prop.xmlEncodedDescription}
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
showEventDefines the event that triggers the colorPicker. Default value is "onclick".
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes


The <rich:colorPicker> component allows you easily select a color or define it in hex, RGB, or HSB input fields. There are two squares in the widget that help you to compare the currently selected color and the already selected color.

The "value" attribute stores the selected color.

The value of the <rich:colorPicker> component could be saved in hex or RGB color models. You can explicitly define a color model in the "colorMode" attribute.

Example:



...
<rich:colorPicker value="#{bean.color}" colorMode="rgb" />
...
        

This is the result:


The <rich:colorPicker> component has two representation states: flat and inline. With the help of the "flat" attribute you can define whether the component is rendered flat.

Example:



...
<rich:colorPicker value="#{bean.color}" flat="true" />
...
        

The "showEvent" attribute defines the event that shows <rich:colorPicker> widget. The default value is "onclick".

The <rich:colorPicker> component allows to use the "icon" facet.

You can also customize <rich:colorPicker> rainbow slider ( ) with the help of the "arrows" facet.



...
<rich:colorPicker value="#{bean.color}">
    <f:facet name="icon">
        <h:graphicImage value="/pages/colorPicker_ico.png" />
    </f:facet>
    <f:facet name="arrows">
        <f:verbatim>        
            <div style="width: 33px; height: 5px; border: 1px solid #bed6f8; background:none;" />
        </f:verbatim>
    </f:facet>
</rich:colorPicker>
...
        

This is the result:


On the screenshot there are classes names that define styles for component elements.





In order to redefine styles for all <rich:colorPicker> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-colorPicker-ext{
    
background-color: #ecf4fe;
}                     
...

This is the result:


In the shown example the background color for the widget is changed.

On the component LiveDemo page you can see the example of <rich:colorPicker> component usage and sources for the given example.

Table 6.98. rich : comboBox attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
buttonClassStyle Class attribute for the button
buttonDisabledClassStyle Class attribute for the disabled button
buttonDisabledStyleCSS style rules to be applied to disabled button
buttonIconDefines icon for the button element
buttonIconDisabledDefines disabled icon for the button element
buttonIconInactiveDefines inactive icon for the button element
buttonInactiveClassStyle Class attribute for the inactive button
buttonInactiveStyleCSS style rules to be applied to inactive button
buttonStyleCSS style rules to be applied to button
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
defaultLabelDefines default label for the input field element
directInputSuggestionsDefines the first value from the suggested in input field. Default value is "false".
disabledWhen set for a form control, this boolean attribute disables the control for your input
enableManualInputEnables keyboard input, if "false" keyboard input will be locked. Default value is "true"
filterNewValuesDefines the appearance of values in the list. Default value is "true".
hideDelayDelay between losing focus and pop-up list closing. Default value is "0".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassStyle Class attribute for the input field
inputDisabledClassStyle Class attribute for the disabled input
inputDisabledStyleCSS style rules to be applied to disabled input
inputInactiveClassStyle Class attribute for the inactive input
inputInactiveStyleCSS style rules to be applied to inactive input
inputStyleCSS style rules to be applied to input field
itemClassStyle Class attribute for the items
itemSelectedClassStyle Class attribute for the selected item
labelA localized user presentable name for this component.
listClassStyle Class attribute for the popup list
listHeightDefines height of file pop-up list. Default value is "200px".
listStyleCSS style rules to be applied to popup list
listWidthDefines width of file popup list
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onlistcallHTML: script expression; a list is called
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; some text is selected in a text field. This attribute may be used with the INPUT and TEXTAREA elements
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
selectFirstOnUpdateDefines if the first value from suggested is selected in pop-up list. Default value is "true".
showDelayDelay between event and pop-up list showing. Default value is "0".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
suggestionValuesDefines the suggestion collection
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
widthWidth of the component. Default value is "150".


The <rich:comboBox> is a simplified suggestion box component, that provides input with client side suggestions. The component could be in two states:

There are two ways to get values for the popup list of suggestions:

Popup list content loads at page render time. No additional requests could be performed on the popup calling.

The "value" attribute stores value from input after submit.

The "directInputSuggestions" attribute defines, how the first value from the suggested one appears in an input field. If it's "true" the first value appears with the suggested part highlighted.

Example:


...
<rich:comboBox value="#{bean.state}" suggestionValues="#{bean.suggestions}" directInputSuggestions="true" />            
...

This is a result:


The "selectFirstOnUpdate" attribute defines if the first value from suggested is selected in a popup list. If it's "false" nothing is selected in the list before a user hovers some item with the mouse.

Example:


...
<rich:comboBox value="#{bean.state}" suggestionValues="#{bean.suggestions}" selectFirstOnUpdate="false" />           
...

This is a result:


The "defaultLabel" attribute defines the default label of the input element. Simple example is placed below.

Example:


...
<rich:comboBox value="#{bean.state}" suggestionValues="#{bean.suggestions}" defaultLabel="Select a city..." />            
...

This is a result:


With the help of the "disabled" attribute you can disable the whole <rich:comboBox> component. See the following example.

Example:


...
<rich:comboBox value="#{bean.state}" suggestionValues="#{bean.suggestions}" defaultLabel="Select a city..." disabled="true" />            
...

This is a result:


The "enableManualInput" attribute enables/disables input field, so when enableManualInput = "false" , user can only pick the value manually and has no possibility to type in the value (default value is "false").

The <rich:comboBox> component provides to use specific event attributes:

  • "onlistcall" which is fired before the list opening and gives you a possibility to cancel list popup/update

  • "onselect" which gives you a possibility to send AJAX request when item is selected

The <rich:comboBox> component allows to use sizes attributes:

  • "listWidth" and "listHeight" attributes specify popup list sizes with values in pixels

  • "width" attribute customizes the size of input element with values in pixels.















On the screenshot there are classes names that define styles for component elements.









In order to redefine styles for all <rich:comboBox> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-combobox-list-decoration{
        
background-color:#ecf4fe;
}
...

This is a result:


In the example background color for popup list was changed.

Also it's possible to change styles of particular <rich:comboBox> component. In this case you should create own style classes and use them in corresponding <rich:comboBox> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
font-weight:bold;
}
...

The "listClass" attribute for <rich:comboBox> is defined as it's shown in the example below:

Example:


<rich:comboBox ... listClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font weight for items was changed.

On RichFaces LiveDemo page you can see an example of <rich:comboBox> usage and sources for the given example.

Table 6.121. rich : componentControl attributes

Attribute NameDescription
attachTimingDefines the page loading phase when componentControl is attached to another component. Default value is "onavailable"
attachToClient identifier of the component or id of the existing DOM element that is a source for given event. If attachTo is defined, the event is attached on the client according to the attachTiming attribute. If attachTo is not defined, the event is attached on the server to the closest in the component tree parent component.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
disableDefaultDisable default action for target event ( append "return false;" to JavaScript )
eventThe Event that is used to trigger the operation on the target component
forClient identifier of the target component.
idEvery component may have a unique id that is automatically created if omitted
nameThe optional name of the function that might be used to trigger the operation on the target component
operationThe function of JavaScript API that will be invoked. The API method is attached to the 'component' property of the root DOM element that represents the target component. The function has two parameters - event and params. See: 'params' attribute for details.
paramsThe set of parameters passed to the function of Javascript API that will be invoked. The JSON syntax is used to define the parameters, but without open and closed curve bracket. As an alternative, the set of f:param can be used to define the parameters passed to the API function. If both way are used to define the parameters, both set are concatenated. if names are equals, the f:param has a priority.
renderedIf "false", this component is not rendered


<rich:componentControl> is a command component, that allows to call JavaScript API function on some defined event. Look at the example:


...
<rich:componentControl attachTo="doExpandCalendarID" event="onclick" for="ccCalendarID" operation="Expand"/>
...

In other words it means "clicking on the component with ID 'doExpandCalendarID', expands the component with ID 'ccCalendarID'". It can be said, that <rich:componentControl> connects two components with the help of JavaScript API function.

Component ID, to wich the event, that invokes JavaScript API function is applied, is defined with "attachTo" attribute (see the exapmle above). If "attachTo" attribute is not defined, the component will be attached to the parent component.

Example:


...
<h:commandButton value="Show Modal Panel">
      <rich:componentControl for="ccModalPanelID" event="onclick" operation="show"/> <!--attached to the commandButton-->
</h:commandButton>
...

On the result page the component is rendered to JavaScript code. This means, that it is possible to invoke the <rich:componentControl> handler operation as usual JavaScript function. This function is called by name, specified in the component "name" attribute. The definition of "name" attribute is shown on the example below:


...
<rich:componentControl name="func" event="onRowClick" for="menu" operation="show" />
...

The generated JavaScript function will look as shown below:


function func (event) {
}

An important <rich:componentControl> feature, is that it allows transferring parameters, with the help of special attribute "params" .

Example:


...
<rich:componentControl name="func" event="onRowClick" for="menu" operation="show" params=#{car.model}"/>
...

The alternative way for parameters transferring uses <f:param> attribute. As the code above, the following code will represent the same functionality.

Example:


...
<rich:componentControl event="onRowClick" for="menu" operation="show">
      <f:param value="#{car.model}" name="model"/>
</rich:componentControl>
...

With the help of the "attachTiming" attribute you can define the page loading phase when <rich:componentControl> is attached to source component. Possible values are:

<rich:componentControl> interacts with such components as: <rich:contextMenu> , <rich:toolTip> , <rich:modalPanel > , <rich:listShuttle> , <rich:orderingList> , <rich:calendar>

In order to use <rich:componentControl> with another component you should place the id of this component into "for" attribute field. All operations with defined component you can find in the JavaScript API section of defined component.

Example:


...
<f:view>
    <h:form>
        <br />
        <rich:toolTip id="toolTipFor" followMouse="false" direction="top-right" mode="ajax" value="This is button" 
                      horizontalOffset="5" verticalOffset="5" layout="block" />
    </h:form>
    <h:commandButton id="ButtonID" value="Button">
        <rich:componentControl for="toolTipFor" attachTo="ButtonID" operation="show" event="onclick"/>
    </h:commandButton>
</f:view>
...

This is a result:


As it could be seen in the picture above, the <rich:toolTip> shows after you click the button.

On RichFaces LiveDemo page you can see an example of <rich:componentControl> usage and sources for the given example.

On RichFaces LiveDemo page you can found some additional information about <f:param> component.

Table 6.123. rich : contextMenu attributes

Attribute NameDescription
attachedIf the value of the "attached" attribute is true, the component is attached to the component, specified in the "attachTo" attribute or to the parent component, if "attachTo" is not defined. Default value is "true".
attachTimingDefines the timing when the menu is attached to the target element. Possible values "onload", "immediate", "onavailable" (default). Default value is "onavailable".
attachToClient identifier of the component or id of the existing DOM element that is a source for a given event. If attachTo is defined, the event is attached on the client according to the AttachTiming attribute. If both attached and attachTo attributes are defined, and attribute attached has value 'false', it is considered to have higher priority.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
disableDefaultMenuForbids default handling for adjusted event. Default value "true".
disabledItemClassSpace-separated list of CSS style class(es) that are be applied to disabled item of this component
disabledItemStyleCSS style(s) is/are to be applied to disabled item when this component is rendered.
eventDefines an event on the parent element to display the menu. Default value is "oncontextmenu".
hideDelayDelay between losing focus and menu closing. Default value is "800".
idEvery component may have a unique id that is automatically created if omitted
itemClassSpace-separated list of CSS style class(es) that are be applied to item of this component
itemStyleCSS style(s) is/are to be applied to item when this component is rendered.
oncollapseHTML: script expression; a menu is collapsed.
onexpandHTML: script expression; a menu is expanded.
ongroupactivateHTML: script expression; some group was activated
onitemselectHTML: script expression; some item was selected
onmousemoveHTML: script expression; a pointer was moved within
onmouseoutHTML: script expression; a pointer was moved away
onmouseoverHTML: script expression; a pointer was moved onto
popupWidthSet minimal width for the all of the lists that will appear
renderedIf "false", this component is not rendered
selectItemClassSpace-separated list of CSS style class(es) that are be applied to selected item of this component.
selectItemStyleCSS style(s) is/are to be applied to selected item when this component is rendered.
showDelayDelay between event and menu showing. Default value is "50".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
submitModeSets the submission mode for all menu items of the menu except those where this attribute redefined. Possible value are "ajax","server", "none". Default value is "server".


<rich:contextMenu> is a support-like component. Context menu itself is an invisible panel that appears after a particular client side event ( "onmouseover" , "onclick" , etc.) occurred on a parent component. The event is defined with an "event" attribute. The component uses "oncontextmenu" event by default to call a context menu by clicking on the right mouse button.

<rich:menuGroup> , <rich:menuItem> and <rich:menuSeparator> components are used as nested elements for <rich:contextMenu> in the same way as for <rich:dropDownMenu> .

If "attached" value is "true" (default value), component is attached to the parent component or to the component, which "id" is specified in the "attachTo" attribute. An example is placed below.

Example:


...
        <rich:contextMenu event="oncontextmenu" attachTo="pic1" submitMode="none">
            <rich:menuItem value="Zoom In" onclick="enlarge();" id="zin"/>
            <rich:menuItem value="Zoom Out" onclick="decrease();" id="zout"/>
        </rich:contextMenu>
        <h:panelGrid columns="1" columnClasses="cent">
                <h:panelGroup id="picture">
                        <h:graphicImage value="/richfaces/jQuery/images/pic1.png" id="pic"/>
                </h:panelGroup>
        </h:panelGrid>
        <h:panelGrid columns="1" columnClasses="cent">
                <h:panelGroup id="picture1">
                        <h:graphicImage value="/richfaces/jQuery/images/pic2.png" id="pic1"/>
                </h:panelGroup>
        </h:panelGrid>
...

The "enlarge()" and "decrease()" functions definition is placed below.

...

        <script type="text/javascript">
                function enlarge(){
                        document.getElementById('pic').width=document.getElementById('pic').width*1.1;
                        document.getElementById('pic').height=document.getElementById('pic').height*1.1;
                }
                function decrease(){
                        document.getElementById('pic').width=document.getElementById('pic').width*0.9;
                        document.getElementById('pic').height=document.getElementById('pic').height*0.9;
                }
        </script>
...

In the example a picture zooming possibility with <rich:contextMenu> component usage was shown. The picture is placed on the <h:panelGroup> component. The <rich:contextMenu> component is not nested to <h:panelGroup> and has a value of the "attachTo" attribute defined as "pic1". Thus, the context menu is attached to the component, which "id" is "pic1". The context menu has two items to zoom in (zoom out) a picture by "onclick" event. For earch item corresponding JavaScript function is defined to provide necessary action as a result of the clicking on it. For the menu is defined an "oncontextmenu" event to call the context menu on a right click mouse event.

In the example the context menu is defined for the parent <h:panelGroup> component with a value of "id" attribute equal to "picture" You should be careful with such definition, because a client context menu is looked for a DOM element with a client Id of a parent component on a server. If a parent component doesn't encode an Id on a client, it can't be found by the <rich:contextMenu> and it's attached to its closest parent in a DOM tree.

If the "attached" attribute has "false" value, component activates via JavaScript API with assistance of <rich:componentControl> . An example is placed below.

Example:


...
        <h:form id="form">
                <rich:contextMenu attached="false" id="menu" submitMode="ajax">
                        <rich:menuItem ajaxSingle="true">
                                <b>{car} {model}</b> details
                                <a4j:actionparam name="det" assignTo="#{ddmenu.current}" value="{car} {model} details"/>
                        </rich:menuItem>
                        <rich:menuGroup value="Actions">  
                                <rich:menuItem ajaxSingle="true">
                                        Put <b>{car} {model}</b> To Basket
                                        <a4j:actionparam name="bask" assignTo="#{ddmenu.current}" value="Put {car} {model} To Basket"/>
                                </rich:menuItem>
                                <rich:menuItem value="Read Comments" ajaxSingle="true">
                                        <a4j:actionparam name="bask" assignTo="#{ddmenu.current}" value="Read Comments"/>
                                </rich:menuItem>                
                                <rich:menuItem ajaxSingle="true">
                                        Go to <b>{car}</b> site
                                        <a4j:actionparam name="bask" assignTo="#{ddmenu.current}" value="Go to {car} site"/>
                                </rich:menuItem>
                        </rich:menuGroup>
                </rich:contextMenu> 

                <h:panelGrid columns="2">
                        <rich:dataTable value="#{dataTableScrollerBean.tenRandomCars}" var="car" id="table"
                                                        onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
                                                        onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" rowClasses="cur">
                                <rich:column>
                                        <f:facet name="header">Make</f:facet>
                                        <h:outputText value="#{car.make}"/>
                                </rich:column>
                                <rich:column>
                                        <f:facet name="header">Model</f:facet>
                                        <h:outputText value="#{car.model}"/>
                                </rich:column>
                                <rich:column>
                                        <f:facet name="header">Price</f:facet>
                                        <h:outputText value="#{car.price}" />
                                </rich:column>

                                <rich:componentControl event="onRowClick" for="menu" operation="show">
                                    <f:param value="#{car.model}" name="model"/>
                                    <f:param value="#{car.make}" name="car"/>
                                </rich:componentControl>
                        </rich:dataTable>

                        <a4j:outputPanel ajaxRendered="true">
                                <rich:panel>
                                        <f:facet name="header">Last Menu Action</f:facet>
                                        <h:outputText value="#{ddmenu.current}"></h:outputText>
                                </rich:panel>       
                        </a4j:outputPanel>
                </h:panelGrid>
        </h:form>           
 ...

This is a result:


In the example the context menu is activated (by clicking on the left mouse button) on the table via JavaScript API with assistance of <rich:componentControl> . The attribute "for" contains a value of the <rich:contextMenu> Id. For menu appearance Java Script API function "show()" is used. It is defined with "operation" attribute for the <rich:componentControl> component. Context menu is recreated after the every call on a client and new {car} and {model} values are inserted in it. In the example for a menu customization macrosubstitutions were used.

The <rich:contextMenu> component can be defined once on a page and can be used as shared for different components (this is the main difference from the <rich:dropDownMenu> component). It's necessary to define it once on a page (as it was shown in the example above) and activate it on required components via JavaScript API with assistance of <rich:componentControl> .

The <rich:contextMenu> "submitMode" attribute can be set to three possible parameters:

  • Server (default)

Regular form submition request is used

  • Ajax

Ajax submission is used for switching

  • None

The "action" and "actionListener" item's attributes are ignored. Menu items don't fire any submits themselves. The behavior is fully defined by the components nested inside items.

Note:

As the <rich:contextMenu> component doesn't provide its own form, use it between <h:form> and </h:form> tags.

Note:

When using <rich:contextMenu> component with <h:outputText> JSF component, specify id for <h:outputText> or move <rich:contextMenu> out from <h:outputText> to provide component's correct work.

On RichFaces LiveDemo page you can see an example of <rich:contextMenu> usage and sources for the given example.

Table 6.129. rich : dataFilterSlider attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
clientErrorMessageAn error message to use in client side validation events
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
endRangeA slider end point
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
fieldStyleClassThe styleClass for input that displays the value : manualInput must be "true"
filterByA getter of an object member required to compare a slider value to. This is a value that is used in results filtering
focusid of element to set focus after request completed on client side
forThe component using UIData (datatable id)
forValRefThis is a string which is used in a value attribute of the datatable. It is used for resetting the datatable back to the original list provided by a backing bean
handleStyleClassThe handleStyleClass for a handle
handleValueCurrent handle value
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
incrementAmount to which a handle on each slide/move should be incremented
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
manualInputFalse value for this attribute makes text field "read-only" and "hidden". Hence, the value can be changed only from a handle. Default value is "true"
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onchangeHTML: script expression; a handler's position is changed on sliding
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onerrorHTML: a script expression; event fires whenever an JavaScript error occurs
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onslideHTML: script expression; a handler is moved on sliding
onSlideSubmitDEPRECATED (use submitOnSlide). If the slider value changes must submit a form. Default value is "true".
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rangeStyleClassThe rangeStyleClass for the background div showing a full range
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
sliderListenerMethodBinding representing an action listener method that will be notified after changing of slider control position
startRangeA slider begin point
statusID (in format of call UIComponent.findComponent()) of Request status component
storeResultsSpecifies if the component will store a UIData object (your table rows) in session
styleCSS style(s) is/are to be applied when this component is rendered
styleClassThe styleClass for the container div surrounding the component
submitOnSlideIf the slider value changes must submit a form. Default value is "true".
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
trackStyleClassThe trackStyleClass for a background div
trailerIt shows or hides a trailer following a handle
trailerStyleClassThe trailerStyleClass for a div following a handle
valueThe current value for this component
widthWidth of the slider control. Default value is "200px".


The dataFilterSlider component is bound to some UIData component using a "for" attribute and filters data in a table.

Example:


...
    <rich:dataFilterSlider sliderListener="#{mybean.doSlide}"
                        startRange="0"
                        endRange="50000"
                        increment="10000"
                        handleValue="1"
                        for="carIndex"
                        forValRef="inventoryList.carInventory" 
                        filterBy="getMileage" />
...
    <h:dataTable id="carIndex"> 
          ... 
    </h:dataTable>
...

In this example other two attributes are used for filtering:

"handleValue" is an attribute for keeping the current handler position on the dataFilterSlider component. Based on the current value, appropriate values obtained from a getter method defined in "filterBy" are filtered.

One more important attribute is a "storeResults" one that allows the dataFilterSlider component to keep UIData target object in session.

If it's necessary the component submits a form on event of a handler state changing, use the "onSlide" attribute ( "onChange" is its alias). When the attribute definition = "true", submission on this event is defined.

Information about the "process" attribute usage you can find in the "Decide what to process " guide section.

On the component LiveDemo page you can see the example of <rich:dataFilterSlider> usage and sources for the given example.

Table 6.131. rich : datascroller attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleBoolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only. Default value is "true"
alignThis attribute specifies the position of the table with relatively to the document. Possible values are "left","center","right ". Default value is "center".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
boundaryControlsThe attribute specifies the visibility of boundaryControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
fastControlsThe attribute specifies the visibility of fastControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
fastStepThe attribute indicates pages quantity to switch onto when fast scrolling is used. Default value is "0".
focusid of element to set focus after request completed on client side
forID of the table component whose data is scrollled
handleValueCurrent handle value
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now. Default value is "true".
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inactiveStyleCorresponds to the HTML style attribute for the inactive cell on scroller
inactiveStyleClassCorresponds to the HTML class attribute for the inactive cell on scroller
lastPageModeThe attribute to control whether last page of datascroller shows "rows" number of items or just the rest. Possible values are "full" and "short". Default value is "short".
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
maxPagesMaximum quantity of pages. Default value is "10".
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onpagechangeHTML: script expression; a page is changed
pageIf page >= 1 then it's a page number to show
pageIndexVarName of variable in request scope containing index of active page
pagesVarName of variable in request scope containing number of pages
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
renderIfSinglePageIf renderIfSinglePage is "true" then datascroller is displayed on condition that the data hold on one page. Default value is "true".
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
scrollerListenerMethodBinding representing an action listener method that will be notified after scrolling
selectedStyleCorresponds to the HTML style attribute for the selected cell on scroller
selectedStyleClassCorresponds to the HTML class attribute for the selected cell on scroller
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
stepControlsThe attribute specifies the visibility of stepControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tableStyleCSS style(s) is/are to be applied to outside table when this component is rendered
tableStyleClassSpace-separated list of CSS style class(es) that are be applied to outside table of this component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component


The <rich:datascroller> component provides table scrolling functionalitity the same as TOMAHAWK scroller but with Ajax requests usage.

The <rich:datascroller> component should be reRendered also with <rich:dataTable> when you changing filter in order to be updated according to the <rich:dataTable> current model.

The component should be placed into footer of the parent table or be bound to it with the "for" attribute. Note, that "for" is evaluated on view build, not on view render, that is why it will ignore JSTL tags.

The table should also have the defined "rows" attribute limiting the quantity of inputted table rows.

The scroller could limit the maximum quantity of rendered links on the table pages with the help of the "maxPages" attribute.

Component provides two controllers groups for switching:

The controls of fast switching are created adding the facets component with the corresponding name:

Example:


 ...
<rich:datascroller for="table" maxPages="10">
          <f:facet name="first">
                    <h:outputText value="First"/>
          </f:facet>
          <f:facet name="last">
                    <h:outputText value="Last"/>
          </f:facet>
</rich:datascroller>
...

The screenshot shows one controller from each group.

There are also facets used to create the disabled states: "first_disabled", "last_disabled", "next_disabled", "previous_disabled", "fastforward_disabled", "fastrewind_disabled".

For the "fastforward"/"fastrewind" controls customization the additional "fastStep" attribute is used. The attribute indicates pages quantity to switch onto when fast scrolling is used.

The "page" is a value-binding attribute used to define and save current page number. The example is placed below.

Example:


...
<h:form id="myForm">
    <rich:dataTable id="carList" rows="7" value="#{dataTableScrollerBean.allCars}" var="category">
        <f:facet name="header">
            <rich:columnGroup>
                <h:column>
                    <h:outputText value="Make" />
                </h:column>
                <h:column>
                    <h:outputText value="Model" />
                </h:column>
                <h:column>
                    <h:outputText value="Price" />
                </h:column>
            </rich:columnGroup>
        </f:facet>
        <h:column>
            <h:outputText value="#{category.make}" />
        </h:column>
        <h:column>
            <h:outputText value="#{category.model}" />
        </h:column>
        <h:column>
            <h:outputText value="#{category.price}" />
        </h:column>
    </rich:dataTable>
    <rich:datascroller id="sc2" for="carList" reRender="sc1" maxPages="7" page="#{dataTableScrollerBean.scrollerPage}" />
    <h:panelGrid>
        <h:panelGroup>
            <h:outputText value="Set current page number:" />
            <h:inputText value="#{dataTableScrollerBean.scrollerPage}" id="sc1" size="1"/>
            <h:commandButton value="Set" />
        </h:panelGroup>
    </h:panelGrid>
</h:form>
...

In the example above you can enter the page number you want and set it by clicking on the <h:commandButton> . By the way, if you use <rich:datascroller> page links the input field rerenders and current page number changes.

This is a result:


The "pageIndexVar" and "pagesVar" attributes define a request scope variables and provide an ability to show the current page and the number of pages in the <rich:datascroller> .

These attributes are used for definition the names of variables, that is used in the facet with name "pages" . An example can be found below:

Example:


...
<h:form>
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
        <rich:column>
            <h:outputText value="#{cap.name}" />
        </rich:column>
        <f:facet name="footer">
            <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages">
                <f:facet name="pages">
                    <h:outputText value="#{pageIndex} / #{pages}" />
                </f:facet>
            </rich:datascroller>
        </f:facet>
    </rich:dataTable>
</h:form>
...

It's possible to insert optional separators between controls. For this purpose use a "controlsSeparator" facet. An example is placed below.


 ...
<f:facet name="controlsSeparator">
          <h:graphicImage value="/image/sep.png"/>
</f:facet>
...

Starting from 3.2.1 of RichFaces multiple <rich:datascroller> instances behavior and page bindings are corrected. Incorrect page after model changes handling is added. Phase Listener called before RenderResponce scans the page for the <rich:datascroller> and performs the following operations:

  • Checks if the <rich:datascroller> is rendered. (If the checking generates an exception, the <rich:datascroller> is considered to be not rendered )

  • If the <rich:datascroller> is rendered - the table to which the <rich:datascroller> is attached gets the value of the page attribute of <rich:datascroller> .

Information about the "process" attribute usage you can find in the " Decide what to process " guide section.

Note:

Make sure, that all <rich:datascroller> components, defined for a table, have same values for all "page" attributes. The page, specified in the last "page" , will be rendered in browser.

On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:datascroller> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:


...
.rich-datascr-button{
    
color: #CD6600;
}
...

This is a result:


In the example an input text font style was changed.

Also it's possible to change styles of particular <rich:datascroller> component. In this case you should create own style classes and use them in corresponding <rich:datascroller> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
background-color: #C6E2FF;
}
...

The "styleClass" attribute for <rich:datascroller> is defined as it's shown in the example below:

Example:


<rich:datascroller ... selectedStyleClass="myClass"/>

This is a result:


As it could be seen on the picture above, background color of the selected cell on scroller was changed.

On the component LiveDemo page you can see the example of <rich:datascroller> usage and sources for the given example.

The solution about how to do correct pagination using datascroller (load a part of data from database) can be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:datascroller> in a context of Extended Data Model see on theRichFaces Users Forum.

Table 6.140. rich : columns attributes

Attribute NameDescription
beginThe first iteration item
breakBeforeif "true" next column begins from the first row
colspanCorresponds to the HTML colspan attribute
columnsNumber of columns to be rendered
comparatorDefines value binding to the comparator that is used to compare the values
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
endThe last iteration item
filterByDefines iterable object property which is used when filtering performed.
filterEventEvent for filter input that forces the filtration (default value is "onchange")
filterExpressionAttribute defines a bean property which is used for filtering of a column
filterMethodThis attribute is defined with method binding. This method accepts on Object parameter and return boolean value
filterValueDefines current filtering value
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
indexThe current counter
labelColumn label for drag indicator. Usable only for extendedDataTable component
langCode describing the language used in the generated markup for this component
renderedAttribute defines if component should be rendered. Default value is "true".
rowspanCorresponds to the HTML rowspan attribute
selfSortedManages if the header of the column is clickable, icons rendered and sorting is fired after click on the header. You need to define this attribute inside <rich:dataTable> component. Default value is "true"
sortableBoolean attribute. If "true" it's possible to sort the column content after click on the header. Default value is "true"
sortByDefines a bean property which is used for sorting of a column. This attribute used with <rich:dataTable>
sortExpressionDefines a bean property which is used for sorting of a column and used only with <rich:scrollableDataTable>.
sortIconDefines sort icon. The value for the attribute is context related.
sortIconAscendingDefines sort icon for ascending order. The value for the attribute is context related.
sortIconDescendingDefines sort icon for descending order. The value for the attribute is context related.
sortOrderSortOrder is an enumeration of the possible sort orderings. Default value is "UNSORTED"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varThe current variable
visibleThe attribute is used to define whether the component is visible or not. The default value is "true".
widthAttribute defines width of column.


The <rich:columns> component gets a list from data model and outputs corresponding set of columns inside <rich:dataTable> on a page. It is possible to use "header" and "footer" facets with <rich:columns> component.

The "value" and "var" attributes are used to access the values of collection.

The simple example is placed below.

Example:


...
<rich:dataTable value="#{capitalsBean.capitals}" var="cap">
        <rich:columns value="#{capitalsBean.labels}" var="col" index="index">
                <f:facet name="header">
                        <h:outputText value="#{col.text}" />
                </f:facet>
         <h:outputText value="#{cap[index]}" />
         <f:facet name="footer">
                 <h:outputText value="#{col.text}" />
         </f:facet>
        </rich:columns> 
</rich:dataTable>
...

The "columns" attribute defines the count of columns.

The "rowspan" attribute defines the number of rows to be displayed. If the value of this attribute is zero, all remaining rows in the table are displayed on a page.

The "begin" attribute contains the first iteration item. Note, that iteration begins from zero.

The "end" attribute contains the last iteration item.

With the help of the attributes described below you can customize the output, i.e. define which columns and how many rows appear on a page.

Example:


...
<rich:dataTable value="#{capitalsBean.capitals}" var="cap">
        <rich:columns value="#{capitalsBean.labels}" var="col" index="index" rowspan="0" columns="3" begin="1" end="2">
                <f:facet name="header">
                        <h:outputText value="#{col.text}" />
                </f:facet>
                <h:outputText value="#{cap[index]}" />
        </rich:columns> 
</rich:dataTable>
...

In the example below, columns from first to second and all rows are shown in the <rich:dataTable> .

The result is:


The <rich:columns> component does not prevent to use <rich:column> . In the following example one column renders in any way and another columns could be picked from the model.

Example:


...
<rich:dataTable value="#{rowBean.rows}" var="row">
        <rich:column>
                <h:outputText value ="#{row.columnValue}"/>
        </rich:column>
        <rich:columns value="#{colBean.columns}" var="col">
                <f:facet name="header">
                        <h:outputText value="#{col.header}"/>
                </f:facet>
                <h:outputText value="#{row.columnValue}"/>
                <f:facet name="footer">
                        <h:outputText value="#{col.footer}"/>
                </f:facet>
        </rich:columns>
</rich:dataTable>   
...

Now, you can use a few <rich:columns> together with <rich:column> within the one table:


...
<rich:dataTable value="#{dataTableScrollerBean.model}" var="model" width="500px" rows="5">
          <f:facet name="header">
              <h:outputText value="Cars Available"></h:outputText>
    </f:facet>
    <rich:columns value="#{dataTableScrollerBean.columns}" var="columns" index="ind">
              <f:facet name="header">
                  <h:outputText value="#{columns.header}" />
        </f:facet>
        <h:outputText value="#{model[ind].model} " />
    </rich:columns>
    <rich:column>
        <f:facet name="header">
                  <h:outputText value="Price" />
        </f:facet>
                    <h:outputText value="Price" />
    </rich:column>
    <rich:columns value="#{dataTableScrollerBean.columns}" var="columns" index="ind">
              <f:facet name="header">
                  <h:outputText value="#{columns.header}" />
        </f:facet>
        <h:outputText value="#{model[ind].mileage}$" />
    </rich:columns>
</rich:dataTable>
...                              
                    

In order to group columns with text information into one row, use the "colspan" attribute, which is similar to an HTML one. In the following example the third column contains 3 columns. In addition, it's necessary to specify that the next column begins from the first row with the help of the breakBefore = "true" .

Example:


...
<rich:dataTable value="#{columns.data1}" var="data">
        <rich:column>
                <h:outputText value="#{column.Item1}" />
        </rich:column>
        <rich:column>
                <h:outputText value="#{column.Item2}" />
        </rich:column>
        <rich:column>
                <h:outputText value="#{column.Item3}" />
        </rich:column>
        <rich:columns columns="3" colspan="3" breakBefore="true">   
                <h:outputText value="#{data.str0}" />
        </rich:columns>
</rich:dataTable>
...

The same way is used for columns grouping with the "rowspan" attribute that is similar to an HTML. The only thing to add in the example is an instruction to move onto the next row for each next after the second column.

Example:


...
<rich:dataTable value="#{columns.data1}" var="data">
        <rich:columns columns="2" rowspan="3">  
                <h:outputText value="#{data.str0}" />
        </rich:columns>
        <rich:column>
                <h:outputText value="#{column.Item1}" />
        </rich:column>
        <rich:column  breakBefore="true">
                <h:outputText value="#{column.Item2}" />
        </rich:column>
        <rich:column  breakBefore="true">
                <h:outputText value="#{column.Item3}" />
        </rich:column>
</rich:dataTable>
...

Note:

The <rich:columns> tag is initialized during components tree building process. This process precedes page rendering at "Render Response" JSF phase. To be rendered properly the component needs all it variables to be initialized while the components tree is being building. A javax.servlet.jsp.JspTagException occurs if <rich:columns> uses variables passed from other components, if these variables are initialized during rendering. Thus, when <rich:columns> is asking for such variables they do not already exist. Use <c:forEach> JSP standard tag as workaround. Compare two examples below.

This code calls the exception:


...
<rich:dataTable value="#{bean.data}" var="var">
          <rich:columns value="#{var.columns}">
                    ...
          </rich:columns>
</rich:dataTable>
...

This code works properly:


...
<c:forEach items="#{bean.data}" var="var">
          <rich:columns value="#{var.columns}">
                    ...
          </rich:columns>
</c:forEach>
...

Information about sorting and filtering you can find in the corresponding section .

On the component LiveDemo page you can found some additional information for <rich:columns> component usage.

Table 6.143. rich : columnGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
filterMethodThis attribute is defined with method binding. This method accepts on Object parameter and return boolean value
filterValueDefines current filtering value
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
selfSortedManages if the header of the column is clickable, icons rendered and sorting is fired after click on the header. You need to define this attribute inside <rich:dataTable> component. Default value is "true"
sortOrderSortOrder is an enumeration of the possible sort orderings. Default value is "UNSORTED"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component


The <rich:columnGroup> component combines columns set wrapping them into the <tr> element and outputting them into one row. Columns are combined in a group the same way as when the "breakBefore" attribute is used for columns to add a moving to the next rows, but the first variant is clearer from a source code. Hence, the following simple examples are very same.

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5" id="sublist"> 
        <rich:column colspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:columnGroup>
            <rich:column> 
                <h:outputText value="#{cap.state}"/>
            </rich:column>
            <rich:column >
                <h:outputText value="#{cap.name}"/>
            </rich:column>
            <rich:column >
                <h:outputText value="#{cap.timeZone}"/>
            </rich:column>
        </rich:columnGroup> 
    </rich:dataTable>
...

And representation without a grouping:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5" id="sublist"> 
        <rich:column colspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column breakBefore="true">
                <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column breakBefore="true">
                <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column >
                <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
....

The result is:


It's also possible to use the component for output of complex headers in a table. For example adding of a complex header to a facet for the whole table looks the following way:

Example:


...
    <f:facet name="header">
        <rich:columnGroup>
            <rich:column rowspan="2">
                <h:outputText value="State Flag"/>
            </rich:column>
            <rich:column colspan="3">
                <h:outputText value="State Info"/>
            </rich:column>
            <rich:column breakBefore="true">
                <h:outputText value="State Name"/>
            </rich:column>
            <rich:column>
                <h:outputText value="State Capital"/>
            </rich:column>
            <rich:column>
                <h:outputText value="Time Zone"/>
            </rich:column>
        </rich:columnGroup>
    </f:facet>
...

Generated on a page as:


On the component LiveDemo page you can see the example of <rich:columnGroup> usage and sources for the given example.

Table 6.145. rich : column attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
breakBeforeif "true" next column begins from the first row
colspanCorresponds to the HTML colspan attribute
comparatorDefines value binding to the comparator that is used to compare the values
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
filterByDefines iterable object property which is used when filtering performed.
filterEventEvent for filter input that forces the filtration (default value is "onchange")
filterExpressionAttribute defines a bean property which is used for filtering of a column
filterMethodThis attribute is defined with method binding. This method accepts on Object parameter and return boolean value
filterValueDefines current filtering value
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
labelColumn label for drag indicator. Usable only for extendedDataTable component
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowspanCorresponds to the HTML rowspan attribute
selfSortedManages if the header of the column is clickable, icons rendered and sorting is fired after click on the header. You need to define this attribute inside <rich:dataTable> component. Default value is "true"
sortableBoolean attribute. If "true" it's possible to sort the column content after click on the header. Default value is "true"
sortByDefines a bean property which is used for sorting of a column. This attribute used with <rich:dataTable>
sortExpressionDefines a bean property which is used for sorting of a column and used only with <rich:scrollableDataTable>.
sortIconDefines sort icon. The value for the attribute is context related.
sortIconAscendingDefines sort icon for ascending order. The value for the attribute is context related.
sortIconDescendingDefines sort icon for descending order. The value for the attribute is context related.
sortOrderSortOrder is an enumeration of the possible sort orderings. Default value is "UNSORTED"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
visibleThe attribute is used to define whether the component is visible or not. The default value is "true".
widthAttribute defines width of column.


To output a simple table, the <rich:column> component is used the same way as the standard <h:column> , i.e. the following code on a page is used:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column>
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column>
            <f:facet name="header">State Name</f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column >
            <f:facet name="header">State Capital</f:facet>
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column>
        <f:facet name="header">Time Zone</f:facet>
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

The result is:


Now, in order to group columns with text information into one row in one column with a flag, use the "colspan" attribute, which is similar to an HTML one, specifying that the first column contains 3 columns. In addition, it's necessary to specify that the next column begins from the first row with the help of the breakBefore="true".

Example:


...
     <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column colspan="3">
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column breakBefore="true"> 
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column >
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column>
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

As a result the following structure is rendered:


The same way is used for columns grouping with the "rowspan" attribute that is similar to an HTML one responsible for rows quantity definition occupied with the current one. The only thing to add in the example is an instruction to move onto the next row for each next after the second column.

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5"> 
        <rich:column rowspan="3">
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
        </rich:column>
        <rich:column> 
            <f:facet name="header">State Info</f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column>
        <rich:column breakBefore="true">
            <h:outputText value="#{cap.name}"/>
        </rich:column>
        <rich:column breakBefore="true">
            <h:outputText value="#{cap.timeZone}"/>
        </rich:column>
    </rich:dataTable>
...

As a result:


Hence, additionally to a standard output of a particular row provided with the <h:column> component, it becomes possible to group easily the rows with special HTML attribute.

The columns also could be grouped in a particular way with the help of the <h:columnGroup> component that is described in the following chapter.

In the Dynamic Columns Wiki article you can find additional information about dynamic columns.

In order to sort the columns you should use "sortBy" attribute that indicates what values to be sorted.This attribute can be used only with the <rich:dataTable> component. In order to sort the column you should click on its header. See the following example.

Example:


...
<h:form>
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" width="300px">
        <f:facet name="header">
            <h:outputText value="Sorting Example"/>
        </f:facet>
        <rich:column sortBy="#{cap.state}">
            <f:facet name="header">
                <h:outputText value="State Name"/>
            </f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column> 
        <rich:column sortBy="#{cap.name}">
            <f:facet name="header">
                <h:outputText value="State Capital"/>
            </f:facet>
            <h:outputText value="#{cap.name}"/> 
        </rich:column>
    </rich:dataTable>
</h:form>
...

This is result:


The "sortExpression" attribute defines a bean property which is used for sorting of a column. This attribute can be used only with the <rich:scrollableDataTable> component. The following example is a example of the attribute usage.

Example:


...
<rich:scrollableDataTable id="carList"
        value="#{dataTableScrollerBean.allCars}" sortMode="single"
        binding="#{dataTableScrollerBean.table}">
        <rich:column id="make" sortExpression="#{cap.make}">
            <f:facet name="header">
                <h:outputText styleClass="headerText" value="Make" />
            </f:facet>
            <h:outputText value="#{category.make}" />
        </rich:column>
        <rich:column id="model">
            <f:facet name="header">
                <h:outputText styleClass="headerText" value="Model" />
            </f:facet>
            <h:outputText value="#{category.model}" />
        </rich:column>
        <rich:column id="price">
            <f:facet name="header">
                <h:outputText styleClass="headerText" value="Price" />
            </f:facet>
            <h:outputText value="#{category.price}" />
        </rich:column>
</rich:scrollableDataTable>
...

The "selfSorted" attribute that would add the possibility of automatic sorting by clicking the column header. Default value is "true". In the example below the second column is unavailable for sorting.

Example:


...
<rich:dataTable value="#{capitalsBean.capitals}" var="cap">
        <rich:column>
                <f:facet name="header">
                        <h:outputText value="State Flag"/>
                </f:facet>
                <h:graphicImage value="#{cap.stateFlag}"/> 
        </rich:column>
        <rich:column sortBy="#{cap.state}" selfSorted="false"> 
                <f:facet name="header">
                        <h:outputText value="State Name"/>
                </f:facet>
                <h:outputText value="#{cap.state}"/>
        </rich:column> 
</rich:dataTable>
...

"sortOrder" attribute is used for changing the sorting of columns by means of external controls.

Possible values are:

  • "ASCENDING" - column is sorted in ascending

  • "DESCENDING" - column is sorted in descending

  • "UNSORTED" - column isn't sorted

Example:


...
<h:form>
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" width="300px">
        <f:facet name="header">
            <h:outputText value="Sorting Example"/>
        </f:facet>
        <rich:column sortBy="#{cap.state}" sortOrder="ASCENDING">
            <f:facet name="header">
                <h:outputText value="State Name"/>
            </f:facet>
            <h:outputText value="#{cap.state}"/>
        </rich:column> 
        <rich:column sortBy="#{cap.name}" sortOrder="DESCENDING">
            <f:facet name="header">
                <h:outputText value="State Capital"/>
            </f:facet>
            <h:outputText value="#{cap.name}"/> 
        </rich:column>
    </rich:dataTable>
</h:form>
...

Below you can see the result:


In the example above the first column is sorted in descending order. But if recurring rows appear in the table the relative second column are sorted in ascending order.

You can customize the sorting's icon element using "rich-sort-icon" class.

Note

In order to sort a column with the values not in English you can add the org.richfaces.datatableUsesViewLocale context parameter in your web.xml. Its value should be "true".

Note:

The "sortBy" and the "selfSorted" attributes used with the <rich:dataTable> component. Also the "selfSorted" can be used with the <rich:extendedDataTable> .

The "sortable" and the "sortExpression" attributes used with the <rich:scrollableDataTable> component.

There are two ways to filter the column value:

Vizit Column page at RichFaces live demo for examples of component usage and their sources.

" Using the "rendered" attribute of <rich:column>" article in RichFaces cookbook at JBoss portal gives an example of code of the component usage case.

Table 6.148. rich : dataGrid attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
alignDeprecated. This attribute specifies the position of the table with respect to the document. The possible values are "left", "center" and "right". The default value is "left".
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width of the frame around a component. Default value is "0".
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
captionStyleCSS style(s) is/are to be applied to caption when this component is rendered
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. Default value is "0".
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells. Default value is "0".
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
columnsNumber of columns
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
elementsNumber of elements in grid
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to footer for this component
frameThis attribute specifies which sides of the frame surrounding a table will be visible. Possible values: "void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box" and "border". The default value is "void".
headerClassSpace-separated list of CSS style class(es) that are be applied to header for this component
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyConverterConverter for a row key object
rowKeyVarRequest scoped variable for client access to rowKey
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
summaryThis attribute provides a summary of the table's purpose and structure for user agents rendering to non-visual media such as speech and Braille
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthThis attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent


The component takes a list from a model and outputs it the same way as with <h:panelGrid> for inline data. To define grid properties and styles, use the same definitions as for <h:panelGrid>.

The component allows to:

Here is an example:

Example:


...
    <rich:panel style="width:150px;height:200px;">
        <h:form>
              <rich:dataGrid value="#{dataTableScrollerBean.allCars}" var="car" columns="2" elements="4" first="1">
                  <f:facet name="header">
                      <h:outputText value="Car Store"></h:outputText>
                  </f:facet>
                  <rich:panel>
                      <f:facet name="header">
                          <h:outputText value="#{car.make} #{car.model}"></h:outputText>
                      </f:facet>
                      <h:panelGrid columns="2">
                           <h:outputText value="Price:" styleClass="label"></h:outputText>
                           <h:outputText value="#{car.price}"/>
                           <h:outputText value="Mileage:" styleClass="label"></h:outputText>
                           <h:outputText value="#{car.mileage}"/>
                      </h:panelGrid>
                  </rich:panel>
                  <f:facet name="footer">
                      <rich:datascroller></rich:datascroller>
                  </f:facet>
              </rich:dataGrid>
        </h:form>
    </rich:panel>       
...

This is a result:


The component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that are updated after an Ajax request.

Here is an example:

Example:


...
    <rich:dataGrid value="#{dataTableScrollerBean.allCars}" var="car" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataGrid}" id="grid" elements="4" columns="2">
        ...
    </rich:dataGrid>
...
    <a4j:commandButton action="#{listBean.action}" reRender="grid" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataGrid> component. As a result the component is updated after an Ajax request.

On the component LiveDemo page you can see the example of <rich:dataGrid> usage and sources for the given example.

Table 6.151. rich : dataList attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
typeCorresponds to the HTML DL type attribute
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating


The <rich:dataList> component allows to generate a list from a model.

The component has the "type" attribute, which corresponds to the "type" parameter for the <UL> HTML element and defines a marker type. Possible values for "type" attribute are: "disc", "circle", "square".

Here is an example:


...
    <h:form>
        <rich:dataList var="car" value="#{dataTableScrollerBean.allCars}" rows="5" type="disc" title="Car Store">
            <h:outputText value="#{car.make} #{car.model}"/><br/>
            <h:outputText value="Price:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.price} "/><br/>
            <h:outputText value="Mileage:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.mileage} "/><br/>
        </rich:dataList>
</h:form>
...

This is a result:


In the example the "rows" attribute limits number of output elements of the list.

"first" attribute defines first element for output. "title" are used for popup title. See picture below:


The component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that are updated after an Ajax request.

Here is an example:

Example:


...
    <rich:dataList value="#{dataTableScrollerBean.allCars}" var="car" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list" rows="5" type="disc">
        ...
    </rich:dataList>
...
    <a4j:commandButton action="#{listBean.action}" reRender="list" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataList> component. As a result the component is updated after an Ajax request.

On the component LiveDemo page you can see the example of <rich:dataList> usage and sources for the given example.

Table 6.154. rich : dataOrderedList attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyConverterConverter for a RowKey object.
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
typeCorresponds to the HTML OL type attribute
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating


The <rich:dataOrderedList> component allows to generate an ordered list from a model.

The component has the "type" attribute, which corresponds to the "type" parameter for the <OL> HTML element and defines a marker type. Possible values for "type" attribute are: "A", "a", "I", "i", "1".

Here is an example:


...
    <h:form>
        <rich:dataOrderedList var="car" value="#{dataTableScrollerBean.allCars}" rows="5" type="1"  title="Car Store">
            <h:outputText value="#{car.make} #{car.model}"/><br/>
            <h:outputText value="Price:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.price}" /><br/>
            <h:outputText value="Mileage:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.mileage}" /><br/>
        </rich:dataOrderedList>
    </h:form>
...

This is a result:


In the example the "rows" attribute limits number of output elements of the list.

"first" attribute defines first element for output. "title" are used for popup title.

The component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that are updated after an Ajax request.

Here is an example:

Example:


...
    <rich:dataOrderedList value="#{dataTableScrollerBean.allCars}" var="car" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        ...
    </rich:dataOrderedList>
...
    <a4j:commandButton action="#{listBean.action}" reRender="list" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataOrderedList> component. As a result the component is updated after an Ajax request.

On the component LiveDemo page you can see the example of <rich:dataOrderedList > usage and sources for the given example.

Table 6.157. rich : dataDefinitionList attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyRowKey is a representation of an identifier for a specific data row
rowKeyConverterConverter for a RowKey object.
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating


The <rich:dataDefinitionList> component allows to generate an definition list from a model.

The component has the "term" facet, which corresponds to the "type" parameter for the <DT> HTML element.

Here is an example:


...
    <h:form>
        <rich:dataDefinitionList var="car" value="#{dataTableScrollerBean.allCars}" rows="5" first="4" title="Cars">
            <f:facet name="term">
                <h:outputText value="#{car.make} #{car.model}"></h:outputText>
            </f:facet>
            <h:outputText value="Price:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.price}" /><br/>
            <h:outputText value="Mileage:" styleClass="label"></h:outputText>
            <h:outputText value="#{car.mileage}" /><br/>
        </rich:dataDefinitionList>
    </h:form>
...

This is a result:


In the example the "rows" attribute limits number of output elements of the list.

"first" attribute defines first element for output. "title" are used for popup title.

The component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. The "ajaxKeys" attribute allows to define row keys that are updated after an Ajax request, you need to pass an array with key (lines) of the list that you want to be updated after the Ajax request is executed.

Here is an example:

Example:


...
    <rich:dataDefinitionList value="#{dataTableScrollerBean.allCars}" var="car" ajaxKeys="#{listBean.list}" 
                        binding="#{listBean.dataList}" id="list">
        ...
    </rich:dataDefinitionList>
...
    <a4j:commandButton action="#{listBean.action}" reRender="list" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataDefinitionList> component. As a result the component is updated after an Ajax request.

On the component LiveDemo page you can see the example of <rich:dataDefinitionList> usage and sources for the given example.

Table 6.160. rich : dataTable attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
alignDeprecated. This attribute specifies the position of the table with respect to the document. The possible values are "left", "center" and "right". The default value is "left".
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width of the frame around a component. Default value is "0".
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
captionStyleCSS style(s) is/are to be applied to caption when this component is rendered
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. Default value is "0".
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells. Default value is "0".
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
columnsNumber of columns
columnsWidthComma-separated list of width attribute for every column. Specifies a default width for each column in the table. In addition to the standard pixel, percentage, and relative values, this attribute allows the special form "0*" (zero asterisk) which means that the width of the each column in the group should be the minimum width necessary to hold the column's contents. This implies that a column's entire contents must be known before its width may be correctly computed. Authors should be aware that specifying "0*" will prevent visual user agents from rendering a table incrementally
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to footer for this component
frameThis attribute specifies which sides of the frame surrounding a table will be visible. Possible values: "void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box" and "border". The default value is "void".
headerClassSpace-separated list of CSS style class(es) that are be applied to header for this component
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowContextMenuJavaScript handler to be called on right click. Returning false prevents default browser context menu from being displayed
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyConverterConverter for a RowKey object.
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
sortModeDefines mode of sorting. Possible values are 'single' for sorting of one column and 'multi' for some.
sortPriorityDefines a set of columns ids in the sorting order
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthThis attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent


The <rich:dataTable> component is similar to the <h:dataTable> one, except Ajax support and skinnability. Ajax support is possible, because the component was created basing on the <a4j:repeat> component and as a result it could be partially updated with Ajax. "ajaxKeys" attribute allows to define row keys that is updated after an Ajax request.

Here is an example:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="capitals"
                ajaxKeys="#{bean.ajaxSet}" binding="#{bean.table}" id="table">
        ...
    </rich:dataTable>
...
    <a4j:commandButton action="#{tableBean.action}" reRender="table" value="Submit"/>
...

In the example "reRender" attribute contains value of "id" attribute for <rich:dataTable> component. As a result the component is updated after an Ajax request.

The component allows to use "header" , "footer" and "caption" facets for output. See an example below:

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
        <f:facet name="caption"><h:outputText value="United States Capitals" /></f:facet>
        <f:facet name="header"><h:outputText value="Capitals and States Table" /></f:facet>
        <rich:column>
            <f:facet name="header">State Flag</f:facet>
            <h:graphicImage value="#{cap.stateFlag}"/>
            <f:facet name="footer">State Flag</f:facet>
        </rich:column>
        <rich:column>
            <f:facet name="header">State Name</f:facet>
            <h:outputText value="#{cap.state}"/>
            <f:facet name="footer">State Name</f:facet>
        </rich:column>
        <rich:column >
            <f:facet name="header">State Capital</f:facet>
            <h:outputText value="#{cap.name}"/>
            <f:facet name="footer">State Capital</f:facet>
        </rich:column>
        <rich:column>
            <f:facet name="header">Time Zone</f:facet>
            <h:outputText value="#{cap.timeZone}"/>
            <f:facet name="footer">Time Zone</f:facet>
        </rich:column>
        <f:facet name="footer"><h:outputText value="Capitals and States Table" /></f:facet>
    </rich:dataTable>
...

This is a result:


Information about sorting and filtering you can find in the corresponding section.

You can find information how to remove header's gradient in the "How to remove rich:dataTable header background " article.

On the screenshot there are classes names that define styles for component elements.





In order to redefine styles for all <rich:dataTable> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-table-cell{
    
font-weight:bold;
}
...

This is a result:


In the example the font weight for table cell was changed.

Also it's possible to change styles of particular <rich:dataTable> component. In this case you should create own style classes and use them in corresponding <rich:dataTable> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-style:italic;
}
...

The "headerClass" attribute for <rich:dataTable> is defined as it's shown in the example below:

Example:


<rich:dataTable  ... headerClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for header was changed.

Detailed information on how to set <rich:dataTable> border to "0px" you can find in the " How to set rich:dataTable border to 0px article " .

On the component LiveDemo page you can see the example of <rich:dataTable> usage and sources for the given example.

The article about <rich:dataTable> flexibility can be found in the "rich:dataTable Flexibility " article .

More information about using <rich:dataTable> and <rich:subTable> could be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:datascroller> in a context of Extended Data Model see on the RichFaces Users Forum.

Table 6.172. rich : subTable attributes

Attribute NameDescription
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
idEvery component may have a unique id that is automatically created if omitted
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
renderedIf "false", this component is not rendered
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
stateVarThe attribute provides access to a component state on the client side
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating






In order to redefine styles for all <rich:subTable> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-subtable-footer{
        
font-weight: bold;
} 
...

This is a result:


In the example a footer font weight was changed.

Also it's possible to change styles of particular <rich:subTable> component. In this case you should create own style classes and use them in corresponding <rich:subTable> styleClass attributes. An example is placed below:

Example:


...
.myClass{
  
background-color: #fff5ec;
}
...

The "columnClasses" attribute for <rich:subTable> is defined as it's shown in the example below:

Example:


<rich:subTable ... columnClasses="myClass"/>

This is a result:


As it could be seen on the picture above, the background color for columns was changed.

Table 6.178. rich : editor attributes

Attribute NameDescription
autoResizeAttribute enables to get the Editor area to resize to the boundaries of the contents.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
configurationAttribute defines configuration properties file name
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
customPluginsAttribute defines property file name witch contains descriptors of custom plugins
dialogTypeAttribute defines how dialogs/popups should be opened. Default value is "modal"
heightAttribute defines height of component.
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelA localized user presentable name for this component.
languageAttribute defines Editor language
onchangeHTML: script expression; content is modified by TinyMCE.
oninitHTML: script expression; initialization of the editor's instances are finished
onsaveHTML: script expression; the contents is extracted/saved.
onsetupHTML: script expression; to add events to editor instances before they get rendered.
pluginsAttribute defines Editor plugins
readonlyAttribute defines Editor is readonly
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
skinAttribute defines Editor skin
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexIn visual mode the attribute works the same way as "tab_focus" TinyMCE's property the attribute enables you to specify an element ID to focus, when the TAB key is pressed . You can also use the special ":prev" and ":next" values that will then place the focus on an input element placed before/after the TinyMCE instance in the DOM. While in "source" mode the attribute works like standard HTML tabindex attribute.
themeAttribute defines Editor theme
useSeamTextAttribute defines if model value should be converted to Seam Text. Default value is "false"
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
viewModeAttribute defines if tinyMCE WYSIWYG should be disabled. Default value is "visual"
widthAttribute defines width of component.


The <rich:editor> is fully based on TinyMCE web based Javascript HTML WYSIWYG editor control and supports all of the features it has. The <rich:editor> adapts the TinyMCE editor for JSF environment and adds some functional capabilities.

The easiest way to place the <rich:editor> on a page is as follows:

Example:


<rich:editor value="#{bean.editorValue}" />

Implementation of <rich:editor> provides three ways to define the properties of the component:

The three methods are described in details in the chapter.

The most important properties are implemented as attributes and you can define them as any other attribute. The attributes of the <rich:editor> component match the corresponding properties of TinyMCE editor.

For example, a theme for the editor can be defined using the "theme" attribute like this:

Example:



<rich:editor value="#{bean.editorValue}" theme="advanced" />

Setting a different skin for the editor can be done using the "skin" attribute.

Another useful property that is implemented at attribute level is "viewMode" . The attribute switches between "visual" and "source" modes, toggling between modes is performed setting the attribute to "visual" and "source" respectively. Implementation of <rich:editor> also implies that you can change the modes dynamically setting the value of the "viewMode" attribute using EL-expression.

Example:


...  
<rich:editor value="#{editor.submit}" theme="advanced" viewMode="#{editor.viewMode}" >
    ...
    <h:selectOneRadio value="#{editor.viewMode}" onchange="submit();">
        <f:selectItem itemValue="visual" itemLabel="visual" />
        <f:selectItem itemValue="source" itemLabel="source" />
    </h:selectOneRadio>
    ...
</rich:editor>
...

Most configuration options that TinyMCE provides can be applied using <f:param> JSF tag. The syntax is quite simple: the "name" attribute should contain the option, the "value" attribute assigns some value to the option.

For example, this code adds some buttons to the editor and positions the toolbar.

Example:


...
<rich:editor value="#{bean.editorValue}" theme="advanced" plugins="save,paste" >
          <f:param name="theme_advanced_buttons1" value="bold,italic,underline, cut,copy,paste,pasteword"/>
          <f:param name="theme_advanced_toolbar_location" value="top"/>                               
          <f:param name="theme_advanced_toolbar_align" value="left"/>
</rich:editor>
...

This is what you get as a result:


The third way to configure the <rich:editor> is to use configuration file (.properties)

This method eases your life if you need to configure multiple instances of the <rich:editor> : you configure the editor once and in one spot and the configuration properties can be applied to any <rich:editor> in your application.

To implement this type of configuration you need to take a few steps:

  • Create a configuration file (.properties) in the classpath folder and add some properties to it. Use standard syntax for the .properties files: parameter=value. Here is an example of configuration file:

    Example:

    
    theme="advanced"
    plugins="save,paste"
    theme_advanced_buttons1="bold,italic,underline, cut,copy,paste,pasteword"
    theme_advanced_toolbar_location="top"
    theme_advanced_toolbar_align="left"
  • The properties stored in configuration file are passed to the <rich:editor> via "configuration" attribute which takes the name of the configuration file as a value (with out .properties extension).

    For example, if you named the configuration file "editorconfig", you would address it as follows:

    Example:

    
    ...
    <rich:editor value="#{bean.editorValue}" configuration="editorconfig"/>
    ...
  • Alternately, you can use a EL-expression to define a configuration file. This way you can dynamically change the sets of configuration properties.

    For example, you have two configuration files "configurationAdvanced" and "configurationSimple" and you want them to be applied under some condition.

    To do this you need to bind "configuration" attribute to the appropriate bean property like this.

    Example:

    
    ...
    <rich:editor value="#{bean.editorValue}" configuration="#{editor.configuration}" />
    ...

    Your Java file should look like this.

    ...
    
        String configuration;
        if(some condition){//defines some condition
                                  configuration = "configurationAdvanced"; //the name on the file with advanced properties  
        }
        else{
             configuration= "configurationSimple"; //the name on the file with simplified properties    
            
        }
    ...

You also might want to add some custom plug-ins to your editor. You can read about how to create a plugin in here.

Adding a custom plugin also requires a few steps to take. Though, the procedure is very similar to adding a configuration file.

This is what you need to add a plugin:

  • Create a .properties file and put the name of the plug-in and a path to it into the file. The file can contain multiple plug-in declarations. Your .properties file should be like this.

    Example:

    
    ...
    pluginName=/mytinymceplugins/plugin1Name/editor_plugin.js
    ...
  • Use the "customPlugins" attribute to specify the .properties file with a plugin name and a path to it.

    If your .properties file is named "myPlugins", then your will have this code on the page.

    Example:

    
    ...
    <rich:editor theme="advanced" customPlugins="myPlugins" plugins="pluginName" /> 
    ...

Note:

Some plug-ins which available for download might have some dependencies on TinyMCE scripts. For example, dialog pop-ups require tiny_mce_popup.js script file. Assuming that you will not plug custom plugins to the RF jar with editor component (standard TinyMCE plugins creation implies that plugins are put into TinyMCE's corresponding directory) you should manually add required TinyMCE scripts to some project folder and correct the js includes.

The implementation of the <rich:editor> component has two methods for handling events.

The attributes take some function name as a value with is triggered on the appropriate event. You need to use standard JavaScript function calling syntax.

  • Using attributes ( "onchange" , "oninit" , "onsave" , "onsetup" )

    Example:

    
    ...
    <rich:editor value="#{bean.editorValue}" onchange="myCustomOnChangeHandler()" />
    ...
  • Using <f:param> as a child element defining the "name" attribute with one of the TinyMCE's callbacks and the "value" attribute takes the function name you want to be called on the corresponding event as the value. Note, that the syntax in this case is a bit different: parentheses are not required.

    Example:

    
    ...
    <rich:editor value="#{bean.editorValue}">
            <f:param name="onchange" value="myCustomOnChangeHandler" />
    </rich:editor>
    ...

The <rich:editor> component has a build-in converter that renders HTML code generated by the editor to Seam text (you can read more Seam text here.), it also interprets Seam text passed to the <rich:editor> and renders it to HTML. The converter can be enable with the "useSeamText" attribute.

Example:

This HTML code generated by editor


...
<p><a href="http://mysite.com">Lorem ipsum</a> <i>dolor sit</i> amet, ea <u>commodo</u> consequat.</p>
...

will be parsed to the following Seam text:


...
[Lorem ipsum=>http://mysite.com] *dolor sit* amet, ea _commodo_ consequat.
...

Accordingly, if the Seam text is passed to the component it will be parsed to HTML code.





















On the screenshot there are CSS selectors that define styles for component elements.




In order to redefine styles for all <rich:editor> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.richfacesSkin .mceButton {                                 
    
border: 1px solid red;             
}  
...

This is the result:


It's also possible to change styles of a particular <rich:editor> component. In this case you should create own style classes and use them in corresponding <rich:editor> "styleClass" attributes. An example is placed below:

Example:


...
.myClass{  
    
margin-top: 20px;
}
...

The "styleClass" attribute for <rich:editor> is defined as it's shown in the example below:

Example:


<rich:editor value="#{bean.text}" styleClass="myClass"/>


dndParam is used during drag-and-drop operations to pass parameters to an indicator. At first, a parameter type is defined with the type attribute (to specify parameter functionality), then a parameter name could be defined with the name and value attribute. Although, it's possible to use nested content defined inside dndParam for value definition, instead of the attribute.

Variants of usage:

In this case, dndParam is of a drag type and is defined in the following way:

Example:


...
    <rich:dragSupport ...> 
        <rich:dndParam type="drag" name="dragging"> 
            <h:graphicImage value="/img/product1_small.png"/> 
        </rich:dndParam> 
        <h:graphicImage value="product1.png"/> 
    </rich:dragSupport>
...

Here dndParam defines an icon that is used by an indicator when a drag is on the place of a default icon (e.g. a minimized image of a draggable element)

In this case dndParam is of a drag type and is defined in the following way:

Example:


...
    <rich:dragSupport ...> 
        <rich:dndParam type="drag" name="label" value="#{msg.subj}"/>
        ...
    </rich:dragSupport>
...

The parameter is transmitted into an indicator for usage in an informational part of the dragIndicator component (inside an indicator a call to {label} happens)

In this case dndParam is of a drop type and is defined in the following way:

Example:


...
    <rich:dropSupport ...> 
        <rich:dndParam type="drop" name="comp" > 
            <h:graphicImage height="16" width="16" value="/images/comp.png"/> 
        </rich:dndParam>
        ...
    </rich:dropSupport >
...

Here, dndParam passes icons into an indicator, if dragged content of a comp type is above the given drop zone that processes it on the next drop event.

On the component LiveDemo page you can see the example of <rich:dndParam> usage and sources for the given example.



In the simplest way the component could be defined empty - in that case a default indicator is shown like this:


For indicator customization you need to define one of the following facets:

  • "single"

Indicator shown when dragging a single element.

  • "multiple"

Indicator shown when dragging several components (for future components that will support multiple selection).

Thus for specify a look-and-feel you have to define one of these facets and include into it a content that should be shown in indicator.

On the component LiveDemo page you can see the example of <rich:dragIndicator> usage and sources for the given example.

Table 6.206. rich : dragSupport attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
disableDefaultDisable default action for target event (append "return false;" to JavaScript)
dragIndicatorId of a component that is used as drag pointer during the drag operation
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeA drag zone type that is used for zone definition, which elements can be accepted by a drop zone
dragValueData to be sent to a drop zone after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
grabbingCursorslist of comma separated cursors that indicates then the you has grabbed something
grabCursorsList of comma separated cursors that indicates then you can grab and drag an object
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
ondragendA JavaScript event handler called after a drag operation
ondragstartA JavaScript event handler called before drag operation
ondropoutA JavaScript event handler called after a out operation
ondropoverA JavaScript event handler called after a drop operation
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component


The dragSupport tag inside a component completely specifies the events and JavaScript required to use the component and it's children for dragging as part of a drag-and-drop operation. In order to work, though, dragSupport must be placed inside a wrapper component that outputs child components and that has the right events defined on it. Thus, this example won't work, because the <h:column> tag doesn't provide the necessary properties for redefining events on the client:

Example:


...
    <h:column>
        <rich:dragSupport dragIndicator=":form:iii" dragType="text">
            <a4j:actionparam value="#{caps.name}" name="name"/>
        </rich:dragSupport>
        <h:outputText value="#{caps.name}"/> 
    </h:column>
...

However, using a4j:outputPanel as a wrapper inside <h:column> , the following code could be used successfully:

Example:


...
    <h:column>
        <a4j:outputPanel>
            <rich:dragSupport dragIndicator=":form:iii" dragType="text">
                <a4j:actionparam value="#{caps.name}" name="name"/>
            </rich:dragSupport>
            <h:outputText value="#{caps.name}"/> 
        </a4j:outputPanel>
    </h:column>
...

This code makes all rows of this column draggable.

One of the main attributes for dragSupport is "dragType" , which associates a name with the drag zone. Only drop zones with this name as an acceptable type can be used in drag-and-drop operations. Here is an example:

Example:


...
    <h:panelGrid id="drag1">
        <rich:dragSupport dragType="singleItems" .../>
        <!--Some content to be dragged-->
    </h:panelGrid>      
...
    <h:panelGrid id="drag2">
        <rich:dragSupport dragType="groups" .../>
        <!--Some content to be dragged-->
    </h:panelGrid>      
...
    <h:panelGrid id="drop1">
        <rich:dropSupport acceptedTypes="singleItems" .../>
        <!--Drop zone content-->
    </h:panelGrid>
...

In this example, the drop1 panel grid is a drop zone that invokes drag-and-drop for drops of items from the first drag1 panel grid, but not the second drag2 panel grid. In the section about dropSupport , you will find an example that shows more detailed information about moving data between tables with drag and drop.

The dragSupport component also has a "value" attribute for passing data into the processing after a drop event.

One more important attribute for <rich:dragSupport> is the "dragIndicator" attribute that point to the component id of the <rich:dragIndicator> component to be used for dragged items from this drag zone. If it isn't defined, a default indicator for drag operations is used.

Finally, the component has the following extra attributes for event processing on the client:

You can use your own custom JavaScript functions to handle these events.

On the component Live Demo page you can see the example of <rich:dragSupport> usage and sources for the given example.

Table 6.208. rich : dropSupport attributes

Attribute NameDescription
acceptCursorsList of comma separated cursors that indicates when acceptable draggable over dropzone
acceptedTypesA list of drag zones types, which elements are accepted by a drop zone
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
cursorTypeMappingMapping between drop types and acceptable cursors
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableDefaultDisable default action for target event (append "return false;" to JavaScript)
dropListenerMethodBinding representing an action listener method that will be notified after drop operation.
dropValueData to be processed after a drop event
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
ondragenterA JavaScript event handler called on enter draggable object to zone
ondragexitA JavaScript event handler called after a drag object leaves zone
ondropA JavaScript event handler called after a drag object is dropped to zone
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rejectCursorsList of comma separated cursors that indicates when rejectable draggable over dropzone
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
typeMappingThe attribute associates a type of dragable zone (dragType) with <rich:dndParam> defined for <rich:dropSupport> for passing parameter value to <rich:dragIndicator>. It uses JSON format: (drag_type: parameter_name).
valueThe current value for this component


The key attribute for <rich:dropSupport> is "acceptedTypes" . It defines, which types of dragable items (zones) could be accepted by the current drop zone. Check the example below:


...
<rich:panel styleClass="dropTargetPanel">
     <f:facet name="header">
          <h:outputText value="PHP Frameworks" />
     </f:facet>
     
     <rich:dropSupport id="php" acceptedTypes="PHP" dropValue="PHP" dropListener="#{eventBean.processDrop}" reRender="phptable, src">
     </rich:dropSupport>
     ...
</rich:panel>
...

and here is what happens on the page:


Using the "typeMapping" attribute. Previous example shows that a drop zone could accept a dragable item or not. Special markers, which are placed at <rich:dragIndicator> , inform user about drop zone’s possible behaviors: "checkmark" appears if drop is accepted and "No" symbol if it is not. Moreover, some extra information (e.g. text message) could be put into the Indicator to reinforce the signal about drop zone’s behavior or pass some other additional sense. This reinforcement could be programmed and attributed to drop zone via "typeMapping" attribute using JSON syntax. The type of dragged zone (dragType) should be passed as "key" and name of <rich:dndParam> that gives needed message to Indicator as "value":


...
<rich:panel styleClass="dropTargetPanel">
     <f:facet name="header">
          <h:outputText value="PHP Frameworks" />
     </f:facet>
     
     <rich:dropSupport id="php" acceptedTypes="PHP" dropValue="PHP" dropListener="#{eventBean.processDrop}" reRender="phptable, src" 
                              typeMapping="{PHP: text_for_accepting, DNET: text_for_rejecting}">
          <rich:dndParam name="text_for_accepting" value="Drop accepted!" />
          <rich:dndParam name="text_for_rejecting" value="Drop is not accepted!" />
     </rich:dropSupport>
     ...
</rich:panel>
...

What happens on the page:


In examples above dropping a dragable item triggers the use a parameter in the event processing; Ajax request is sent and dropListener defined for the component is called.

Here is an example of moving records between tables. The example describes all the pieces for drag-and-drop. (To get extra information on these components, read the sections for these components.)

As draggable items, this table contains a list of such items designated as being of type "text" :

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals}" var="caps">
        <f:facet name="caption">Capitals List</f:facet>
        <h:column>
        <a4j:outputPanel>
            <rich:dragSupport dragIndicator=":form:ind" dragType="text">
                <a4j:actionparam value="#{caps.name}" name="name"/>
            </rich:dragSupport>
            <h:outputText value="#{caps.name}"/> 
        </a4j:outputPanel>
        </h:column>
    </rich:dataTable>
...

As a drop zone, this panel will accept draggable items of type text and then rerender an element with the ID of box :

Example:


...
    <rich:panel style="width:100px;height:100px;">
        <f:facet name="header">Drop Zone</f:facet>
        <rich:dropSupport acceptedTypes="text" reRender="box" 
                        dropListener="#{capitalsBean.addCapital2}"/>
    </rich:panel>
...

As a part of the page that can be updated in a partial page update, this table has an ID of box :

Example:


...
    <rich:dataTable value="#{capitalsBean.capitals2}" var="cap2" id="box">
        <f:facet name="caption">Capitals chosen</f:facet>
        <h:column>
            <h:outputText value="#{cap2.name}"/>
        </h:column>
    </rich:dataTable>
...

And finally, as a listener, this listener will implement the dropped element:

Example:

...

    public void addCapital2(DropEvent event) {
        FacesContext context = FacesContext.getCurrentInstance();
        Capital cap = new Capital();
        cap.setName(context.getExternalContext().getRequestParameterMap().get("name").toString());
        capitals2.add(cap);
    }
...

Here is the result after a few drops of items from the first table:


In this example, items are dragged element-by-element from the rendered list in the first table and dropped on a panel in the middle. After each drop, a drop event is generated and a common Ajax request is performed that renders results in the third table.

As with every Ajax action component, <rich:dropSupport> has all the common attributes ( "timeout" , "limitToList" , "reRender" , etc.) for Ajax request customization.

Finally, the component has the following extra attributes for event processing on the client:

  • "ondragenter"

  • "ondragexit"

  • "ondrop"

  • "ondropend"

Developers can use their own custom JavaScript functions to handle these events.

Information about the "process" attribute usage you can find in the "Decide what to process" guide section .

On the component Live Demo page you can see the example of <rich:dropSupport> usage and sources for the given example.



The <rich:dragListener> is used as a nested tag with components like <rich:dragSupport> , <rich:tree> and <rich:treeNode> .

Attribute "type" defines the fully qualified Java class name for a listener. This class should implement org.richfaces.event.DropListener interface.

The typical variant of using:


...
<h:panelGrid id="dragPanel">
    <rich:dragSupport dragType="item">
        <rich:dragListener type="demo.ListenerBean"/>   
    </rich:dragSupport>
    <!--Some content to be dragged-->
</h:panelGrid>
...

Java bean source:

package demo;


import org.richfaces.event.DragEvent;
public class ListenerBean implements org.richfaces.event.DragListener{
... 
    public void processDrag(DragEvent arg0){
        //Custom Developer Code 
    }
...
}


The <rich:dropListener> is used as a nested tag with components like <rich:dropSupport> , <rich:tree> and <rich:treeNode> .

Attribute "type" defines the fully qualified Java class name for the listener. This class should implement org.richfaces.event.DropListener interface. .

The typical variant of using:


...
<rich:panel style="width:100px;height:100px;">
    <f:facet name="header">Drop Zone</f:facet>
    <rich:dropSupport acceptedTypes="text"> 
        <rich:dropListener type="demo.ListenerBean"/>
    </rich:dropSupport>             
</rich:panel>
...

Java bean source:

package demo;


import org.richfaces.event.DropEvent;
public class ListenerBean implements org.richfaces.event.DropListener{
... 
    public void processDrop(DropEvent arg0){
        //Custom Developer Code 
    }
...
}

Table 6.214. rich : dropDownMenu attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
directionDefines direction of the popup list to appear. Possible values are "top-right", "top-right", "top-left", "bottom-right", "bottom-left", "auto". Default value is "auto".
disabledAttribute 'disabled' provides possibility to make the whole menu disabled if its value equals to "true". Default value is "false"
disabledItemClassSpace-separated list of CSS style class(es) that are be applied to disabled item of this component
disabledItemStyleCSS style(s) is/are to be applied to disabled item when this component is rendered.
disabledLabelClassSpace-separated list of CSS style class(es) applied to dropdown menu label when it is disabled.
eventDefines the event on the representation element that triggers the menu's appearance.
hideDelayDelay between losing focus and menu closing. Default value is "800".
horizontalOffsetSets the horizontal offset between popup list and label element. Default value is "0". conjunction point
idEvery component may have a unique id that is automatically created if omitted
itemClassSpace-separated list of CSS style class(es) that are be applied to item of this component
itemStyleCSS style(s) is/are to be applied to item when this component is rendered.
jointPointSets the corner of the label for the pop-up to be connected with. Possible values are "tr", "tl", "bl", "br", "bottom-left", "auto". Default value is "auto". "tr" stands for top-right.
labelClassSpace-separated list of CSS style class(es) applied to dropdown menu label in it normal (neither selected nor disabled) sate.
oncollapseHTML: script expression; a menu is collapsed.
onexpandHTML: script expression; a menu is expanded.
ongroupactivateHTML: script expression; some group was activated.
onitemselectHTML: script expression; some item was selected.
onmousemoveHTML: script expression; a pointer was moved within.
onmouseoutHTML: script expression; a pointer was moved away.
onmouseoverHTML: script expression; a pointer was moved onto.
popupWidthSets minimal width for all lists that will appear.
renderedIf "false", this component is not rendered
selectedLabelClassSpace-separated list of CSS style class(es) applied to dropdown menu label when it is selected.
selectItemClassSpace-separated list of CSS style class(es) that are be applied to selected item of this component.
selectItemStyleCSS style(s) is/are to be applied to selected item when this component is rendered.
showDelayDelay between event and menu showing. Default value is "50".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
submitModeSets the submission mode for all menu items of the menu except ones where this attribute redefined. Possible values are "ajax","server","none". Default value is "sever".
valueDefines representation text for Label used for menu calls.
verticalOffsetSets the vertical offset between popup list and label element. Default value is "0". conjunction point


All attributes except "value" are optional. The "value" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "value" attribute.

Here is an example:

Example:


...
<f:facet name="label">
    <h:graphicImage value="/images/img1.png"/>
</f:facet>
...

Use the "event" attribute to define an event for the represented element that triggers a menu appearance. An example of a menu appearance on a click can be seen below.

Example:


...
<rich:dropDownMenu event="onclick" value="Item1">
    <!--Nested menu components-->
</rich:dropDownMenu>
...

The <rich:dropDownMenu> "submitMode" attribute can be set to three possible parameters:

Regular form submission request is used.

Ajax submission is used for switching.

The "action" and "actionListener" item's attributes are ignored. Menu items don't fire any submits themselves. The behavior is fully defined by the components nested into items.

The "direction" and "jointPoint" attributes are used for defining aspects of menu appearance.

Possible values for the "direction" attribute are:

Possible values for the "jointPoint" attribute are:

By default, the "direction" and "jointPoint" attributes are set to "auto".

Here is an example:

Example:


...
<rich:dropDownMenu value="File" direction="bottom-right" jointPoint="bl">
    <rich:menuItem submitMode="ajax" value="New" action="#{ddmenu.doNew}"/>
    <rich:menuItem   submitMode="ajax"  value="Open" action="#{ddmenu.doOpen}"/>
    <rich:menuGroup value="Save As...">
        <rich:menuItem   submitMode="ajax" value="Text File"  action="#{ddmenu.doSaveText}"/>
        <rich:menuItem   submitMode="ajax" value="PDF File"  action="#{ddmenu.doSavePDF}"/>
    </rich:menuGroup>
    <rich:menuItem  submitMode="ajax" value="Close" action="#{ddmenu.doClose}"/>
    <rich:menuSeparator id="menuSeparator11"/>
    <rich:menuItem  submitMode="ajax" value="Exit"  action="#{ddmenu.doExit}"/>
</rich:dropDownMenu>
...

This is the result:


You can correct an offset of the pop-up list relative to the label using the following attributes: "horizontalOffset" and "verticalOffset" .

Here is an example:

Example:


...
<rich:dropDownMenu value="File" direction="bottom-right" jointPoint="tr" horizontalOffset="-15" verticalOffset="0">
    <rich:menuItem submitMode="ajax" value="New" action="#{ddmenu.doNew}"/>
    <rich:menuItem   submitMode="ajax"  value="Open" action="#{ddmenu.doOpen}"/>
    <rich:menuGroup value="Save As...">
        <rich:menuItem   submitMode="ajax" value="Text File"  action="#{ddmenu.doSaveText}"/>
        <rich:menuItem   submitMode="ajax" value="PDF File"  action="#{ddmenu.doSavePDF}"/>
    </rich:menuGroup>
    <rich:menuItem  submitMode="ajax" value="Close" action="#{ddmenu.doClose}"/>
    <rich:menuSeparator id="menuSeparator11"/>
    <rich:menuItem  submitMode="ajax" value="Exit"  action="#{ddmenu.doExit}"/>
</rich:dropDownMenu>
...

This is the result:


The "disabled" attribute is used for disabling whole <rich:dropDownMenu> component. In this case it is necessary to define "disabled" attribute as "true". An example is placed below.

Example:


...
<rich:dropDownMenu value="File"  disabled="true">
    ...
</rich:dropDownMenu>
...

On the screenshot there are classes names that define styles for component elements.



On the screenshot there are classes names that define styles for component elements.



In order to redefine styles for all <rich:dropDownMenu> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:


...
.rich-ddmenu-label-select{
    
background-color:  #fae6b0;
    
border-color: #e5973e;
}
...

This is a result:


In the example a label select background color and border color were changed.

Also it's possible to change styles of particular <rich:dropDownMenu> component. In this case you should create own style classes and use them in corresponding <rich:dropDownMenu> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-style: italic;
}
...

The "itemClass" attribute for <rich:dropDownMenu> is defined as it's shown in the example below:

Example:


<rich:dropDownMenu ... itemClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for items was changed.

On the component LiveDemo page you can see the example of <rich:dropDownMenu> usage and sources for the given example.

Table 6.223. rich : extendedDataTable attributes

Attribute NameDescription
activeClassCSS class for active row
activeRowKeyRequest scope attribute under which the activeRowKey will be accessible
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
alignDeprecated. This attribute specifies the position of the table with respect to the document. The possible values are "left", "center" and "right". The default value is "left".
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width of the frame around a component. Default value is "0"
captionClassSpace-separated list of CSS style class(es) that are be applied to caption for this component
captionStyleCSS style(s) is/are to be applied to caption when this component is rendered
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. Default value is "0"
cellspacingThis attribute specifies the amount of space between the border of the cell and its contents. The attribute also specifies the amount of space to leave between cells. Default value is "0"
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
enableContextMenuIf set to true, table header context menu will be enabled
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to footer for this component
frameThis attribute specifies which sides of the frame surrounding a table will be visible. Possible values: "void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box" and "border". The default value is "void".
groupingColumnDefines an id of column which the data is grouped by.
headerClassSpace-separated list of CSS style class(es) that are be applied to header for this component
heightDefines a height of the component. Default value is "500px"
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
noDataLabelDefines label to be displayed in case there are no data rows.
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseMoveHTML: a script expression; a pointer is moved within of row
onRowMouseOutHTML: a script expression; a pointer is moved away of row
onRowMouseOverHTML: a script expression; a pointer is moved onto of row
onRowMouseUpHTML: script expression; a pointer button is released on row
onselectionchangeHTML: script expression to invoke on changing of rows selection
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
selectedClassCSS class for selected rows
selectionValue binding representing selected rows
selectionModeSingle row can be selected. multi: Multiple rows can be selected. none: no rows can be selected. Default value is "single"
sortModeDefines mode of sorting. Possible values are 'single' for sorting of one column and 'multi' for some.
sortPriorityDefines a set of column ids in the order the columns could be set
stateVarThe attribute provides access to a component state on the client side
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tableStateValueBinding pointing at a property of a String to hold table state
titleAdvisory title information about markup elements generated for this component
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthThis attribute specifies the desired width of the entire table and is intended for visual user agents. When the value is percentage value, the value is relative to the user agent's available horizontal space. In the absence of any width specification, table width is determined by the user agent


The <rich:extendedDataTable> component is similar to the <rich:dataTable> . The data in component is scrollable. You can also set the type of selection ( "none", "single" or "multi" lines). Selection of multiple lines is possible using Shift and Ctrl keys.

Here is an example:

Example:


...
<rich:extendedDataTable id="edt" value="#{extendedDT.dataModel}" var="edt" width="500px" height="500px" selectedClass="dataTableSelectedRow" sortMode="single" selectionMode="multi" selection="#{extendedDT.selection}" rowKeyVar="rkvar" tableState="#{extendedDT.tableState}">
       <rich:column id="id" headerClass="dataTableHeader" width="50" label="Id" sortable="true" sortBy="#{edt.id}" sortIconAscending="dataTableAscIcon" sortIconDescending="dataTableDescIcon">
              <f:facet name="header">
                     <h:outputText value="Id" />
              </f:facet>
              <h:outputText value="#{edt.id}" />
       </rich:column>
       <rich:column id="name" width="300" headerClass="dataTableHeader" label="Name" sortable="true" sortBy="#{edt.name}" sortIconAscending="dataTableAscIcon" sortIconDescending="dataTableDescIcon" filterBy="#{edt.name}" filterEvent="onkeyup" visible="false"> 
              <f:facet name="header"> 
                     <h:outputText value="Name" />
              </f:facet>
              <h:outputText value="#{edt.name}" />
       </rich:column>
       <rich:column id="date" width="100" headerClass="dataTableHeader" label="Date" sortable="true" comparator="#{extendedDT.dateComparator}" sortIconAscending="dataTableAscIcon" sortIconDescending="dataTableDescIcon">
              <f:facet name="header">
                     <h:outputText value="Date" />
              </f:facet>
              <h:outputText value="#{edt.date}"><f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />
              </h:outputText>
       </rich:column>
       <rich:column id="group" width="50" headerClass="dataTableHeader" label="Group" sortable="true" sortBy="#{edt.group}" sortIconAscending="dataTableAscIcon" sortIconDescending="dataTableDescIcon">
              <f:facet name="header">
                     <h:outputText value="Group" />
              </f:facet>
              <h:outputText value="#{edt.group}" />
       </rich:column>
</rich:extendedDataTable>
...

Information about sorting and filtering can be found here.

For external filtering <rich:extendedDataTable> component supports "filter" facet for <rich:column> component. In this facet you can define your own controls for filtering which will be positioned like built-in filter controls. Rest of the filter scenario is the same as described here.

In the example "selection" attribute contains object with selected rows.

Note:

Attribute "height" is mandatory. The default value is "500px" .

Menu on the right side of the column header is used to perform action: sorting, grouping, hiding columns.

This is an example:


After selecting a "Group by this column" option, you can see the data grouped. You can collapse and expand groups by clicking on a group header.

This is an example:


The "label" attribute in <rich:column> sets the name of the column, which is used when dragging columns (in drag window) and in context menu, in "Columns" submenu.

Example:


...
<rich:column id="name" label="#{msg['name']}"
...

In the component <rich:extendedDataTable> columns can hidden:


"tableState" attribute can be used to bind state of the table (column width, column position, visible, sequence, grouping...) to a backing-bean string property, for a later used. This state can be for example saved to a database, and it is different form standard JSF state saving mechanisms.

Example:


...
<rich:extendedDataTable tableState="#{extendedDT.tableState}">
...

Table 6.235. rich : menuGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
directionDefines direction of the popup sublist to appear ("right", "left", "auto"(Default), "left-down", "left-up", "right-down", "right-up")
disabledIf "true" sets state of the item to disabled state. Default value is "false".
eventDefines the event on the representation element that triggers the menu's appearance. Default value is "onmouseover".
iconPath to the icon to be displayed for the enabled item state
iconClassClass to be applied to icon element
iconDisabledPath to the icon to be displayed for the disabled item state
iconFolderPath to the folder icon to be displayed for the enabled item state
iconFolderDisabledPath to the folder icon to be displayed for the enabled item state
iconStyleCSS style rules to be applied to icon element
idEvery component may have a unique id that is automatically created if omitted
labelClassClass to be applied to label element
oncloseHTML: script expression; group was closed
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onopenHTML: script expression; group was opened
renderedIf "false", this component is not rendered
selectClassClass to be applied to selected items
selectStyleCSS style rules to be applied to selected items
showDelayDelay between event and menu showing. Default value is "300".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
valueDefines representation text for menuItem


The "value" attribute defines the text representation of a group element in the page.

The "icon" attribute defines an icon for the component. The "iconDisabled" attribute defines an icon for when the group is disabled. Also you can use the "icon" and "iconDisabled" facets. If the facets are defined, the corresponding "icon" and "iconDisabled" attributes are ignored and the facets' contents are used as icons. This could be used for an item check box implementation.

Here is an example:


...
    <f:facet name="icon">
        <h:selectBooleanCheckbox value="#{bean.property}"/>
    </f:facet>
...

The "iconFolder" and "iconFolderDisabled" attributes are defined for using icons as folder icons. The "iconFolder" and "iconFolderDisabled" facets use their contents as folder icon representations in place of the attribute values.

The "direction" attribute is used to define which way to display the menu as shown in the example below:

Possible values are:

By default, the "direction" attribute is set to "auto".

Here is an example:


...
        <rich:menuGroup value="Save As..." direction="left-down">
                <rich:menuItem   submitMode="ajax" value="Text File"  action="#{ddmenu.doSaveText}"/>
                <rich:menuItem   submitMode="ajax" value="PDF File"  action="#{ddmenu.doSavePDF}"/>
        </rich:menuGroup>
...

This would be the result:


Note:

The <rich:menuGroup> component was designed to be used only for pop-up menu list creation.

On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:menuGroup> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-menu-item-label-disabled{
        
font-style: italic;
}
...

This is a result:


In the example a disabled label font style was changed.

Also it's possible to change styles of particular <rich:menuGroup> component. In this case you should create own style classes and use them in corresponding <rich:menuGroup> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
background-color: #acbece; 
    
border: none;
}
...

The "selectClass" attribute for <rich:menuGroup> is defined as it's shown in the example below:

Example:


<rich:menuGroup value="Save As..." selectClass="myClass">

This is a result:


As it could be seen on the picture above, the background color for selected class was changed. Also selected class has no border.

On the component LiveDemo page you can see the example of <rich:menuGroup> usage and sources for the given example.

Table 6.243. rich : menuItem attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf "true" sets state of the item to disabled state. Default value is "false".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
iconPath to the icon to be displayed for the enabled item state
iconClassClass to be applied to icon element
iconDisabledPath to the icon to be displayed for the disabled item state.
iconStyleCSS style rules to be applied to icon element
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelClassClass to be applied to label element
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when you select some menu item
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
selectClassClass to be applied to selected items
selectStyleCSS style rules to be applied to selected items
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
submitModeSets the submission mode. Possible values are "ajax", "server", "none". Default value is "server".
targetName of a frame where the resource retrieved via this hyperlink is to be displayed
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component


The "value" attribute defines the text representation for an item element.

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item. Also you can use the "icon" and "iconDisabled" facets. If the facets are defined, the corresponding "icon" and "iconDisabled" attributes are ignored and the facets content is shown as an icon. It could be used for an item check box implementation.

Here is an example:


...
    <f:facet name="icon">
        <h:selectBooleanCheckbox value="#{bean.property}"/>
    </f:facet>
...

The <rich:menuItem> "submitMode" attribute can be set to three possible parameters:

Regular form submission request is used.

Ajax submission is used for switching.

The "action" and "actionListener" item's attributes are ignored. Menu items don' fire any submits themselves. The behavior is fully defined by the components nested into items.

For example, you can put any content into an item, but, in this case, you should set the "submitMode" attribute as "none" .

Here is an example:


...
    <rich:dropDownMenu>
        ...
        <rich:menuItem submitMode="none">
            <h:outputLink value="www.jboss.org"/>
        </rich:menuItem>
        ...
    <rich:dropDownMenu>
...

You can use the "disabled" attribute to set the item state.

Here is an example:


...
    <rich:dropDownMenu>
        <rich:menuItem value="Disable" disabled="true"/>
    <rich:dropDownMenu>
...

Information about the "process" attribute usage you can find here.

On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:menuItem> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-menu-item-disabled{
        
font-style: italic;
}
...

This is a result:


In the example a disabled item font style was changed.

Also it's possible to change styles of particular <rich:menuItem> component. In this case you should create own style classes and use them in corresponding <rich:menuItem> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
border-color: #bed6f8;
        
background-color: #ffffff;
}
...

The "styleClass" attribute for <rich:menuItem> is defined as it's shown in the example below:

Example:


<rich:menuItem ... selectStyle="myClass">

This is a result:


As it could be seen on the picture above, the background color and border color for selected item were changed.

On the component LiveDemo page you can see the example of <rich:menuItem> usage and sources for the given example.



On the component LiveDemo page you can see the example of <rich:menuSeparator> usage and sources for the given example.



It is possible to use <rich:effect> in two modes:

Those a the typical variants of using:


...
<!-- attaching by event  -->
<rich:panel>
    <rich:effect event="onmouseout" type="Opacity" params="duration:0.8,from:1.0,to:0.3" />
    .... panel content ....
</rich:panel>
...

<!--  invoking from JavaScript -->
<div id="contentDiv">
  ..... div content ......
</div>

<input type="button" onclick="hideDiv({duration:0.7})" value="Hide" />
<input type="button" onclick="showDiv()" value="Show" />

<rich:effect  name="hideDiv"  for="contentDiv" type="Fade" />
<rich:effect  name="showDiv"  for="contentDiv" type="Appear" />

<!-- attaching to window on load and applying on particular page element -->
<rich:effect for="window" event="onload" type="Appear" params="targetId:'contentDiv',duration:0.8,from:0.3,to:1.0" />
...


"name" attribute defines a name of the JavaScript function that is be generated on a page when the component is rendered. You can invoke this function to activate the effect. The function accesses one parameter. It is a set of effect options in JSON format.

"type" attribute defines the type of an effect. For example, "Fade", "Blind", "Opacity". Have a look at scriptaculous documentation for set of available effect.

"for" attribute defines the id of the component or html tag, the effect is attached to. RichFaces converts the "for" attribute value to the client id of the component if such component is found. If not, the value is left as is for possible wiring with on the DOM element's id on the client side. By default, the target of the effect is the same element that effect pointed to. However, the target element is might be overridden with "targetId" option passed with "params" attribute of with function paramenter.

"params" attribute allows to define the set of options possible for particurar effect. For example, 'duration', 'delay', 'from', 'to'. Additionally to the options used by the effect itself, there are two option that might override the <rich:effect> attribute. Those are:

  • "targetId" allows to re-define the target of effect. The option is override the value of "for" attribute.

  • "type" defines the effect type. The option is override the value of "type" attribute.

You can use a set of effects directly without defining the <rich:effect> component on a page if it's convenient for you. For that, load the scriptaculous library to the page with the following code:

Example:


...
<a4j:loadScript src="resource://scriptaculous/effect.js" />
...

If you do use the <rich:effect> component, there is no need to include this library because it's already here.

For more information look at RichFaces Users Forum.

Here you can get additional information how to create an image banner using <rich:effect> and <a4j:poll> components and here how to create a HTML banner.

Here you can find information how to make a Slide Show with help of the <rich:effect> and <a4j:poll> components.

On the component LiveDemo page you can see the example of <rich:effect> usage.

How to save <rich:effect> status see on the RichFaces Users Forum.

Table 6.258. rich : fileUpload attributes

Attribute NameDescription
acceptedTypesFiles types allowed to upload
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
addButtonClassCSS style for add button
addButtonClassDisabledCSS style for add button disabled
addControlLabelDefines a label for an add button
ajaxSingleBoolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only. Default value is "false"
allowFlashAttribute which allow the component to use the flash module that provides file upload functionality [false, true, auto]. Default value is "false"
altFor a user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the lang attribute
autoclearIf this attribute is "true" files will be immediately removed from list after upload completed. Default value is "false".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
cancelEntryControlLabelDefines a label for a cancel control
cleanButtonClassCSS style for clean button
cleanButtonClassDisabledCSS style for clean button disabled
clearAllControlLabelDefines a label for a clearAll button
clearControlLabelDefines a label for a clear control
disabledAttribute 'disabled' provides a possibility to make the whole component disabled if its value equals to "true". Default value is "false".
doneLabelDefines a label for a done label
fileEntryClassCSS style upload file entry
fileEntryClassDisabledCSS style upload file entry disabled
fileEntryControlClassCSS style for upload enrty control
fileEntryControlClassDisabledCSS style for upload enrty control disabled
fileUploadListenerMethodExpression representing an action listener method that will be notified after file uploaded.
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
immediateUploadIf this attribute is true files will be immediately uploaded after they have been added in list. Default value is "false".
listHeightDefines height of file list. Default value is "210px".
listWidthDefines width of file list. Default value is "400px".
localeUsed for locale definition
maxFilesQuantityDefines max files count allowed for upload (optional). Default value is "1".
noDuplicateDefines if component should allow to add files that were already in list. Default value is "false".
onaddHTML: script expression; a file is added.
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclearHTML: script expression; the file entries are cleared
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onerrorHTML: script expression; the file uploading is interrupted according to any errors
onfileuploadcompleteHTML: script expression; a file is uploaded to the server
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; some text is selected in a text field. This attribute may be used with the INPUT and TEXTAREA elements
onsizerejectedHTML: script expression; the file uploading is rejected by fiel size overflow
ontyperejectedHTML: script expression; the file type is rejected according to file types allowed
onuploadHTML: script expression; the uploading is cancelled at client side
onuploadcanceledHTML: script expression; uploading is cancelled
onuploadcompleteHTML: script expression; uploading all files from list is completed
progressLabelDefines a label for a progress label
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
sizeErrorLabelDefines a label for a size error label
statusID (in format of call UIComponent.findComponent()) of Request status component
stopButtonClassCSS style for cancel button
stopButtonClassDisabledCSS style for cancel button disabled
stopControlLabelDefines a label for a stop button
stopEntryControlLabelDefines a label for a stop control
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
transferErrorLabelDefines a label for a transfer error label
uploadButtonClassCSS style for upload button
uploadButtonClassDisabledCSS style for upload button disabled
uploadControlLabelDefines a label for an upload button
uploadDataCollection of files uploaded
uploadListClassCSS style for upload list
uploadListClassDisabledCSS style for upload list disabled
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator


The <rich:fileUpload> component consists of two parts:

There are two places where the uploaded files are stored:

The "uploadData" attribute defines the collection of files uploaded. See the example below.

Example:


...
<rich:fileUpload uploadData="#{bean.data}"/>
...

The "fileUploadedListener" is called at server side after every file uploaded and used for the saving files from temporary folder or RAM.

Example:


...
<rich:fileUpload uploadData="#{bean.data}" fileUploadListener="#{bean.listener}"/>
 ...

The following methods for processing the uploaded files are available:

Automatically files uploading could be performed by means of the "immediateUpload" attribute. If the value of this attribute is "true" files are uploaded automatically once they have been added into the list. All next files in the list are uploaded automatically one by one. If you cancel uploading process next files aren't started to upload till you press the "Upload" button or clear the list.

Example:


...
<rich:fileUpload uploadData="#{bean.data}" fileUploadListener="#{bean.listener}" immediateUpload="true"/>
 ...

The "autoclear" attribute is used to remove automatically files from the list after upload completed. See the simple example below.

Example:


...
<rich:fileUpload uploadData="#{bean.data}" autoclear="true"/>
...

Each file in list waiting for upload has link "Cancel" opposite its name. Clicking this link invokes JS API remove() function, which gets $('id').component.entries[i] as a parameter and removes the particular file from list and from the queue for upload. After a file has been uploaded the link "Cancel" changes to "Clear". Clicking "Clear" invokes clear() JS API function, which also gets ID of the particular entry and removes it from the list. Uploaded to server file itself is kept untouched.

The <rich:fileUpload> component provides following restrictions:

The <rich:fileUpload> component provides a number of specific event attributes:

The <rich:fileUpload> component has an embedded Flash module that adds extra functionality to the component. The module is enabled with "allowFlash" attribute set to "true".

These are the additional features that the Flash module provides:

Apart from uploading files to the sever without using AJAX, the Flash module provides a number of useful API functions that can be used to obtain information about the uploaded file.

There are 2 ways to obtain the data stored in the FileUploadEntry object.

  • By means of JavaScript on the client side. Use the following syntax for that entries[i].propertyName. For example entries[0].state will return the state of the file the is being processed or has just been processed.

  • The properties of FileUploadEntry object can be retrieved using the entry.propertyName expression in the specific event attributes. For example, onupload="alert(event.memo.entry.fileName);" will display a message with the name of the file at the very moment when upload operation starts. A full list of properties can be found here.

The given bellow code sample demonstrates how the properties can be used. Please study it carefully.


...
            <head>
                  <script>
                        function _onaddHandler (e) {
                             var i = 0;
                             for (; i < e.memo.entries.lenghti++) {
                                   alert(e.memo.entries[i].creator);  //Shows creators of the added files
                             }
                        }

                        function _onerrorhandle(e) {
                             alert(e.memo.entry.fileName + "file was not uploaded due  transfer error");
                        }
                  </script>
            </head>
 ...

Moreover, embedded Flash module provides a smoother representation of progress bar during the uploading process: the polling is performed is not by AJAX, but my means of the flash module.


However, the Flash module doens't perform any visual representation of the component.

In order to customize the information regarding the ongoing process you could use "label" facet with the following macrosubstitution:

  • {B}, {KB}, {MB} contains the size of file uploaded in bytes, kilobytes, megabytes respectively

  • {_B}, {_KB}, {_MB} contains the remain file size to upload in bytes, kilobytes, megabytes respectively

  • {ss}, {mm}, {hh} contains elapsed time in seconds, minutes and hours respectively

Example:


...
<rich:fileUpload uploadData="#{bean.data}" fileUploadListener="#{bean.listener}">
        <f:facet name="label">
                <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
        </f:facet>
</rich:fileUpload>
...

This is the result:


You could define labels of the component controls with the help of "addControlLabel" , "clearAllControlLabel" , "clearControlLabel" , "stopEntryControlLabel" , "uploadControlLabel" attributes. See the following example.

Example:


...
<rich:fileUpload addControlLabel="Add file..." clearAllControlLabel="Clear all" clearControlLabel="Clear"
                        stopEntryControlLabel="Stop process" uploadControlLabel="Upload file"/>
...

This is the result:


The <rich:fileUpload> component allows to use sizes attributes:

  • "listHeight" attribute specify height for list of files in pixels

  • "listWidth" attribute specify width for list of files in pixels

In order to disable the whole component you could use the "disabled" attribute. See the following example.

Example:


...
<rich:fileUpload disabled="true"/>
...

This is the result:


It's possible to handle events for fileUpload using JavaScript code. A simplest example of usage JavaScript API is placed below:

Example:


...
<rich:fileUpload  id="upload" disabled="false"/>
<h:commandButton onclick="${rich:component('upload')}.disable();" value="Disable" />
...

<rich:fileUpload> component also provides a number of JavaScript property, that can be used to process uploaded files, file states etc. The given below example illustrates how the entries[0].state property can be used to get access to the file state. Full list of JavaScript properties can be found below.


...
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
        maxFilesQuantity="#{fileUploadBean.uploadsAvailable}"
        id="upload"
        immediateUpload="#{fileUploadBean.autoUpload}"
        acceptedTypes="jpg, gif, png, bmp">
            <a4j:support event="onuploadcomplete" reRender="info"  />
</rich:fileUpload>
<h:commandButton onclick="if($('j_id232:upload').component.entries[0].state == FileUploadEntry.UPLOAD_SUCCESS) alert ('DONE');" value="Check file state"/>
...

The <rich:fileUpload> component allows to use internationalization method to redefine and localize the labels. You could use application resource bundle and define RICH_FILE_UPLOAD_CANCEL_LABEL, RICH_FILE_UPLOAD_STOP_LABEL, RICH_FILE_UPLOAD_ADD_LABEL, RICH_FILE_UPLOAD_UPLOAD_LABEL, RICH_FILE_UPLOAD_CLEAR_LABEL, RICH_FILE_UPLOAD_CLEAR_ALL_LABEL, RICH_FILE_UPLOAD_PROGRESS_LABEL, RICH_FILE_UPLOAD_SIZE_ERROR_LABLE, RICH_FILE_UPLOAD_TRANSFER_ERROR_LABLE, RICH_FILE_UPLOAD_ENTRY_STOP_LABEL, RICH_FILE_UPLOAD_ENTRY_CLEAR_LABEL, RICH_FILE_UPLOAD_ENTRY_CANCEL_LABEL there.

The <rich:fileUpload> component could work together with Seam framework. On RichFaces LiveDemo page you can see how to configure filter for this framework in web.xml file in order to handle <rich:fileUpload> requests.

To make <rich:fileUpload> component work properly with MyFaces extensions, the order in which filters are defined and mapped in web.xml, is important. See corresponding FAQ chapter.


Table 6.261. Client side object properties

PropertyDescription
entriesReturns a array of all files in the list
entries.lengthReturns the number of files in the list
entries[i].fileNameReturns the file name, that is retrieved by the array index
entries[i].state Returns the file state. Possible states are
  • "initialized" - the file is added, corresponds to FileUploadEntry.INITIALIZED constant

  • "progress" - the file is being uploaded, corresponds to FileUploadEntry.UPLOAD_IN_PROGRESS constant

  • "ready" - uploading is in process, corresponds to FileUploadEntry.READY constant The file will be uploaded on queue order.

  • "canceled" - uploading of the file is canceled, corresponds to FileUploadEntry.UPLOAD_CANCELED constant

  • "done" - the file is uploaded successfully, corresponds to FileUploadEntry.UPLOAD_SUCCESS constant

  • "transfer_error" - a file transfer error occurred, corresponds to FileUploadEntry.UPLOAD_TRANSFER_ERROR constant

  • "size_error" - the file exceeded maximum size, corresponds to FileUploadEntry.UPLOAD_SIZE_ERROR constant

entries[i].size Returns the size of the file. Available in flash enabled version only
entries[i].TypeReturns the mime type of the file. Available in flash enabled version only
entries[i].creator Returns the name of the author of the file. Available in flash enabled version only
entries[i].creationDateReturns the date when the file was created. Available in flash enabled version only
entries[i].modificationDateReturns the date of the last file modification. Available in flash enabled version only

Table 6.262. Client side object properties available with specific event attributes

PropertyDescription
entry.state Returns the file state. Possible states are
  • "initialized" - the file is added, corresponds to FileUploadEntry.INITIALIZED constant

  • "progress" - the file is being uploaded, corresponds to FileUploadEntry.UPLOAD_IN_PROGRESS constant

  • "ready" - uploading is in process, corresponds to FileUploadEntry.READY constant The file will be uploaded on queue order.

  • "canceled" - uploading of the file is canceled, corresponds to FileUploadEntry.UPLOAD_CANCELED constant

  • "done" - the file is uploaded successfully, corresponds to FileUploadEntry.UPLOAD_SUCCESS constant

  • "transfer_error" - a file transfer error occurred, corresponds to FileUploadEntry.UPLOAD_TRANSFER_ERROR constant

  • "size_error" - the file exceeded maximum size, corresponds to FileUploadEntry.UPLOAD_SIZE_ERROR constant

entry.fileName Returns the file's name. This property works with all event handlers except for "onadd".
entry.size Returns the size of the file. Available in flash enabled version only
entry.TypeReturns the mime type of the file. Available in flash enabled version only
entry.creator Returns the name of the author of the file. Available in flash enabled version only
entry.creationDateReturns the date when the file was created. Available in flash enabled version only
entry.modificationDateReturns the date of the last file modification. Available in flash enabled version only













The following picture illustrates how CSS classes define styles for component elements.







In order to redefine styles for all <rich:fileUpload> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-fileupload-anc{
    
font-weight:bold;
    
text-decoration:none;
}
...

This is the result:


In the example above the font weight and text decoration for "Cancel" and "Clear" links are changed.

Also it's possible to change styles of particular <rich:fileUpload> component. In this case you should create own style classes and use them in the corresponding <rich:fileUpload> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
font-weight:bold;
}
...

The "addButtonClass" attribute for <rich:fileUpload> is defined as it's shown in the example below:

Example:


<rich:fileUpload ... addButtonClass="myClass"/>

This is the result:


As it could be seen on the picture above, the font style for "Add" button is changed.

On RichFaces LiveDemo page you can see an example of <rich:fileUpload> usage and sources for the given example.

Table 6.280. rich : gmap attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
enableContinuousZoomEnables continuous smooth zooming for selected browsers. Default value is "false".
enableDoubleClickZoomEnables zooming in by a double click. Default value is "false".
enableDraggingEnables a map dragging with the mouse. Default value is "true".
enableInfoWindowEnables Info Window. Default value is "true".
gmapKeyGoogle Map key. A single Map API key is valid for a single "directory" on your web server. Default value is "internal".
gmapVarThe JavaScript variable that is used to access the Google Map API. If you have more than one Google Map components on the same page, use individual key for each of them. The default variable name is "map" (without quotes).
idEvery component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90. Default value is "37.9721046".
lngInitial longitude coordinate in degrees, as a number between -180 and +180. Default value is "-122.0424842834".
localeUsed for locale definition. Default value is "getDefaultLocale()".
mapTypeInitial map type. The possible values are "G_NORMAL_MAP", "G_SATELLITE_MAP", "G_HYBRID_MAP". Default value is "G_SATELLITE_MAP".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
oninitHTML: script expression; the Google Map object is initiated.
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
showGLargeMapControlShows the GLarge control. Default value is "true".
showGMapTypeControlShows the Type switch control. Default value is "true".
showGScaleControlIt shows the scale control. Default value is "true".
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
warningMessageThe warning message that appears if a browser is not compatible with Google Map. Default value is "Your browser does not support Google Maps".
zoomInitial zoom level as a number between 1 and 18. Default value is "17".


To use Google Map in your application, generate a key on Google Map official resource . One key could be used for one directory on the server.

Here are the main settings of initial rendering performed with a component map that are accessible with the following attributes:

  • "zoom" defines an approximation size (boundary values 1-18)

  • "lat" specifies an initial latitude coordinate in degrees, as a number between -90 and +90

  • "lng" specifies an initial longitude coordinate in degrees, as a number between -180 and +180

  • "mapType" specifies a type of a rendered map (G_NORMAL_MAP, G_SATELLITE_MAP (DEFAULT), G_HYBRID_MAP)

For example, the city of Paris is shown after rendering with the following initial settings: lat = "48.44" , lng = "2.24" and zoom = "5" .


It's also possible to set accessible controls on the map with the help of the attributes:

  • "showGMapTypeControl" determines whether the controls for a map type definition are switched on

  • "showGScaleControl" determines whether the controls for scaling are switched on

  • "showGLargeMapControl" determines whether the control for map scale rendering is rendered


To set all these parameters and perform some activity (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of an object on a map in the "gmapVar" attribute and then call the object directly with API Google Map .

For example, to approximate a map for gmapVar = "map" declared inside the component, call map.zoomIn() on an event.

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • "onmouseover"

  • "onclick"

  • "onmouseout"

  • etc.

Note

Google Map does not support XHTML format of the page. Thus, if you use Facelets and JSF 1.2, do not forget to put the following tags somewhere on the page:


...
<f:view contentType="text/html">...</f:view>
...

On the component Live Demo page you can see the example of <rich:gmap> usage and sources for the given example.

Table 6.283. rich : virtualEarth attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dashboardSizeInitial map type. The possible values are "Normal", "Small", "Tiny". Default value is "Normal".
idEvery component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90. Default value is "37.9721046".
lngInitial longitude coordinate in degrees, as a number between -180 and +180. Default value is "-122.04248428346".
mapStyleNavigation control size. Possible values are "Road", "Aerial", "Hybrid", "Birdseye". Default value is "Road"
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onLoadMapHTML: script expression; the Virtual Earth object is initiated.
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
varThe JavaScript variable that is used to access the Virtual Earth API. If you have more than one Virtual Earth components on the same page, use individual key for each of them. Default value name is "map".
versionVirtual earth version, Default value is "6.1".
zoomInitial zoom level as a number between 1 and 18. Default value is "17".


Here are the main settings of initial rendering performed with a component map that are accessible with the following attributes:

For example, the city of Paris is shown after rendering with the following initial settings: lat = "48.833" , lng = "2.40" and zoom = "11" .


Code for this example is placed below:

Example:


...
    <rich:virtualEarth  style="width:800px;" id="vm" lat="48.833" lng="2.40" 
                                     dashboardSize="Normal"  zoom="11" mapStyle="Hybrid" var="map" />
...

To set all these parameters and perform some activity (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of an object on a map in the "var" attribute and then call the object directly with API Microsoft Virtual Earth map .

For example, to approximate a map for var = "map" declared inside the component, call map.ZoomIn() on an event.

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • "onmouseover"

  • "onclick"

  • "onmouseout"

  • etc.

Note

Virtual Earth does not support XHTML format of the page. Thus, if you use Facelets and JSF 1.2, do not forget to put the following tags somewhere on the page:


...
<f:view contentType="text/html">...</f:view>
...

Here you can found additional information about Microsoft Virtual Earth map .

Some additional information about usage of component can be found on its LiveDemo page.

  • Includes all features of the Javascript jQuery Hotkeys Plugin

  • Hot key registration by request through JavaScript API

  • Possibility to attach <rich:hotKey> to a whole page or to a particular element using "selector" attribute

  • Hot key registration timing

  • Enabling/disabling the <rich:hotKey> using JavaScript API



There are two ways to register <rich:hotKey> :

The "key" attribute defines the hot key itself which is processed by the component.

After the hot key has been registered and defined you could set the "handler" attribute which determines a JavaScript function to be called every time when corresponding keys are pressed.

Example:


...
<rich:listShuttle var="cap" sourceValue="#{capitalsBean.capitals}" id="ls">
    <rich:column>
        <f:facet name="header">
            <h:outputText value="State flag"/>
        </f:facet>
        <h:graphicImage value="#{cap.stateFlag}"/>
    </rich:column>
    <rich:column>
        <f:facet name="header">
            <h:outputText value="State name"/>
        </f:facet>
        <h:outputText value="#{cap.name}"/>
    </rich:column>
</rich:listShuttle>
<rich:hotKey selector="#ls" key="right" handler="#{rich:component('ls')}.copy()"/>
<rich:hotKey selector="#ls" key="left" handler="#{rich:component('ls')}.remove()"/>
<rich:hotKey selector="#ls" key="end" handler="#{rich:component('ls')}.copyAll()"/>
<rich:hotKey selector="#ls" key="home" handler="#{rich:component('ls')}.removeAll()"/>
...

In the example above the "selector" attribute is used. So the keys work only if <rich:listShuttle> component is focused.

You could press Right or Left keys in order to move some selected items between lists. You could press Home or End buttons in order to move all items between lists.

With the help of the "timing" attribute you could manage <rich:hotKey> registration timing. There are three possible values of this attribute:

  • "immediate" - the component is rendered in browser immediately (by default)

  • "onload" - the component is rendered after the page is fully loaded

  • "onregistercall" - the component is rendered only after JavaScript API for the key registration is used.

The "type" attribute defines the type of keyboard event. Possible values are: "onkeyup", "onkeypress" and "onkeydown".

The "disableInInput" attribute disables the <rich:hotKey> if it is activated on input elements and the value of this attribute is "true".

The "checkParent" attribute defines the hotkey handling of events generated by child components nested into the parent component to which the <rich:hotKey> is attached.

The <rich:hotKey> component also provides a number of JavaScript API functions. There is an example below.

Example:


...
<h:form id="myForm">
    <rich:hotKey id="myKey" key="ctrl+g" handler="alert('Ctrl+G is pressed')" />
    <button onclick="${rich:component('myKey')}.enable(); return false;">Turn Ctrl+G On</button>
    <button onclick="${rich:component('myKey')}.disable(); return false;">Turn Ctrl+G Off</button>
</h:form>   
...

In the example above the Ctrl+G is registered as a global hotkey, so if you press this key combination the alert window with the "Ctrl+G is pressed" text appears. With the help of enable(), disable() JavaScript API fucntions you could enable or disable registered hotkey.

On RichFaces LiveDemo page you can see an example of <rich:hotKey> usage and sources for the given example.

Table 6.289. rich : inplaceInput attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
cancelControlIconDefines custom cancel icon
changedClassCSS style class for changed state
changedHoverClassCSS style class for hovered text in changed state
controlClassCSS style class for controls
controlHoverClassCSS style class for hovered control
controlPressedClassCSS style class for pressed press controls
controlsHorizontalPositionPositions the controls horizontally. Possible values are "left", "center", "right". Default value is "right".
controlsVerticalPositionPositions the controls vertically. Possible values are "bottom","center" and "top". Default value is "center"
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
defaultLabelThe attribute is used to display text while value is undefined
editClassCSS style class for edit state
editEventProvides an option to assign an JavaScript action that initiates the change of the state. Default value is "onclick".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputWidthSets width of the input field
labelA localized user presentable name for this component.
layoutDefines how the component is displayed in the layout. Possible values are "block", "inline". Default value is "inline".
maxInputWidthSets the maximum width of the input field. Default value is "500px".
maxlengthSpecifies the maximum number of digits that could be entered into the input field. The maximum number is unlimited by default.
minInputWidthSets the minimum width of the input field. Default value is "40px".
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
oneditactivatedHTML: script expression; edit state is activated
oneditactivationProvides a possibility to assign JavaScript on edit state activation
onfocusHTML: script expression; the element got the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; the onselect event occurs when you select some menu item
onviewactivatedHTML: script expression; view state is activated
onviewactivationProvides a possibility to assign JavaScript on view state activation
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
saveControlIconDefines custom save icon
selectOnEditMakes the input field select when switched to edit state. Default value is "false"
showControlsServes to display "save" and "cancel" controls. Default value is "false".
styleClassCorresponds to the HTML class attribute
tabindexServes to define the tabbing order
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
viewClassCSS style class for view state
viewHoverClassCSS style class for hovered text in view state


The <rich:inplaceInput> component was designed to facilitate displaying and inputting(editing) some data.

The "value" attribute is a value-binding expression for the current value of the component.

The component has three functional states:

The "editEvent" attribute provides an option to assign a JavaScript action to initiate the change of the state from view/changed to edit. The default value is "onclick".

Example:


...
<rich:inplaceInput value="#{bean.value}" editEvent="ondblclick"/> 
... 

The <rich:inplaceInput> component provides specific event attributes:

Example:


...
<rich:inplaceInput value="#{bean.value}" oneditactivation="if (!confirm('Are you sure you want to change the value?')){return false;}" />
... 

The given code illustrates how "oneditactivation" attribute works, namely when the state is being changed from view to edit, a confirmation window with a message "Are you sure you want to change value?" comes up.

Using the boolean "selectOnEdit" attribute set to true, the text in the input field will be selected when the change from view/changed state to edit occurs.

This is the result:


If the <rich:inplaceInput> loses focus, input data is saved automatically and the component displays a new value. Additionally, the data is saved when "Enter" is pressed. Nevertheless, you can use the "showControls" attribute, which makes "Save" and "Cancel" buttons appear next to the input field. If the controls are used, data is not saved automatically when the form loses focus: user has to confirm that he/she wants to save/discard the data explicitly. In both cases(with controls or without them) the input data can be discarded by pressing "Esc" key.

Example:


...
<rich:inplaceInput value="#{bean.value}" showControls="true"/>
... 

You can also position the controls relatively to the input field, by means of

  • The "controlsHorizontalPosition" attribute with "left", "right" and "center" definitions

  • The "controlsVerticalPosition " attribute with "bottom", "center" and "top" definitions

Example:


...
<rich:inplaceInput value="#{bean.value}" showControls="true" controlsVerticalPosition="bottom" controlsHorizontalPosition="left"/>
... 

This is the result:


It is also possible to use "controls" facet in order to replace the default controls with facets content. See the example below.

Example:


...
<rich:inplaceInput defaultLabel="Click here to edit" showControls="true" controlsHorizontalPosition="left" controlsVerticalPosition="bottom" id="inplaceInput">
    <f:facet name="controls">
        <button onclick="#{rich:component('inplaceInput')}.save();" type="button">Save</button>
        <button onclick="#{rich:component('inplaceInput')}.cancel();" type="button">Cancel</button>
    </f:facet>
</rich:inplaceInput>
... 

This is the result:


Note:

The "controls" facet also implies using "showControls" attribute and it has to be defined as "true".

Redefinition of the "save" and "cancel" icons can be performed using "saveControlIcon" and "cancelControlIcon" attributes. You need to define the path to where your images are located.

Example:


...
<rich:inplaceInput value="#{bean.value}" defaultLabel='click to edit'
    showControls="true"
    controlsHorizontalPosition="left"
    controlsVerticalPosition="top"
    saveControlIcon="/images/cancel.gif"
    cancelControlIcon="/images/save.gif"/> 
    ... 

The <rich:inplaceInput> component could be rendered with <span> or <div> elements to display its value. In order to change default <span> output, use "layout" attribute with "block" value.

The <rich:inplaceInput> component supports standard "tabindex" attribute. When the component gets focus the edit mode is activated.

The "inputWidth" , "minInputWidth" , "maxInputWidth" attributes are provided to specify the width, minimal width and maximal width for the input element respectively.


On the screenshot there are classes names that define styles for component elements.






In order to redefine styles for all <rich:inplaceInput> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-inplace-field {
    
font-style: italic;
}                     
   
...

This is the result:


In the shown example the font in edit state is changed to bold.

It's aslo possible to change styles of a particular <rich:inplaceInput> component. In this case you should create own style classes and use them in corresponding <rich:inplaceInput> styleClass attributes. An example is placed below:

Example:


...
.myClass {
    
color:  #008cca;
}
...

The "viewClass" attribute for the <rich:inplaceInput> is defined as it's shown in the example below:

Example:


...<rich:inplaceInput value="click to edit" styleClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font color of the text on the component was changed.

On the component Live Demo page you can see the example of <rich:inplaceIput> usage and sources for the given example.

Table 6.302. rich : inplaceSelect attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
cancelControlIconDefines custom cancel icon
changedClassCSS style class for changed state
controlClassCSS style class for controls
controlHoverClassCSS style class for hovered control
controlPressClassCSS style class for controls pressed
controlsHorizontalPositionThe attribute positions the controls horizontally. Possible values are "right","center","left". Default value is "right".
controlsVerticalPositionThe attribute positions the controls vertically. Possible values are "bottom","center" and "top". Default value is "center"
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
defaultLabelThe attribute is used to display text while value is undefined
editClassCSS style class for edit state
editEventThe attribute provides an option to assign an JavaScript action that initiates the change of the state. Default value is "onclick".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelA localized user presentable name for this component.
layoutDefines how the component is displayed in the layout. Possible values are "block", "inline". Default value is "inline".
listHeightThe attribute defines the height of option list. Default value is "200px".
listWidthThe attribute defines the width of option list. Default value is "200px".
maxSelectWidthSets the maximum width of the select element. Default value is "200px".
minSelectWidthSets the minimum width of the select element. Default value is "100px".
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
oneditactivatedHTML: script expression; edit state is activated
oneditactivationThe attributes provide a possibility to assign JavaScript on edit state activation
onfocusHTML: script expression; the element got the focus
oninputblurHTML: script expression; the element lost the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputfocusHTML: script expression; the element got the focus
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; the onselect event occurs when you select some menu item
onviewactivatedHTML: script expression; view state is activated
onviewactivationThe attributes provide a possibility to assign JavaScript on view state activation
openOnEditThe attribute opens the list once edit activated. Default value is "true".
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
saveControlIconDefines custom save icon
selectWidthSets width of the select element
showControlsThe attribute serves to display "save" and "cancel" controls. Default value is "false".
showValueInViewIf "true", shows the SelectItem labels in the InplaceSelect pull-down list, but displays the value in the field in view mode once an item is selected. Default value is "false"
styleClassCorresponds to the HTML class attribute
tabindexThe attribute serves to define the tabbing order
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
viewClassStyle class for view state
viewHoverClassCSS style class for hovered text in view state


The "value" attribute is a value-binding expression for the current value of the component.

The <rich:inplaceSelect> component has three functional states:

You can form the list of the options using <f:selectItem/> and <f:selectItems/> JSF components.

Please, see the example below.

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="click to edit">
    <f:selectItems  value="#{bean.selectItems}"/>
    <f:selectItem itemValue="1" itemLabel="factory"/>
    <f:selectItem itemValue="2" itemLabel="newspaper"/>
</rich:inplaceSelect>
...

In the example above the value of the selected item is available via "value" attribute.

The "editEvent" attribute provides an option to assign an JavaScript action that initiates the change of the state from view to edit. The default value is "onclick".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" defaultLabel="Double Click to edit" editEvent="ondblclick">
    <f:selectItems value="#{demo.selectItems}" />
</rich:inplaceSelect>
...

The <rich:inplaceSelect> component provides specific event attributes:

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" oneditactivation="if (!confirm('Are you sure you want to change the value?')){return false;}">
    <f:selectItems value="#{demo.selectItems}" />
</rich:inplaceSelect>
... 

The given code illustrates how "oneditactivation" attribute works, namely when the state is being changed from view to edit, a confirmation window with a message "Are you sure you want to change value?" comes up.

To prevent opening the drop-down list by default, once edit state is activated, set the "openOnEdit" attribute to "false". The default value is "true".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true" openOnEdit="false">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
...

This is the result:


Nowever, if you want to confirm the data saving explicitly you can use the "showControls" attribute, which makes "Save" and "Cancel" buttons (displayed as icons) appear next to the input field. Edit state can be deactivated by pressing "Esc" key. An option in the drop-drown list can be also selected by pressing "Enter".

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
...

This is the result:


You can also position the controls relatively to the input field, by means of

  • The "controlsHorizontalPosition" attribute with "left", "right" and "center" definitions

  • The "controlsVerticalPosition " attribute with "bottom" and "top" definitions

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" controlsHorizontalPosition="left" controlsVerticalPosition="center" showControls="true">
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
... 

This is the result:


It is also possible to use "controls" facet in order to replace the default controls with facets content. See the example below.

Please, see the example.

Example:


...
<rich:inplaceSelect value="#{bean.inputValue}" showControls="true">
    <f:facet name="controls">
        <button onclick="#{rich:component('inplaceSelect')}.save();" type="button">Save</button>
        <button onclick="#{rich:component('inplaceSelect')}.cancel();" type="button">Cancel</button> 
    </f:facet>  
    <f:selectItems  value="#{bean.selectItems}"/>
</rich:inplaceSelect>
... 

This is the result:


Note:

The "controls" facet also implies using "showControls" attribute and it has to be defined as "true".

The <rich:inplaceSelect> component could be rendered with <span> or <div> elements to display its value. In order to change default <span> output, use the "layout" attribute with "block" value.

The <rich:inplaceSelect> component supports standard "tabindex" attribute. When the component gets focus the edit mode is activated and drop-down list is opened.

The "selectWidth" , "minSelectWidth" and "maxSelectWidth" attributes are provided to specify the width, minimal width and maximal width for the input element respectively.

In order to specify the height and width parameters for the list items of the component, you can use "listHeight" and " listWidth" attributes.

On the screenshot there are classes names that define styles for component elements.








In order to redefine styles for all <rich:inplaceSelect> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-inplace-select-list-decoration{
    
background-color: #ecf4fe;
}                      
   
...

This is the result:


In the shown example the background color for list is changed.

It's aslo possible to change styles of a particular <rich:inplaceSelect> component. In this case you should create own style classes and use them in corresponding <rich:inplaceSelect> styleClass attributes. An example is placed below:

Example:


...
.myClass {
    
background-color:#bed6f8;
    
font-style:italic;}
...

The "viewClass" attribute for <rich:inplaceSelect> is defined as it's shown in the example below:

Example:


<rich:inplaceSelect value="click to edit" viewClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style and background color in view state is changed.

On the component Live Demo page you can see the example of <rich:inplaceSelect> usage and sources for the given example.

Table 6.318. rich : inputNumberSlider attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
barClassA name of CSS class for the bar element
barStyleStyle for a slider control line
bindingThe attribute takes a value-binding expression for a component property of a backing bean
clientErrorMessagean error message to use in client side validation events
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
decreaseClassA name of CSS class for the decrease arrow element
decreaseSelectedClassA name of CSS class for a selected control decrease arrow element
decreaseStyleA style for the decrease arrow element
delayDelay in pressed increase/decrease arrows in miliseconds. Default value is "200".
disabledWhen set for a form control, this boolean attribute disables the control for your input
enableManualInputIf set to "false" this attribute makes the text field "read-only", so the value can be changed only from a handle. Default value is "true".
handleClassA name of CSS class for a control handle element
handleSelectedClassA name of CSS class for a selected control handle element
heightThe height of a slider control. Default value is "20px", for orientation="vertical" value is "20px"
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
increaseClassA name of CSS class for increase arrow element
increaseSelectedClassA name of CSS class for a selected control increase arrow element
increaseStyleA style for the increase arrow element
inputClassStyle Class attribute for a text field
inputPositionIf "right", the InputText Box would be rendered on the right side of the ruler. If "top", the InputText Box would be rendered on the top of the ruler. If "bottom", the InputText Box would be rendered on the bottom of the ruler.
inputSizeSimilar to the "Size" attribute of h:inputText. Default value is "3".
inputStyleStyle attribute for text field
labelA localized user presentable name for this component.
maxlengthSpecifies the maximum number of digits that could be entered into the input field. The maximum number is unlimited by default. If entered value exceeds the value specified in "maxValue" attribute than the slider takes a maximum value position.
maxValueAttribute to set an "end" value. Default value is "100"
minValueAttribute to set the "start" value. Default value is "0".
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onerrorHTML: script expression; a non-number value or a number value that is out of the range is input
onfocusHTML: script expression; the element got the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; some text is selected in a text field. This attribute may be used with the INPUT and TEXTAREA elements
onslideEvent occur on slide
orientationAttribute can have the values "vertical" and "horizontal" to define in which direction the slider should be moveable.
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
showArrowsFalse value for this attribute makes increase/decrease arrows invisible. Default value is "false".
showBoundaryValuesIf the min/max values are shown on the right/left borders of a control. Default value is "true".
showInputFalse value for this attribute makes text a field invisible. Default value is "true".
showToolTipIf "true"the current value is shown in the tooltip when a handle control is in a "dragged" state. Default value is "true".
stepParameter that determines a step between the nearest values while using a handle. Default value is "1".
styleStyles for main div element of the slider control
styleClassName of a CSS class
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
tipClassA name of CSS class for the tool tip element
tipStyleA style for the tool tip element
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
widthThe width of a slider control. Default value is "200px", for orientation="vertical" value is "200px"


<rich:inputNumberSlider> is used to facilitate your data input with rich UI Controls.

Here is the simplest variant of a slider definition with "minValue" , "maxValue" and "step" (on default is "1") attributes, which define the beginning and the end of a numerical area and a slider property step.

Example:


<rich:inputNumberSlider></rich:inputNumberSlider>

It's generated on a page:


Using "showInput" (default is "true") and "enableManualInput" (default value is "true") attributes, it's possible to output the input area near the slider, and make it read-only or editable.

To remove input area use showInput = "false" :

Example:


<rich:inputNumberSlider minValue="1"  maxValue="100" showInput="false"/>

It's displayed at a page like:


It's also possible to switch off displaying of "boundary values" and a toolTip showing on a handle drawing. This could be performed with the help of the component defined attributes: "showBoundaryValues" which is responsible for "boundary values" displaying (default is true) and "showToolTip" which is responsible for tooltTip displaying (default is "true").

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • "onchange"

  • "onmouseover"

  • "onclick"

  • "onfocus"

  • "onmouseout"

  • etc.

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of a localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM" , {2} for "ShortConverter.SHORT".

The "showArrows" boolean attribute when set to "true" enables additional controls for increasing and decreasing slider value. The controls (arrows by default) are placed in the beginning and in the end of slider track:


Clicking an arrow changes the driven value on the amount defined with "step" attribute. Keepeng an arrow control pressed changes the value continuous. Time that value takes to change from one step to another is definded with "delay" attribute.

Style classes names that define styles for component elements are shown on the picture below:



In order to redefine styles for all <rich:inputNumberSlider> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above ) and define necessary properties in them. An example is placed below:

Example:


...
.rich-inslider-tip{
    
background-color: #FFDAB9;
    
font-family: Arial Black;
}  
...

This is a result:


In the example a tip background color and font family was changed.

Also it's possible to change styles of particular <rich:inputNumberSlider> component. In this case you should create own style classes and use them in corresponding <rich:inputNumberSlider> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-style: italic;
    
font-weight:bold;
    
font-size:12px;
}
...

The "inputClass" attribute for <rich:inputNumberSlider> is defined as it's shown in the example below:

Example:


<rich: inputNumberSlider ... inputClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for input text was changed.

On the component Live Demo page you can see the example of <rich:inputNumberSlider> usage and sources for the given example.

Table 6.325. rich : inputNumberSpinner attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
bindingThe attribute takes a value-binding expression for a component property of a backing bean
clientErrorMessageAn error message to use in client side validation events
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
cycledIf "true" after the current value reaches the border value it is reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing (or decreasing) will be locked. Default value is " true ".
disableBrowserAutoCompleteDisable browser's auto completion. Default value is "false"
disabledWhen set for a form control, this boolean attribute disables the control for your input
enableManualInputif "false" your's input to the text field using keyboard will be locked. Default value is "true"
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassClass attribute for text field
inputSizeAttribute specifies the initial length of input in characters. Default value is "10".
inputStyleStyle attribute for text field
labelA localized user presentable name for this component.
maxValueMaximum value. . Default value is "100".
minValueMinimum value. Default value is "0".
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ondownclickHTML: a script expression; a button "Down" is clicked
onerrorHTML: a script expression; event fires whenever an JavaScript error occurs
onfocusHTML: script expression; the element got the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; some text is selected in a text field. This attribute may be used with the INPUT and TEXTAREA elements
onupclickHTML: a script expression; a button "Up" is clicked
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
stepParameter that determines the step between nearest values while using controls. Default value is "1"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes


<rich:inputNumberSpinner> is used to facilitate your data input with rich UI Controls.

Here is the simplest variant of spinner definition with "minValue" , "maxValue" and "step" (on default is "1") attributes, which define the beginning and the end of numerical area and a spinner step.

Example:


...
    <rich:inputNumberSpinner minValue="1" maxValue="100"/>
...

It generates on a page:


There are also several attributes to define functionality peculiarities:

  • "cycled" if the attribute is "true" after the current value reaches the border value it's be reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing/decreasing are locked

  • "disabled" is an attribute that defines whether a component is active on a page

  • "enableManualInput" is an attribute that defines whether a keyboard input is possible or only UI controls could be used

Moreover, to add e.g. some JavaScript effects, events defined on it are used

  • "onchange"

  • "onmouseover"

  • "onclick"

  • "onfocus"

  • "onmouseout"

  • etc.

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM" , {2} for "ShortConverter.SHORT" .

On the screenshot there are classes names that define styles for component elements.



In order to redefine styles for all <rich:inputNumberSpinner> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above ) and define necessary properties in them. An example is placed below:

Example:


...
.rich-spinner-input{
    
font-style:italic;
}
...

This is a result:


In the example an input text font style was changed.

Also it's possible to change styles of particular <rich:inputNumberSpinner> component. In this case you should create own style classes and use them in corresponding <rich:inputNumberSpinner> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-family: Arial Black;
}
...

The "inputClass" attribute for <rich:inputNumberSpinner> is defined as it's shown in the example below:

Example:


<rich: inputNumberSpinner ... inputClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font family for input text was changed.

On the component Live Demo page you can see the example of <rich:inputNumberSpinner> usage and sources for the given example.



The are two basic attributes. The "src" attribute defines the path to the file with source code. The "highlight" attribute defines the type of a syntax highlighting.

If "highlight" attribute is defined and JHighlight open source library is in the classpath, the text from the file is formated and colorized.

An example is placed below.

Example:


...
      <rich:insert  src="/pages/sourcePage.xhtml" highlight="xhtml"/>
...

The result of using <rich:insert> component is shown on the picture:


The <rich:insert> component provides the same functionality as JHighlight. Thus, all names of highlight style classes for source code of particular language could be changed to your names, which are used by the JHighlight library.

On RichFaces LiveDemo page you can found some additional information for <rich:insert> component usage.



<rich:jQuery> can be used in two main modes:

The mode is chosen with "timing" attribute that has the following options:

Definition of the "name" attribute is mandatory when the value of "timing" attribute is "onJScall". If the "name" attribute is defined when "timing" value equals to "immediate" or "onload", the query is applied according to this value, but you still have an opportunity to invoke it by a function name.

The "selector" attribute defines an object or a list of objects. The query is defined with the "query" attribute.

Here is an example of how to highlight odd rows in a table:

Example:


...
<style>
    
.odd {
          
background-color: #FFC;
    
}
</style>
...

...
    <rich:table id="customList" ...>
        ...
    </rich:table>
    ...
    <rich:jQuery selector="#customList tr:odd" timing="onload" query="addClass(odd)" />
...

The "selector" attribute uses defined by w3c consortium syntax for CSS rule selector with some jQuery extensions

Those are typical examples of using selector in the <rich:jQuery> component.


In addition, RichFaces allows using either a component id or client id if you apply the query to a JSF component. When you define a selector, RichFaces examines its content and tries to replace the defined in the selector id with a component id if it's found.

For example, you have the following code:


...
    <h:form id="form">
        ...
        <h:panelGrid id="menu">
            <h:graphicImage ... />
            <h:graphicImage ... />
            ...
        </h:panelGrid>
    </h:form>
...

The actual id of the <h:panelGrid> table in the browser DOM is "form:menu". However, you still can reference to images inside this table using the following selector:


...
    <rich:jQuery selector="#menu img" query="..." />
...

You can define the exact id in the selector if you want. The following code reference to the same set of a DOM object:


...
    <rich:jQuery selector="#form\\:menu img" query="..." />
...

Pay attention to double slashes that escape a colon in the id.

In case when the "name" attribute is defined, <rich:jQuery> generates a JavaScript function that might be used from any place of JavaScript code on a page.

There is an example of how to enlarge the picture smoothly on a mouse over event and return back to the normal size on mouse out:


...
    <h:graphicImage onmouseover="enlargePic(this)" width="50" value="/images/price.png"
                onmouseover="enlargePic(this, {pwidth:'60px'})" onmouseover="releasePic(this)"  />
    <h:graphicImage onmouseover="enlargePic(this)" width="50" value="/images/discount.png"
                onmouseover="enlargePic(this, {pwidth:'100px'})" onmouseover="releasePic(this)"  />
    ...
    <rich:jQuery name="enlargePic" timing="onJScall" query="animate({width:param.pwidth})" />
    <rich:jQuery name="releasePic" timing="onJScall" query="animate({width:'50px'})"/> 
...

The JavaScript could use two parameters. The first parameter is a replacement for the selector attribute. Thus, you can share the same query, applying it to the different DOM objects. You can use a literal value or a direct reference for an existing DOM object. The second parameter can be used to path the specific value inside the query. The JSON syntax is used for the second parameter. The "param." namespace is used for referencing data inside the parameter value.

<rich:jQuery> adds styles and behavior to the DOM object dynamically. This means if you replace something on a page during an Ajax response, the applied artifacts is overwritten. But you are allowed to apply them again after the Ajax response is complete.

Usually, it could be done with reRendering the <rich:jQuery> components in the same Ajax interaction with the components these queries are applied to. Note, that queries with "timing" attribute set to "onload" are not invoked even if the query is reRendered, because a DOM document is not fully reloaded during the Ajax interaction. If you need to re-applies query with "onload" value of "timing" attribute, define the "name" attribute and invoke the query by name in the "oncomplete" attribute of the Ajax component.

RichFaces includes jQuery JavaScript framework. You can use the futures of jQuery directly without defining the <rich:jQuery> component on a page if it is convenient for you. To start using the jQuery feature on the page, include the library into a page with the following code:


...
    <a4j:loadScript src="resource://jquery.js"/>
...

Refer to the jQuery documentation for the right syntax. Remember to use jQuery() function instead of $(), as soon as jQuery works without conflicts with prototype.js.

More information about jQuery framework and its features you can read here.

How to use jQuery with other libraries see here.

Some additional information about usage of component can be found on its LiveDemo.

Table 6.335. rich : listShuttle attributes

Attribute NameDescription
activeItemStores active item
ajaxKeysDefines row keys that are updated after an Ajax request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bottomControlClassCSS class for a "Bottom" control
bottomControlLabelDefines a label for a bottom control
bottomTitleHTML: alt for the last button
columnClassesComma-separated list of CSS classes for columns
componentStateIt defines EL-binding for a component state for saving or redefinition
controlsTypeDefines type of a control: button or none. Default value is "button".
controlsVerticalAlignCustomizes vertically a position of move/copy and order controls relatively to lists. Default value is "middle"
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
copyAllControlClassCSS class for a "Copy all" control
copyAllControlLabelDefines a label for a "Copy all" control
copyAllTitleHTML: alt for "Copy all" button
copyControlClassCSS class for "Copy" control
copyControlLabelDefines a label for a "Copy" control
copyTitleHTML: alt for a "Copy" button
disabledControlClassCSS class for a disabled control
downControlClassCSS class for a "Down" control
downControlLabelDefines a label for a down control
downTitleHTML: alt for bottom button
fastMoveControlsVisibleIf "false", 'Copy All' and 'Remove All' controls aren't displayed. Default value is "true".
fastOrderControlsVisibleIf "false", 'Top' and 'Bottom' controls aren't displayed. Default value is "true".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelA localized user presentable name for this component.
listClassCSS class for a list
listsHeightDefines height of the list. Default value is "140".
moveControlsVisibleIf "false", 'Copy' and 'Remove' controls aren't displayed. Default value is "true".
onblurHTML: script expression; the element lost the focus
onbottomclickA JavaScript event handler; a button "Bottom" is clicked
onclickHTML: a script expression; a pointer button is clicked
oncopyallclickA JavaScript event handler; a button "Copy All" is clicked
oncopyclickHTML: a script expression; a button "Copy" is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ondownclickA JavaScript event handler; a button "Down" is clicked
onfocusHTML: script expression; the element got the focus
onlistchangeHTML: script expression; before a list is changed
onlistchangedHTML: script expression; a list is changed
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onorderchangeHTML: script expression; called before ordering action
onorderchangedHTML: script expression; called after ordering action
onremoveallclickA JavaScript event handler; a button "Remove All" is clicked
onremoveclickA JavaScript event handler; a button "Remove" is clicked
ontopclickA JavaScript event handler; a button "Top" is clicked
onupclickHTML: a script expression; a button "Up" is clicked
orderControlsVisibleIf "false", 'Up' and 'Down' controls aren't displayed. Default value is "true".
removeAllControlClassCSS class for "Remove all" control
removeAllControlLabelDefines a label for a "Remove all" control
removeAllTitleHTML: alt for "Remove all" button
removeControlClassCSS class for a "Remove" control
removeControlLabelDefines a label for a "Remove" control
removeTitleHTML: alt for a "Remove" button
renderedIf "false", this component is not rendered
rowClassesCSS class for a row
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
showButtonLabelsShows a label for a button. Default value is "true".
sourceCaptionLabelDefines source list caption representation text
sourceListWidthDefines width of a source list. Default value is "140".
sourceRequiredDefines the case when source value is being validated. If the value is "true", there should be at least one item in the source list
sourceSelectionManages selection in a source list from the server side
sourceValueDefines a List or Array of items to be shown in a source list
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchByClickIf "true", dragging between lists realized by click
switchByDblClickIf "true", items can be moved between the lists by double-clicking on them. Default value is "true".
targetCaptionLabelDefines target list caption representation text
targetListWidthDefines width of a target list. Default value is "140".
targetRequiredDefines the case when target value is being validated. If the value is "true", there should be at least one item in the target list
targetSelectionManages selection in a target list from the server side
targetValueDefines a List or Array of items to be shown in a target list
topControlClassCSS class for a "Top" control
topControlLabelDefines a label for a "Top" control
topTitleHTML: alt for the first button
upControlClassCSS class for an "Up" control
upControlLabelDefines a label for an "Up" control
upTitleHTML: alt for top button
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueChangeListenerListener for value changes
varDefines a list on the page

The <rich:listShuttle> component consists of the following parts:

The "sourceValue" attribute defines a List or Array of items to be shown in the source list.

The "targetValue" attribute defines a List or Array of items to be shown in the target list.

The "var" attribute could be shared between both Lists or Arrays to define lists on the page.

The "sourceRequired" and "targetRequired" attributes define the case when source and target values are being validated. If the value of both attributes is "true" there should be at least one item in source and target lists. Otherwise validation fails.

Example:


...
<h:form id="myForm">
        <rich:messages>
                <f:facet name="errorMarker">
                        <h:graphicImage value="/images/ajax/error.gif" />   
                </f:facet>
        </rich:messages>
        <rich:listShuttle id="myListShuttle" sourceValue="#{toolBar.freeItems}" targetValue="#{toolBar.items}"  
                                sourceRequired = "true" targetRequired = "true" var="items" converter="listShuttleconverter"
                                sourceCaptionLabel="Source List" targetCaptionLabel="Target List">
                <rich:column>
                        <h:graphicImage value="#{items.iconURI}" />
                </rich:column>
                <rich:column>
                        <h:outputText value="#{items.label}" />
                </rich:column>
        </rich:listShuttle>
        <a4j:commandButton value="Submit" />
</h:form>
...

In the example above the source list is empty. If you submit the form validation fails and error message appears on a page.

This is the result:


The "converter" attribute is used to convert component data to a particular component's value. For example, when you select items in a list, a converter is used to format a set of objects to a strings to be displayed.

The "sourceSelection" attribute stores the collection of items selected by you in the source list. The "targetSelection" attribute stores the collection of items selected by you in the target list.

Captions could be added to a list only after it was defined as a "sourceCaption" and "targetCaption" named facets inside the component or defined with the "sourceCaptionLabel" and "targetCaptionLabel" attribute.


...
<rich:listShuttle var="item" sourceValue="#{bean.source}" targetValue="#{bean.target}" sourceSelection="#{bean.sourceSelection}" 
                        targetSelection="#{bean.targetSelection}" converter="listShuttleconverter">
        <f:facet name="sourceCaption">
                <h:outputText value="Cars Store #1" />
        </f:facet>
        <f:facet name="targetCaption">
                <h:outputText value="Cars Store #2" />
        </f:facet>
        <rich:column>
                <h:outputText value="#{items.name}" />
        </rich:column>
</rich:listShuttle>
...

The <rich:listShuttle> component provides the possibility to use ordering controls set, which performs reordering in the target item list. Every control has possibility to be disabled.

An ordering controls set could be defined with "topControlLabel" , "bottomControlLabel" , "upControlLabel" , "downControlLabel" attributes.

It is also possible to use "topControl" , "topControlDisabled" , "bottomControl" , "bottomControlDisabled" , "upControl" , "upControlDisabled" , "downControl" , "downControlDisabled" facets in order to replace the default controls with facets content.

Example:


...
<rich:listShuttle var="item" sourceValue="#{bean.source}" targetValue="#{bean.target}" converter="listShuttleconverter">
...                  
        <f:facet name="topControl">
                <h:outputText value="Move to top" />
        </f:facet>
        <f:facet name="upControl">
                <h:outputText value="Move up" />
        </f:facet>
        <f:facet name="downControl">
                <h:outputText value="Move down" />
        </f:facet>
        <f:facet name="bottomControl">
                <h:outputText value="Move to bottom" />
        </f:facet>
</rich:listShuttle>
...

The <rich:listShuttle> component also provides 4 predefined controls in move controls set for moving items between source and target lists. Every control has possibility to be disabled.

A move controls set could be defined with "copyControlLabel" , "removeControlLabel" , "copyAllControlLabel" , "removeAllControlLabel" attributes.

It is also possible to use "copyControl" , "removeControl" , "copyAllControl" , "removeAllControl" facets in order to replace the default controls with facets content.


...
<rich:listShuttle var="item" sourceValue="#{bean.source}" targetValue="#{bean.target}" converter="listShuttleconverter"
                        copyControlLabel="Copy" removeControlLabel="Remove"
                        copyAllControlLabel="Copy all" removeAllControlLabel="Remove all">
        <h:column>
                <f:facet name="header">
                        <h:outputText value="Cars" />
                </f:facet>
                <h:outputText value="#{item.name}" />
        </h:column>
</rich:listShuttle>
...

Controls rendering is based on the "controlsType" attribute. Possible types are button and none.

The <rich:listShuttle> component allows to use internationalization method to redefine and localize the labels. You could use application resource bundle and define RICH_SHUTTLES_TOP_LABEL, RICH_SHUTTLES_BOTTOM_LABEL, RICH_SHUTTLES_UP_LABEL, RICH_SHUTTLES_DOWN_LABEL RICH_LIST_SHUTTLE_COPY_ALL_LABEL, RICH_LIST_SHUTTLE_COPY_LABEL, RICH_LIST_SHUTTLE_REMOVE_ALL_LABEL, RICH_LIST_SHUTTLE_REMOVE_LABEL there.

You could also pack org.richfaces.renderkit.listShuttle resource bundle with your JARs defining the same properties.
















On the screenshot there are classes names that define styles for component elements.










In order to redefine styles for all <rich:listShuttle> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-shuttle-source-row-active{
        
background-color:#FFE4B5;
}    
...

This is a result:


In the example an active row background color in the source list was changed.

Also it's possible to change styles of particular <rich:listShuttle> component. In this case you should create own style classes and use them in corresponding <rich:listShuttle> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
font-style:italic;
}
...

The "rowClasses" attribute for <rich:listShuttle> is defined as it's shown in the example below:

Example:


<rich:listShuttle ... rowClasses="myClass"/>

This is a result:


As it could be seen on the picture above, font style for row items was changed.

On RichFaces LiveDemo page you can see an example of <rich:listShuttle> usage and sources for the given example.

Table 6.361. rich : message attributes

Attribute NameDescription
ajaxRenderedDefine, must be (or not) content of this component will be included in AJAX response created by parent AJAX Container, even if not forced by reRender list of ajax action. Ignored if component marked to output by some Ajax action component. The default value is "true".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
errorClassCSS style class to apply to any message with a severity class of "ERROR"
errorLabelClassCSS style class to apply to any message label with a severity class of "ERROR"
errorMarkerClassCSS style class to apply to any message marker with a severity class of "ERROR"
fatalClassCSS style class to apply to any message with a severity class of "FATAL"
fatalLabelClassCSS style class to apply to any message label with a severity class of "FATAL"
fatalMarkerClassCSS style class to apply to any message marker with a severity class of "FATAL"
forClient identifier of the component for which to display messages
idEvery component may have a unique id that is automatically created if omitted
infoClassCSS style class to apply to any message with a severity class of "INFO"
infoLabelClassCSS style class to apply to any message label with a severity class of "INFO"
infoMarkerClassCSS style class to apply to any message marker with a severity class of "INFO"
labelClassCSS style class to apply to label
levelA comma-separated list of messages categories which should be displayed. Default value is "ALL".
markerClassCSS style class to apply to marker
markerStyleCSS style(s) is/are to be applied to marker when this component is rendered
renderedIf "false", this component is not rendered
showDetailFlag indicating whether detailed information of a displayed messages should be included. Default value is "true".
showSummaryFlag indicating whether the summary portion of displayed messages should be included. Default value is "false".
styleThe CSS style for message
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
titleAdvisory title information about markup elements generated for this component
tooltipFlag indicating whether the detail portion of the message should be displayed as a tooltip. Default value is "false".
warnClassCSS style class to apply to any message with a severity class of "WARN"
warnLabelClassCSS style class to apply to any message label with a severity class of "WARN"
warnMarkerClassCSS style class to apply any message marker with a severity class of "WARN"


The component has the same behavior as standard <h:message> component except next two features:

A set of facets which can be used for marker defining:

The following example shows different variants for component customization. The attribute "passedLabel" is used for definition of the label to display when no message appears. But the message component doesn't appear before the form submission even when state is defined as passed (on initial rendering). Boolean attribute "showSummary" defines possibility to display summary portion of displayed messages. The facets "errorMarker" and "passedMarker" set corresponding images for markers.

Example:


...
<rich:message for="id" passedLabel="No errors" showSummary="true">
      <f:facet name="errorMarker">
            <h:graphicImage url="/image/error.png"/>
      </f:facet>
      <f:facet name="passedMarker">
            <h:graphicImage url="/image/passed.png"/>
      </f:facet>    
</rich:message>     
...

On the component LiveDemo page you can see the example of <rich:message> usage and sources for the given example.

Table 6.365. rich : messages attributes

Attribute NameDescription
ajaxRenderedDefine, must be (or not) content of this component will be included in AJAX response created by parent AJAX Container, even if not forced by reRender list of ajax action. Ignored if component marked to output by some Ajax action component. The default value is "true".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
errorClassCSS style class to apply to any message with a severity class of "ERROR"
errorLabelClassCSS style class to apply to any message label with a severity class of "ERROR"
errorMarkerClassCSS style class to apply to any message marker with a severity class of "ERROR"
fatalClassCSS style class to apply to any message with a severity class of "FATAL"
fatalLabelClassCSS style class to apply to any message label with a severity class of "FATAL"
fatalMarkerClassCSS style class to apply to any message marker with a severity class of "FATAL"
forClient identifier of the component for which to display messages
globalOnlyFlag indicating that only global messages (that is, messages not associated with any client identifier) are to be displayed. Default value is "false"
idEvery component may have a unique id that is automatically created if omitted
infoClassCSS style class to apply to any message with a severity class of "INFO"
infoLabelClassCSS style class to apply to any message label with a severity class of "INFO"
infoMarkerClassCSS style class to apply to any message marker with a severity class of "INFO"
labelClassCSS style class to apply to label
layoutThe type of layout markup to use when rendering error messages. Possible values are "table" (an HTML table), "list" (an HTML list) and iterator. If not specified, the default value is "list".
levelA comma-separated list of messages categories which should be displayed. Default value is "ALL".
markerClassCSS style class to apply to marker
markerStyleCSS style(s) is/are to be applied to marker when this component is rendered
renderedIf "false", this component is not rendered
showDetailFlag indicating whether the detailed information of displayed messages should be included. Default value is "false"
showSummaryFlag indicating whether the summary portion of displayed messages should be included. Default value is "true"
styleThe CSS style for message
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
titleAdvisory title information about markup elements generated for this component
tooltipFlag indicating whether the detail portion of the message should be displayed as a tooltip. Default value is "false".
warnClassCSS style class to apply to any message with a severity class of "WARN"
warnLabelClassCSS style class to apply to any message label with a severity class of "WARN"
warnMarkerClassCSS style class to apply any message marker with a severity class of "WARN"


The <rich:messages> component is considered as JSF HTML <h:messages> , extended with following features:

There are two optional parts that could be defined for every message: marker and text label. The set of facets, which can be used for a marker definition, is shown below:


The following example shows different variants of customization of the component.

Example:


<rich:messages layout="table" tooltip="true" showDetail="false" showSummary="true" passedLabel="No Errors">
      <f:facet name="errorMarker">
            <h:graphicImage url="/image/error.png"/>
      </f:facet>
      <f:facet name="infoMarker">
            <h:graphicImage url="/image/info.png"/>
      </f:facet>
      <f:facet name="passedMarker">
            <h:graphicImage url="/image/passed.png"/>
      </f:facet>
</rich:messages>

The <rich:messages> component keeps all messages for all components even after only one ajax-validated component was updated.

On the component LiveDemo page you can see the example of <rich:messages> usage and sources for the given example.

Table 6.369. rich : modalPanel attributes

Attribute NameDescription
autosizedIf "true" modalPanel should be autosizeable. Default value is "false".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
controlsClassCSS style(s) is/are to be applied to component controls when this component is rendered
domElementAttachmentDefines the DOM element, which stacking context will assimilate the modalPanel. Possible values: "body", "form", "parent". Default value is "body".
headerClassCSS style(s) is/are to be applied to component header when this component is rendered
heightAttribute defines height of component. Default value is "200".
idEvery component may have a unique id that is automatically created if omitted
keepVisualStateIf "true" modalPanel should save state after submission. Default value is "false".
labelA localized user presentable name for this component.
leftAttribute defines X position of component left-top corner. Default value is "auto".
minHeightAttribute defines min height of component. Default value is "10". If the value is less then 10, a "IllegalArgumentException" exception is thrown.
minWidthAttribute defines min width of component. Default value is "10". If the value is less then 10, a "IllegalArgumentException" exception is thrown.
moveableif "true" there is possibility to move component. Default value is "true".
onbeforehideHTML: script expression; before panel is hidden
onbeforeshowHTML: script expression; before panel is opened
onhideHTML: script expression; after panel is closed
onmaskclickHTML: a script expression; a pointer button is clicked outside modalPanel
onmaskcontextmenuJavaScript handler to be called on right click outside modalPanel
onmaskdblclickHTML: a script expression; a pointer button is double-clicked outside modalPanel
onmaskmousedownHTML: a script expression; a pointer button is pressed down outside modalPanel
onmaskmousemoveHTML: a script expression; a pointer button is moved outside modalPanel
onmaskmouseoutHTML: a script expression; a pointer button is moved away modalPanel
onmaskmouseoverHTML: a script expression; a pointer button is moved onto modalPanel
onmaskmouseupHTML: a script expression; a pointer button is released outside modalPanel
onmoveHTML: script expression; before panel is moved
onresizeHTML: script expression; panel is resized
onshowHTML: script expression; after panel is opened
overlapEmbedObjectsIf "true" modalPanel creates iframe to overlap embed objects like PDF on a page. Default value is "false".
renderedIf "false", this component is not rendered
resizeableif "true" there is possibility to change component size. Default value is "true".
shadowDepthPop-up shadow depth for suggestion content
shadowOpacityHTML CSS class attribute of element for pop-up suggestion content
showWhenRenderedIf "true" value for this attribute makes a modal panel opened as default. Default value is "false"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
topAttribute defines Y position of component left-top corner. Default value is "auto".
tridentIVEngineSelectBehaviorHow to handle HTML SELECT-based controls in IE 6? - "disable" - default, handle as usual, use disabled="true" to hide SELECT controls - "hide" - use visibility="hidden" to hide SELECT controls
trimOverlayedElementsDefines whether to trim or not elements inside modalPanel. Default value is "true"
visualOptionsDefines options that were specified on the client side
widthAttribute defines width of component. Default value is "300".
zindexAttribute is similar to the standard HTML attribute and can specify window. Default value is "100". placement relative to the content


The component is defined as a panel with some content inside that displays its content as a modal dialog. To call it and to close it, the client API for the window is used.


Important:

To work properly the <rich:modalPanel> should always be placed outside the original <h:form> and must include its own <h:form> for such cases like performing submissions from within the <rich:modalPanel>.

Note:

In order to avoid a bug in IE, the root node of the dialog is moved on the top of a DOM tree.

It's possible to add a "header" facet to the component to set the content for the header.

Example:


<a onclick="Richfaces.showModalPanel('pnl');" href="#">Show ModalPanel</a>
<a4j:form>
    <rich:modalPanel id="pnl">
        <f:facet name="header">
            <h:outputText value="This is a panel header" />
        </f:facet> 
        <p>The &lt;rich:modalPanel&gt; accepts different types of information: 
        from simple text to iterative components such as &lt;rich:dataTable&gt;, etc.
        </p>
        <a onclick="Richfaces.hideModalPanel('pnl');" href="#">Hide</a>
    </rich:modalPanel>
</a4j:form>

Here is what happening on the page:


A facet named "controls" can be added to the component to place control elements on a header.

Example:


<a onclick="Richfaces.showModalPanel('pnl');" href="#">Show ModalPanel</a>
<a4j:form>
    <rich:modalPanel id="pnl">
        <f:facet name="header">
            <h:outputText value="This is a panel header" />
        </f:facet> 
        <f:facet name="controls">
            <h:graphicImage value="/pages/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('pnl')" />
        </f:facet>
        <p>The &lt;rich:modalPanel&gt; accepts different types of information: 
        from simple text to iterative components such as &lt;rich:dataTable&gt;, etc.
        </p>
    </rich:modalPanel>
</a4j:form>

The result:


To understand the sence of " domElementAttachment " attribute you should understand the stacking context in the division element (<div>) HTML makeup. Since each positioned or z-indexed element (in CSS position: absolute or relative or z-index: [any integer value different from 0]) form their own stacking context the <rich:modalPanel> nested into such element may be overlapped with another elements, which appear later in HTML heirarchy and assimilated with basic stacking context (HTML <body>). To make the panel rendered in closest to the observer layer and avoid such overlapping, the component was designed in way when it is always being automatically assimilated with <body> and with a very high rendering layer (z-index). Due to some side effects the <rich:modalPanel> should not always be assimilated with <body> stacking context. The " domElementAttachment " attribute helps to reassign the panel to it 'parent' or 'form' element. If 'form' is used and no parent form is available the panel is functioning as if it is assimilated with <body>.

Note:

If " domElementAttachment " value is not 'body' then some overlapping may occur.

To manage window placement relative to the component, there are "left" and "top" attributes defining a window shifting relative to the top-left corner of the window.

Modal windows can also support resize and move operations on the client side. To allow or disallow these operations, set the "resizeable" and "moveable" attributes to "true" or "false" values. Window resizing is also limited by "minWidth" and "minHeight" attributes specifying the minimal window sizes.

Also you can use "minWidth" and "minHeight" attributes used as showModalPanel() arguments in JavaScript options.

You can pass your parameters during modalPanel opening or closing. This passing could be performed in the following way:

Example:


Richfaces.showModalPanel('panelId', {left: auto, param1: value1});

Thus, except the standard modalPanel parameters you can pass any of your own parameters.

Also modalPanel allows to handle its own opening and closing events on the client side. The "onshow" attribute is used in this case.

The following example shows how on the client side to define opening and closing event handling in such a way that your own parameters could also be obtained:

Example:


onshow="alert(event.parameters.param1)"

Here, during modalPanel opening the value of a passing parameter is output.

More information about this problem could be found on the RichFaces Development Forum.

There is a possibility to restore of the previous component state on a page (including position on the screen) after submitting and reloading. The modalPanel has some special attributes like "showWhenRendered" and "keepVisualState" .

"showWhenRendered" - This boolean attribute is used if modalPanel should be rendered after first page loading.

"keepVisualState" - Used if modalPanel should save state after submission. If keepVisualState="true" then parameters which modalPanel has during opening should be submitted and passed to new page.

Example:


<a href="javascript:Richfaces.showModalPanel('pnl', {top:'10px', left:'10px', height:'400'});">Show</a>

Here, if you open modal dialog window using current link and after submits data then modalPanel destination and height on new loaded page is restored.

if you need the content of the modalPanel to be submitted - you need to remember two important rules:

  • modalPanel must have its own form if it has form elements (input or/and command components) inside (as it was shown in the example above)

  • modalPanel must not be included into the form (on any level up) if it has the form inside.

Simple example of using commandButton within modalPanel is placed below.

Example:


<a4j:form>
    <rich:modalPanel>
        <f:facet name="header">
            <h:outputText value="Test" />
        </f:facet>
        <f:facet name="controls">
            <h:commandLink value="Close" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" />
        </f:facet>
        <h:form>
            <h:commandButton value="Test" action="#{TESTCONTROLLER.test}" />
        </h:form>
    </rich:modalPanel>

See also discussion about this problem on the RichFaces Users Forum.

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM", {2} for "ShortConverter.SHORT".

Here there is information for those of you who would like to click on a details link in table and have it show a modal panel with information loaded from the server.


The screenshot shows the classes names for defining different elements.


In order to redefine styles for all <rich:modalPanel> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-mpnl-mask-div{
    
background-color:#fae6b0;
}
...

This is a result:


In the example the background color for mask was changed.

Also it's possible to change styles of particular <rich:modalPanel> component. In this case you should create own style classes and use them in corresponding <rich:modalPanel> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-style:italic;
}
...

The "headerClass" attribute for <rich:modalPanel> is defined as it's shown in the example below:

Example:


<rich:modalPanel ... headerClass="myClass"/>

This is a result:


As it could be seen on the picture above,the font style for header was changed.

Vizit ModalPanel page at RichFaces Livedemo for examples of component usage and their sources.

Read the " An Introduction To JBoss RichFaces" tutorial by Max Katz to find out how the <rich:modalPanel> helps to edit and save changes for table entries.

Some articles at JBoss portal describing different aspects of <rich:modalPanel> usage:

Table 6.379. rich : orderingList attributes

Attribute NameDescription
activeItemStores active item
ajaxKeysDefines row keys that are updated after an Ajax request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bottomControlLabelDefines a label for a 'Bottom' control
bottomTitleHTML: alt for last button
captionLabelDefines caption representation text
columnClassesCSS class for a column
componentStateIt defines EL-binding for a component state for saving or redefinition
controlsHorizontalAlignControls horizontal rendering. Possible values: "left" - controls should be rendered to the left side of a list. "right"- controls should be rendered to the right side of a list. Default value is "right".
controlsTypeDefines type of a control: button or none. Default value is "button".
controlsVerticalAlignControls vertical rendering. Possible values: "top" - controls should be rendered aligned to top side of a list. "bottom" - controls should be rendered aligned to bottom side of a list. "middle" - controls should be rendered centered relatively to a list. Default value is "middle"
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
downControlLabelDefines a label for a 'Down' control
downTitleHTML: alt for bottom button
fastOrderControlsVisibleIf "false", 'Top' and 'Bottom' controls aren't displayed. Default value is "true".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelA localized user presentable name for this component.
listHeightDefines height of a list. Default value is "140".
listWidthDefines width of a list. Default value is "140".
onbottomclickHTML: script expression; a button "Bottom" is clicked
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ondownclickHTML: script expression; a button "Down" is clicked
onheaderclickHTML: script expression; a header is clicked
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onorderchangeHTML: script expression; before a order list is changed
onorderchangedHTML: script expression; a order list is changed
ontopclickHTML: script expression; a button "Top" is clicked
onupclickHTML: a script expression; a button "Up" is clicked
orderControlsVisibleIf "false", 'Up' and 'Down' controls aren't displayed. Default value is "true".
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
rowClassesCSS class for a row
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the list
selectionCollection which stores a set of selected items
showButtonLabelsIf "true", shows a label for a button. Default value is "true"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
topControlLabelDefines a label for a 'Top' control
topTitleHTML: alt for first button
upControlLabelDefines a label for a 'Up' control
upTitleHTML: alt for top button
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueDefines a List or Array of items to be shown in a list
valueChangeListenerListener for value changes
varDefines a list on the page


The <rich:orderingList> component consists of

The "value" and "var" attributes are used to access the values of a list.

Controls rendering is based on the "controlsType" attribute. Possible types are button or none.

The information about the "converter" attribute is here.

The "selection" attribute stores the collection of items selected by you. In the example below after submitting the form the current collection is placed in the object's property and then <rich:dataTable> with selected items is shown.

Example:


...
<h:form>
        <rich:orderingList value="#{bean.simpleItems}" var="item" selection="#{bean.selection}" controlsType="button">
                <rich:column>
                    <f:facet name="header">
                            <h:outputText value="Cars" />
                    </f:facet>
                            <h:outputText value="#{item}" />
                </rich:column>
        </rich:orderingList>
        <rich:dataTable id="infoPanelID" value="#{bean.info}" var="info" rendered="true">
                <rich:column>
                            <h:outputText value="#{info}" />
                </rich:column>
        </rich:dataTable>
        <a4j:commandButton value="reRender" reRender="infoPanelID" />
</h:form>
...

The <rich:orderingList> component allows to use "caption" facet. A caption could be also defined with "captionLabel" attribute.

Simple example is placed below.

Example:


...
<rich:orderingList value="#{bean.simpleItems}" var="item" controlsType="button" selection="#{bean.selection}">
        <f:facet name="caption">
                <h:outputText value="Caption Facet" />
        </f:facet>
        <rich:column>
                <f:facet name="header">
                <h:outputText value="Cars" />
                </f:facet>
                <h:outputText value="#{item.name}" />
        </rich:column>
        <rich:column>
                <f:facet name="header">
                <h:outputText value="Price" />
                </f:facet>
                <h:outputText value="#{item.price}" />
        </rich:column>
</rich:orderingList>
...

The <rich:orderingList> component provides the possibility to use ordering controls set, which performs reordering. Every control has possibility to be disabled.

An ordering controls set could be defined with "topControlLabel" , "bottomControlLabel" , "upControlLabel" , "downControlLabel" attributes.

It is also possible to use "topControl" , "topControlDisabled" , "bottomControl" , "bottomControlDisabled" , "upControl" , "upControlDisabled" , "downControl" , "downControlDisabled" facets in order to replace the default controls with facets content.

Example:


...
<rich:orderingList value="#{bean.simpleItems}" var="item" controlsType="button" selection="#{bean.selection}">
        <f:facet name="topControl">
                <h:outputText value="Move to top" />
        </f:facet>
        <f:facet name="upControl">
                <h:outputText value="Move up" />
        </f:facet>
        <f:facet name="downControl">
                <h:outputText value="Move down" />
        </f:facet>
        <f:facet name="bottomControl">
                <h:outputText value="Move to bottom" />
        </f:facet>
<rich:orderingList>
...

The position of the controls relatively to a list could be customized with:

  • "controlsHorizontalAlign" attribute. Possible values:

    • "left" - controls render to the left side of a list

    • "right" (default) - controls render to the right side of a list

    • "center" - controls is centered

  • "controlsVerticalAlign" attribute. Possible values:

    • "top" - controls render aligned to the top side of a list

    • "bottom" - controls render aligned to the bottom side of a list

    • "center" (default) - controls is centered relatively to a list

The <rich:orderingList> component has a possibility to hide any of the controls by pairs using following attributes:

  • "orderControlsVisible" attribute has two values: "true" or "false". If false Up and Down controls are not displayed.

  • "fastOrderControlsVisible" attribute has two values: "true" or "false". If false Top and Bottom controls are not displayed.

The <rich:orderingList> component allows to use internationalization method to redefine and localize the labels. You could use application resource bundle and define RICH_SHUTTLES_TOP_LABEL, RICH_SHUTTLES_BOTTOM_LABEL, RICH_SHUTTLES_UP_LABEL, RICH_SHUTTLES_DOWN_LABEL there.

You could also pack org.richfaces.renderkit.orderingList resource bundle with your JARs defining the same properties.


















On the screenshot there are classes names that define styles for component elements.








In order to redefine styles for all <rich:orderingList> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-ordering-list-table-header-cell{
        
font-weight:bold;
}
...

This is a result:


In the example the font weight for header text was changed.

Also it's possible to change styles of particular <rich:orderingList> component. In this case you should create own style classes and use them in corresponding <rich:orderingList> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
font-style:italic;
}
...

The "rowClasses" attribute for <rich:orderingList> is defined as it's shown in the example below:

Example:


<rich:orderingList ... rowClasses="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for rows was changed.

On RichFaces LiveDemo page you can see an example of <rich:orderingList> usage and sources for the given example.

Table 6.406. rich : paint2D attributes

Attribute NameDescription
alignDeprecated. This attribute specifies the position of an IMG, OBJECT, or APPLET with respect to its context. The possible values are "bottom", "middle", "top", "left" and "right". The default value is "middle".
altFor compability with XHTML 1.1 standart
bgcolorBackground color of painted image. Default value is 'transparent' which means no background fill. Hex colors can be used, as well as common color names. Invalid values are treated as transparent. Note, that JPEG format doesn't support transparency, and transparent background is painted black. Also note, that several browsers (e.g. IE6) do not support PNG transparency. Default value is "transparent"
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderDeprecated. This attribute specifies the width of an IMG or OBJECT border, in pixels. The default value for this attribute depends on the user agent
cacheableSupported (or not) client/server caching for generated images. Caching on client supported by properly sending and processing of HTTP headers (Last-Modified, Expires, If-Modified-Since, etc.) Server-side caching is supported by application-scope object cache. For build of cache key use "value" attribute, serialized to URI
dataValue calculated at render time and stored in Image URI (as part of cache Key), at paint time passed to a paint method. It can be used for updating cache at change of image generating conditions, and for creating paint beans as "Lightweight" pattern components (request scope). IMPORTANT: Since serialized data stored in URI, avoid using big objects
formatformat Name of format for sending a generated image. It currently supports "jpeg" (24 bit, default), "gif" (8 bit with transparency), "png" (32 bit with transparency)
heightHeight in pixels of image (for paint canvas and HTML attribute). Default value is "10".
hspaceDeprecated. This attribute specifies the amount of white space to be inserted to the left and right of an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
paintThe method calls expression to paint Image on prepared Buffered image. It must have two parameters with a type of java.awt.Graphics2D (graphics to paint) and Object (restored from URI "data" property). For painting used 32-bit RGBA color model (for 8-bit images used Diffusion filtration before sending)
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component
valueThe current value of this component
vspaceDeprecated. This attribute specifies the amount of white space to be inserted above and below an IMG, APPLET, or OBJECT. The default value is not specified, but is generally a small, non-zero length
widthWidth in pixels of image (for paint canvas and HTML attribute). Default value is "10".


The example shows two main attributes of the component:

The "format" attribute of the component defines a format of visual data passing to the server.

Generated data can be used as a cacheable or non-cacheable resource. It's defined with "cacheable" attribute. If cache support is turned on, a key is created in URI with a mix of size (width/height), "paint" method, "format" and "data" attributes.

Example:

paintBean.java:

      
      public void paint(Graphics2D g2, Object obj) {
          // code that gets data from the data Bean (PaintData)
          PaintData data = (PaintData) obj;
          ...
          // a code drawing a rectangle
          g2.drawRect(0, 0, data.Width, data.Height);
          ...
          // some more code placing graphical data into g2 stream below
     }
     
dataBean.java:
    
    public class PaintData implements Serializable{
        private static final long serialVersionUID = 1L;
        Integer Width=100;
        Integer Height=50;
        ...
    }
    
    page.xhtml:
    ...
    <rich:paint2D paint="#{paint2D.paint}" data="#{paint2DModel.data}"/>
    ... 

On the component LiveDemo page you can see the example of <rich:paint2D> usage and sources for the given example.



The "header" attribute defines text to be represented. If you can use the "header" facet, you can even not use the "header" attribute.

Example:


...
    <rich:panel>
        <f:facet name="header">  
            <h:graphicImage value="/images/img1.png"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:panel>
...

<rich:panel> components are used to group page content pieces on similarly formatted rectangular panels.

Example:


...
    <rich:panel>
        ...
    </rich:panel>
...

It's generating on a page in the following way:


The example shows that similar rectangular areas are formed with a particular style.

When creating a panel with a header element, one more <div> element is added with content defined for a header.

Example:


...
    <rich:panel>
        <f:facet name="header">
            <h:outputText value="Olympus EVOLT E-500 "/>
        </f:facet>
        ...
    </rich:panel>
...

It's displayed on a page in the following way:


As it has been mentioned above, the component is mostly used for a page style definition, hence the main attributes are style ones.

  • "styleClass"

  • "headerClass"

  • "bodyClass"

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • "onmouseover"

  • "onclick"

  • "onmouseout"

  • etc.

On the component LiveDemo page you can see the example of <rich:panel> usage and sources for the given example.

Table 6.415. rich : panelBar attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassThe component content style class
contentStyleThe component content style
headerClassThe component header style class
headerClassActiveThe component header style class active
headerStyleThe component header style
headerStyleActiveThe component header style active
heightThe height of the slide panel. Might be defined as pixels or as percentage. Default value is "100%".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
onclickHTML: script expression; before on the header is clicked
onitemchangeHTML: script expression; a item is changed
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: script expression; a pointer was moved onto.
renderedIf "false", this component is not rendered
selectedPanelAttribure defines name of selected item
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute.
valueThe current value of this component
valueChangeListenerListener for value changes
widthThe width of the slide panel. Might be defined as pixels or as percentage. Default value is "100%".


As it was mentioned above, panelBar is used for grouping any content on the client, thus its customization deals only with specification of sizes and styles for rendering.

"width" and "height" (both are 100% on default) attributes stand apart.

Style attributes are described further.

panelBar could contain any number of child panelBarItem components inside, which content is uploaded onto the client and headers are controls to open the corresponding child element.

There is one predefined class for the <rich:panelBar> , which is applicable to a whole component, specifying padding, borders, and etc.



Other classes responsible for elements rendering are described for child <rich:panelBarItem> elements and could be found in the components chapters.


In order to redefine styles for all <rich:panelBar> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-panelbar{
        
font-style: italic;
}
...

This is a result:


In the example header and content font style was changed.

Also it's possible to change styles of particular <rich:panelBar> component. In this case you should create own style classes and use them in corresponding <rich:panelBar> styleClass attributes. An example is placed below:

Example:


...
.myClass{
       
font-family: Tahoma;
}
...

The "contentClass" attribute for <rich:panelBar> is defined as it's shown in the example below:

Example:


<rich:panelBar ... contentClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font family for content were changed.

On the component LiveDemo page you can see the example of <rich:panelBar> usage and sources for the given example.



The "label" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "label" attribute.

Example:


...
    <rich:panelBarItem...>
        <f:facet name="label">  
            <h:graphicImage value="/images/img1.png"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:panelBarItem>
...

As it was mentioned above, panelBarItem is used for grouping any content inside within one panelBar, thus its customization deals only with specification of sizes and styles for rendering.

panelBar could contain any number of child panelBarItem components inside, which content is uploaded onto the client and headers are controls to open the corresponding child element.

On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:panelBarItem> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-panelbar-content{
        
background-color: #ecf4fe;
}
...

This is a result:


In the example a content background color was changed.

Also it's possible to change styles of particular <rich:panelBarItem> component. In this case you should create own style classes and use them in corresponding <rich:panelBarItem> styleClass attributes. An example is placed below:

Example:


...
.myClass{
  
font-family: monospace;
}
...

The "headerClass" attribute for <rich:panelBarItem> is defined as it's shown in the example below:

Example:


<rich:panelBarItem ... headerClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font family for header of active item was changed.

Table 6.427. rich : panelMenu attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
disabledIf true sets state of the item to disabled state. Default value is "false".
disabledGroupClassSpace-separated list of CSS style class(es) that are be applied to disabled group of this component
disabledGroupStyleCSS style(s) is/are to be applied to disabled group when this component is rendered
disabledItemClassSpace-separated list of CSS style class(es) that are be applied to disabled item of this component
disabledItemStyleCSS style(s) is/are to be applied to disabled item when this component is rendered.
eventDefines the event on the representation element that triggers the submenu's expand/collapse. Default value is "onclick".
expandModeSet the submission mode for all panel menu groups after expand/collapse except ones where this attribute redefined. Possible values are "ajax", "server", "none". Default value is "none".
expandSingleWhether only one panel menu node on top level can be opened at a time. If the value of this attribute is true, the previously opened node on the top level is closed. If the value is false, the node is left opened. Default value is "false".
groupClassSpace-separated list of CSS style class(es) that are be applied to group of this component
groupStyleCSS style(s) is/are to be applied to group when this component is rendered
hoveredGroupClassSpace-separated list of CSS style class(es) that are be applied to hovered group of this component
hoveredGroupStyleCSS style(s) is/are to be applied to hovered group when this component is rendered
hoveredItemClassSpace-separated list of CSS style class(es) that are be applied to hovered item of this component
hoveredItemStyleCSS style(s) is/are to be applied to hovered item when this component is rendered
iconCollapsedGroupPath to the icon to be displayed for the collapsed Group state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconCollapsedTopGroupPath to the icon to be displayed for the collapsed top group state.\ You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconDisabledGroupPath to the icon to be displayed for the disabled group state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconDisabledItemPath to the icon to be displayed for the disabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconExpandedGroupPath to the icon to be displayed for the expanded Group state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconExpandedTopGroupPath to the icon to be displayed for the expanded top group state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconGroupPositionPosition of the icon for the group icon. Possible values are "left","right","none". Default value is "left".
iconGroupTopPositionPosition of the icon for the top group icon. Possible values are "left","right","none". Default value is "left".
iconItemPath to the icon to be displayed for the enabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconItemPositionPosition of the icon for the item icon. Possible values are "left","right","none". Default value is "left".
iconItemTopPositionPosition of the icon for the top item icon. Possible values are "left","right","none". Default value is "left".
iconTopDisabledItemPath to the icon to be displayed for the disabled top item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconTopDisableGroupPath to the icon to be displayed for the disabled top Group state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconTopItemPath to the icon to be displayed for the enabled top item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
itemClassSpace-separated list of CSS style class(es) that are be applied to item of this component
itemStyleCSS style(s) is/are to be applied to item when this component is rendered.
labelA localized user presentable name for this component.
modeSet the submission mode for all panel menu items on the panel menu except ones where this attribute redefined. Possible values are "ajax", "server", "none". Default value is "server".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ongroupcollapseHTML: script expression; some group was closed
ongroupexpandHTML: script expression; some group was activated
onitemhoverHTML: script expression; some item was hovered
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: script expression; a pointer was moved within.
onmouseoutHTML: script expression; a pointer was moved away.
onmouseoverHTML: script expression; a pointer was moved onto.
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
selectedChildcontain the name or the clientId of any of the item or group, the child defined in this attribute should be highlighted on PanelMenu rendering
styleThe CSS style for the panel menu.
styleClassThe CSS class for the panel menu.
topGroupClassSpace-separated list of CSS style class(es) that are be applied to top group of this component
topGroupStyleCSS style(s) is/are to be applied to top group when this component is rendered
topItemClassSpace-separated list of CSS style class(es) that are be applied to top item of this component
topItemStyleCSS style(s) is/are to be applied to top item when this component is rendered
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
widthSet minimal width for the menu. Default value is "100%".


All attributes are not required.

Use "event" attribute to define an event for appearance of collapsing/expanding sublevels. Default value is "onclick". An example could be seen below.

Example:


...
      <rich:panelMenu event="onmouseover">
            <!--Nested panelMenu components-->
      </rich:panelMenu>
...

Switching mode could be chosen with the "mode" attribute for all panelMenu items except ones where this attribute was redefined. By default all items send traditional request.

The "expandMode" attribute defines the submission modes for all collapsing/expanding panelMenu groups except ones where this attribute was redefined.

The "mode" and "expandMode" attributes could be used with three possible parameters. The "mode" attribute defines parameters for all included <rich:panelMenuItem> elements.

The common submission of the form is performed and a page is completely refreshed.

Example:


...
      <rich:panelMenu mode="server">
          <rich:panelMenuGroup label="test Group" action="#{bean.action}"> 
              <rich:panelMenuItem label="test" action="#{capitalsBean.action}"> 
                  <f:param value="test value" name="test"/> 
              </rich:panelMenuItem> 
          </rich:panelMenuGroup>
      </rich:panelMenu>
...

An Ajax form submission is performed, and additionally specified elements in the "reRender" attribute are reRendered.

Example:


...
      <rich:panelMenu mode="ajax">
           <rich:panelMenuGroup label="test Group" action="#{bean.action}"> 
               <rich:panelMenuItem label="test" reRender="test" action="#{capitalsBean.action}"> 
                   <f:param value="test value" name="test"/> 
               </rich:panelMenuItem> 
          </rich:panelMenuGroup>
      </rich:panelMenu>
...

"Action" and "ActionListener" item's attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested into items.

Example:


...
      <rich:panelMenu event="onclick" submitMode="none">
            <rich:panelMenuItem label="Link to external page">
                  <h:outputLink ... >
            <rich:panelMenuItem>
      </rich:panelMenu>
...

The "expandSingle" attribute is defined for expanding more than one submenu on the same level. The default value is "false" . If it's true the previously opened group on the top level closes before opening another one. See the picture below.


The "selectedChild" attribute is used for defining the name of the selected group or item. An example for group is placed below:

Here is an example:

Example:


...
      <rich:panelMenu selectedChild="thisChild">
        <rich:panelMenuGroup label="Group1" name="thisChild">
          <!--Nested panelMenu components-->
        </rich:panelMenuGroup>
      </rich:panelMenu>
      ...

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM", {2} for "ShortConverter.SHORT".

On the component LiveDemo page you can see the example of <rich:panelMenu> usage and sources for the given example.

Table 6.431. rich : panelMenuGroup attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
alignDeprecated. This attribute specifies the horizontal alignment of its element with respect to the surrounding context. The possible values are "left", "center", "right" and "justify". The default depends on the base text direction. For left to right text, the default is align="left", while for right to left text, the default is align="right".
altFor a user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the lang attribute
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledWhen set for a form control, this boolean attribute disables the control for your input
disabledClassClass to be applied to disabled items.
disabledStyleCSS style rules to be applied to disabled items.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
expandedIf true group will be displayed expanded initially. Default value is "false".
expandModeSet the submission mode for all panel menu groups after expand/collapse except ones where this attribute redefined. Possible value are "ajax", "server", "none". Default value is "none".
focusid of element to set focus after request completed on client side
hoverClassClass to be applied to hovered items.
hoverStyleCSS style rules to be applied to hovered items.
iconClassClass to be applied to icon element.
iconCollapsedPath to the icon to be displayed for the collapsed item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconDisabledPath to the icon to be displayed for the disabled item state.
iconExpandedPath to the icon to be displayed for the expanded item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconStyleCSS style rules to be applied
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelDisplayed node's text
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
maxlengthSpecifies the maximum number of digits that could be entered into the input field. The maximum number is unlimited by default. If entered value exceeds the value specified in "maxValue" attribute than the slider takes a maximum value position.
nameRefers to group/item with the same name. Default value is "getId()".
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression; group was closed
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onexpandHTML: script expression; group was opened
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; some text is selected in a text field. This attribute may be used with the INPUT and TEXTAREA elements
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
sizeThis attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) to be applied when this component is rendered.
styleClassCorresponds to the HTML class attribute.
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetTarget frame for action to execute.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value for this component
valueChangeListenerListener for value changes


All attributes except "label" are optional. The "label" attribute defines text to be represented.

Switching mode could be chosen with the "expandMode" attribute for the concrete panelMenu group.

The "expandMode" attribute could be used with three possible parameters:

Regular form submission request is used.

Ajax submission is used for switching.

"Action" and "actionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested into items.

There are three icon-related attributes. The "iconExpanded" attribute defines an icon for an expanded state. The "iconCollapsed" attribute defines an icon for a collapsed state. The "iconDisabled" attribute defines an icon for a disabled state.

Default icons are shown on the picture below:


Here is an example:

Example:


...
      <rich:panelMenu>
            <rich:panelMenuGroup label="Group1" iconExpanded="disc" iconCollapsed="chevron">
                  <!--Nested panelMenu components-->
            </rich:panelMenuGroup>
      </rich:panelMenu>
...

As the result the pictures are shown below. The first one represents the collapsed state, the second one - expanded state:



It's also possible to define a path to the icon. Simple code is placed below.


...
      <rich:panelMenu>
            <rich:panelMenuGroup label="Group1" iconExpanded="\images\img1.png" iconCollapsed="\images\img2.png">
                  <!--Nested menu components-->
            </rich:panelMenuGroup>
      </rich:panelMenu>
...

Information about the "process" attribute usage you can find " Decide what to process " guide section.

On the screenshot there are classes names that define styles for component elements.






In order to redefine styles for all <rich:panelMenuGroup> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-pmenu-disabled-element{
        
color: #87b9ff;
}
...

This is a result:


In the example a disabled element font style and color were changed.

Also it's possible to change styles of particular <rich:panelMenuGroup> component. In this case you should create own style classes and use them in corresponding <rich:panelMenuGroup> styleClass attributes. An example is placed below:

Example:


...
.myClass{
       
background-color: #ecf4fe;
}
...

The "hoverClass" attribute for <rich:panelMenuGroup> is defined as it's shown in the example below:

Example:


<rich:panelMenuGroup ... hoverClass="myClass"/>

This is a result:


As it could be seen on the picture above, the background color for hovered item was changed.

Table 6.442. rich : panelMenuItem attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf true sets state of the item to disabled state. Default value is "false".
disabledClassClass to be applied to disabled items.
disabledStyleCSS style rules to be applied to disabled items.
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
hoverClassClass to be applied to hovered items.
hoverStyleCSS style rules to be applied to hovered items.
iconPath to the icon or the default one name to be displayed for the enabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconClassClass to be applied to icon element.
iconDisabledPath to the icon to be displayed for the disabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconStyleCSS style rules to be applied
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelDefines representation text for menuItem.
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
modeSet the submission mode. Possible values are "ajax", "server", "none". Default value is "none".
name'selectedChild' attribute of PanelMenu refers to group/item with the same name. Default value is "getId()".
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
targetTarget frame for action to execute.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component


All attributes except "label" are optional. The "label" attribute defines text to be represented.

The "mode" attribute could be used with three possible parameters:

Regular form submission request is used.

Ajax submission is used for switching.

"Action" and "actionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested into items.

Here is an example for value "none":

Example:


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem mode="none" onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/">
                  <h:outputLink value="http://labs.jboss.com/jbossrichfaces/">
                        <h:outputText value="RichFaces Home Page"></h:outputText>
                  </h:outputLink>
            </rich:panelMenuItem>
            ...
      </rich:panelMenu>
...

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item.

Default icons are shown on the picture below:


Here is an example:

Example:


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem value="Item 1.1" icon="chevronUp" />
            ... 
      </rich:panelMenu>
...

As the result the picture is shown below:


It's also possible to define a path to the icon. Simple code is placed below.


...
      <rich:panelMenu>
            ...
            <rich:panelMenuItem value="Item 1.1" icon="\images\img1.png" />
            ... 
      </rich:panelMenu>
...

Information about the "process" attribute usage you can find in the "Decide what to process" guide section.

On the screenshot there are classes names that define styles for component elements.






In order to redefine styles for all <rich:panelMenuItem> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-pmenu-hovered-element {
  
background-color: #ff7800;
}
...

This is a result:


In the example a hovered element background color was changed.

Also it's possible to change styles of particular <rich:panelMenuItem> component. In this case you should create own style classes and use them in corresponding <rich:panelMenuItem> styleClass attributes. An example is placed below:

Example:


...
.myClass {
        
color: #a0a0a0;
}
...

The "disabledClass" attribute for <rich:panelMenuItem> is defined as it's shown in the example below:

Example:


<rich:panelMenuItem ... disabledClass="myClass"/>

This is a result:


As it could be seen on the picture above, the text color for disabled item was changed.

Table 6.449. rich : pickList attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
controlClassCSS class for a list
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
copyAllControlLabelDefines a label for a "Copy all" control
copyAllTitleHTML: alt for a "Copy all" button
copyAllVisibleIf "false", the 'Copy All' control will not be displayed. Even if this value is "true", the 'Copy All' control will not be displayed if the "fastMoveControlsVisible" attribute is "false". Default value is "true".
copyControlLabelDefines a label for a "Copy" control
copyTitleHTML: alt for a "Copy" button
copyVisibleIf "false", the 'Copy' control will not be displayed. Even if this value is "true", the 'Copy' control will not be displayed if the "moveControlsVisible" attribute is "false". Default value is "true".
disabledIf "true", disable this component on page.
disabledStyleCSS style rules to be applied to disabled controls
disabledStyleClassThe disabledStyleClass for disabled controls
enabledStyleCSS style rules to be applied to enabled controls
enabledStyleClassThe enabledStyleClass for enabled controls
fastMoveControlsVisibleIf "false", 'Copy All' and 'Remove All' controls aren't displayed. Even if this value is "true", the 'Copy All' and 'Remove All' controls will not be displayed if the "copyAllVisible" and "removeAllVisible" attribute values are "false". Default value is "true".
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
labelA localized user presentable name for this component.
listClassCSS class for a list
listsHeightDefines height of the list. Default value is "140px"
moveControlsVerticalAlignCustomizes vertically a position of move/copy controls relatively to lists. Default value is "center".
moveControlsVisibleIf "false", 'Copy' and 'Remove' controls aren't displayed. Even if this value is "true", the 'Copy' and 'Remove' controls will not be displayed if the "copyVisible" and "removeVisible" attribute values are "false". Default value is "true".
onblurHTML: script expression; the element lost the focus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onlistchangeHTML: a script expression; before a list is changed
onlistchangedHTML: a script expression; a list is changed
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
removeAllControlLabelDefines a label for a "Remove all" control
removeAllTitleHTML: alt for a "Remove" all button
removeAllVisibleIf "false", the 'Remove All' control will not be displayed. Even if this value is "true", the 'Remove All' control will not be displayed if the "fastMoveControlsVisible" attribute is "false". Default value is "true".
removeControlLabelDefines a label for a "Remove" control
removeTitleHTML: alt for a "Remove" button
removeVisibleIf "false", the 'Remove' control will not be displayed. Even if this value is "true", the 'Remove' control will not be displayed if the "moveControlsVisible" attribute is "false". Default value is "true".
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
showButtonsLabelShows a label for a button. Default value is "true"
sourceListWidthDefines width of a source list. Default value is "140px"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchByClickIf "true", items can be moved between the lists by clicking on them. Default value is "false".
switchByDblClickIf "true", items can be moved between the lists by double-clicking on them. Default value is "true".
targetListWidthDefines width of a target list. Default value is "140px"
titleAdvisory title information about markup elements generated for this component
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes


The <rich:pickList> component consists of

The "value" attribute is the initial value of this component.

The <f:selectItem /> or <f:selectItems /> facets are used to define the values of a source list.

Example:


...
<rich:pickList value="#{pickBean.listValues}">
        <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>
        <f:selectItem itemValue="Audi" itemLabel="Audi"/>
        <f:selectItems value="#{pickBean.sourceList}"/>
</rich:pickList>
...

The "switchByClick" attribute provides an option to copy and remove items between lists by one click. Default value of this attribute is "false", so you need a double click to copy, remove items from one list to another.

Lables of the move controls can be defined with "copyAllControlLabel" , "copyControlLabel" , "removeControlLabel" , "removeAllControlLabel" attributes.

Example:


...
<rich:pickList copyAllControlLabel = "#{pickBean.copyAllLabel}" copyControlLabel = "#{pickBean.copyLabel}" removeControlLabel = "#{pickBean.removeLabel}" 
removeAllControlLabel ="#{pickBean.removeAllLabel}" value="#{pickBean.listValues}">
        <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>
        <f:selectItem itemValue="Audi" itemLabel="Audi"/>
        <f:selectItems value="#{pickBean.sourceList}"/>
</rich:pickList>
...

If you don't want to display labels on the buttons you need to set "showButtonsLabel" to "false".


Alternative to the given attributes are the following facets: "copyAllControl" , "removeAllControl" , "copyControl" , "removeControl" , "copyAllControlDisabled" , "removeAllControlDisabled" , "copyControlDisabled" , "removeControlDisabled" , "caption" .

It is an example of usage of the facets and it is identical to the previous example.


...
<rich:pickList value="#{pickBean.listValues}">
    <f:facet name="copyAllControl">
        <h:commandButton value="#{pickBean.copyAllLabel}" />
    </f:facet>
    <f:facet name="copyControl">
        <h:commandButton value="#{pickBean.copyLabel}" />
    </f:facet>
    <f:facet name="removeControl">
        <h:commandButton value="#{pickBean.removeLabel}" />
    </f:facet>
    <f:facet name="removeAllControl">
        <h:commandButton value="#{pickBean.removeAllLabel}" />
    </f:facet>
        <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>
        <f:selectItem itemValue="Audi" itemLabel="Audi"/>
        <f:selectItems value="#{pickBean.sourceList}"/>
</rich:pickList>
...

With the help of "moveControlsVerticalAlign" attribute you can align move controls vertically.

The possible value for "moveControlsVerticalAlign" are "top", "bottom" and "center" (default value).

The <rich:pickList> component provides resizing of lists by using such attributes as:

  • "listsHeight" defines height of the lists.

  • "sourceListWidth" defines width of a source list.

  • "targetListWidth" defines width of a target list.

Example:


...
<rich:pickList listsHeight="#{pickBean.listsHeight}" sourceListWidth="#{pickBean.sourceListWidth}" targetListWidth="#{pickBean.targetListWidth}" value="#{pickBean.listValues}">
        <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>
        <f:selectItem itemValue="Audi" itemLabel="Audi"/>
        <f:selectItems value="#{pickBean.sourceList}"/>
</rich:pickList>
...

The <rich:pickList> component allows to use internationalization method to redefine and localize the labels. You could use application resource bundle and define RICH_PICK_LIST_COPY_ALL_LABEL, RICH_PICK_LIST_COPY_LABEL, RICH_PICK_LIST_REMOVE_ALL_LABEL, RICH_PICK_LIST_REMOVE_LABEL there.















The following pictures illustrate how CSS classes define styles for component elements.










In order to redefine styles for all <rich:pickList> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-picklist-list{
        
background-color:#ecf4fe;
}
...

This is a result:


In the example the background color for lists is changed.

Also it's possible to change styles of particular <rich:pickList> component. In this case you should create own style classes and use them in the corresponding <rich:pickList> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
font-weight:bold;
}
...

The "styleClass" attribute for <rich:pickList> is defined as it's shown in the example below:

Example:


<rich:pickList ... styleClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font style for buttons is changed.

On RichFaces LiveDemo page you can see an example of <rich:pickList> usage and sources for the given example.

Table 6.473. rich : progressBar attributes

Attribute NameDescription
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
completeClassCSS class that defines style for progress line rendering
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enabledEnables/disables polling. Default value is "true".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
finishClassCSS class that defines style for complete state of the component
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
initialClassCSS class that defines style for initial state of the component
intervalInterval (in ms) for call poll requests. Default value 1000 ms (1 sec)
labelAttribute defines a simple label instead of rendering children component
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
maxValueMax value, after which complete state should be rendered. Default value is "100".
minValueMin value when initial state should be rendered. Default value is "0".
modeAttributes defines AJAX or CLIENT modes for component. Possible values are "ajax", "client". Default value is "ajax".
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onsubmitJavaScript code for call before submission of ajax event
parametersParameters for macrosubstitution in the label
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
progressVarDEPRECATED. Provides access to value of the component on the client
remainClassCSS class that defines style for remained part of progress bar
renderedIf "false", this component is not rendered
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
reRenderAfterCompleteSet of componets to rerender after completion
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCSS class that defines style for progress bar
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
valueSets the current value of the progress


As it was mentioned above, the <rich:progressBar> component displays the status of the ongoing process.

The <rich:progressBar> component can run in two modes: Ajax (default) and Client.

In order to define the mode you need to use "mode" attribute.

One of the key attributes of the component is "interval" which defines the frequency of status polling and rerenders the component when the value is updated.

Polling is active while the "enabled" attribute is "true".

Example:


...
<rich:progressBar value="#{bean.incValue}" id="progrs" interval="900" enabled="true"/>
... 

With the help of "timeout" attribute you can define the waiting time on a particular request. If a response is not received during this time the request is aborted.

Status of the process is calculated basing on values of the following attributes:

Example:


...
<rich:progressBar value="#{bean.incValue}"  minValue="50"  maxValue="400"/>
... 

This is the result


There are two ways to display information on a progress bar:

  • Using "label" attribute

    Example:

    
    ... 
    <rich:progressBar value="#{bean.incValue}" id="progrs" label="#{bean.incValue}"/>
    ...
  • Using any child(nested) components. One of the components that can be used is <h:outputText />

    Example:

    
    ...
    <rich:progressBar value="#{bean.incValue}">
        <h:outputText value="#{bean.incValue} %"/>
    </rich:progressBar>
    ... 

The <rich:progressBar> component provides 3 predefined macrosubstitution parameters:

  • {value} contains the current value

  • {minValue} contains min value

  • {maxValue} contains max value

You can use them as follows:

Example:


...
<rich:progressBar value="#{bean.incValue1}" minValue="400" maxValue="900">
        <h:outputText value="Min value is {minValue}, current value is {value}, max value is {maxValue}"/>
</rich:progressBar> 
... 

This is the result:


The "parameters" is also a special attribute which defines parameters that can be to get additional data from server (e.g. additional info about process status). All you need is to define the value of your own parameter (e.g parameters="param:'#{bean.incValue1}'") and you can use it to pass the data.

Example:


...
<rich:progressBar value="#{bean.incValue}" parameters="param:'#{bean.dwnlSpeed}'">
    <h:outputText value="download speed {param} KB/s"/>
</rich:progressBar>
... 

This is the result:


The "progressVar" attribute (deprecated) defines request scoped variable that could be used for substitution purpose. This variable contains the data taken from "value" attribute. Please, study carefully the following example.

Example:


...
<rich:progressBar value="#{bean.incValue1}" enabled="#{bean.enabled1}" id="progrs1" progressVar="progress">
    <h:outputText value="{progress}%"/>
</rich:progressBar>
... 

In the shown example "progressVar" attribute defines a variable "progress" with the value taken from "value" attribute of the <rich:progressBar> component. The "progress" variable performs substitution passing the current progress value to the "value" attribute of the <h:outputText> . This is how the current value of a progress appears on the label of <rich:progressBar> .

As the "progressVar" attribute is deprecated, it's better to use the predefined macrosubstitution parameter {value} instead. See how you can rewrite the above example with the help of {value}.

Example:


...
<rich:progressBar value="#{bean.incValue1}" enabled="#{bean.enabled1}" id="progrs1">
    <h:outputText value="{value}%"/>
</rich:progressBar>
... 

The component can also employ "initial" and "complete" facets to display the states of the process: "initial" facet is displayed when the progress value is less or equal to "minValue" , and the "complete" facet is shown when the value is greater or equal to "maxValue" . Please see an example below.

Example:


...
<rich:progressBar value="#{bean.incValue1}">
    <f:facet name="initial">
        <h:outputText value="Process not started"/>
    </f:facet>
    <f:facet name="complete">
        <h:outputText value="Process completed"/>
    </f:facet>
</rich:progressBar> 
 ... 

Information about the "process" attribute usage you can find " Decide what to process " guide section.

On the screenshot there are classes names that define styles for component elements.




Note:

It's necessary to define width of the component in pixels only.

In order to redefine styles for all <rich:progressBar> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.richfacesSkin .mceButton {                                 
    
border: 1px #FF0000 solid;                     
}  
...

This is the result:


In the example above background color of the remained part of progress area was changed.

It's also possible to change styles of a particular <rich:progressBar> component. In this case you should create own style classes and use them in corresponding <rich:progressBar> styleClass attributes. An example is placed below:

Example:


...
.myClass{  
background-color: #ebf3fd;
}
...

The "styleClass" attribute for <rich:progressBar> is defined as it's shown in the example below:

Example:


<rich:progressBar value="#{bean.incValue1}" styleClass="myClass"/>

This is the result:


As it could be seen on the picture above, background color of the remained part of progress area was changed.

On the component Live Demo page you can see the example of <rich:progressBar> usage and sources for the given example.

Table 6.485. rich : scrollableDataTable attributes

Attribute NameDescription
activeClassA CSS class to be applied to an active row
activeRowKeyRequest scope attribute under which the activeRowKey will be accessible
ajaxKeysThis attribute defines row keys that are updated after an AJAX request
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
columnClassesComma-delimited list of CSS style classes that are be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the "columns" attribute, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the "columns" attribute, the elements at the position in the list after the value of the "columns" attribute are ignored
componentStateIt defines EL-binding for a component state for saving or redefinition
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
firstA zero-relative row number of the first row to display
footerClassSpace-separated list of CSS style class(es) that are be applied to any footer generated for this table
frozenColCountDefines the number of the fixed columns from the left side that will not be scrolled via horizontal scroll. Default value is "0".
headerClassSpace-separated list of CSS style class(es) that are be applied to any header generated for this table
heightDefines a height of the component. Default value is "500px".
hideWhenScrollingIf "true" data will be hidden during scrolling. Can be used for increase performance. Default value is "false".
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
onRowClickHTML: a script expression; a pointer button is clicked on row
onRowDblClickHTML: a script expression; a pointer button is double-clicked on row
onRowMouseDownHTML: script expression; a pointer button is pressed down on row
onRowMouseUpHTML: script expression; a pointer button is released on row
onselectionchangeHTML: script expression to invoke on changing of rows selection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
rowsA number of rows to display, or zero for all remaining rows in the table
scriptVarName of JavaScript variable corresponding to component
selectedClassName of the CSS class for a selected row
selectionValue binding representing selected rows
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
sortModeDefines mode of sorting. Possible values are 'single' for sorting of one column and 'multi' for some.
sortOrderValueBinding pointing at a property of a class to manage rows sorting
stateVarThe attribute provides access to a component state on the client side
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component
varA request-scope attribute via which the data object for the current row will be used when iterating
widthDefines a width of the component. Default value is "700px".

Table 6.486. rich : separator attributes

Attribute NameDescription
alignThis attribute specifies a position of the separator according to the document. The possible values are "left", "center" and "right". Default value is "left".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
heightThe separator height. Default value is "6px".
idEvery component may have a unique id that is automatically created if omitted
lineTypeA line type. The possible values are "beveled", "dotted", "dashed", "double", "solid" and "none". Default value is "beveled"
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleHTML: An advisory title for this element. Often displayed as a tooltip
widthThe separator width that can be defined in pixels or in percents. Default value is "100%".


On the component LiveDemo page you can see the example of <rich:separator> usage and sources for the given example.

Table 6.489. rich : simpleTogglePanel attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bodyClassA class that defines a style for a panel content
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
headerClassClass that defines the style for panel header
heightHeight of a simple toggle panel content area might be defined as pixels or in percents. By default height is not defined
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
iterationStateiterationState
labelMarker to be rendered on a panel header
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression; before a panel is collapsed
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onexpandHTML: script expression; before a panel is expanded
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
openedA "false" value for this attribute makes the panel closed by default. Default value is "true".
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypePanels switch mode: "client", "server"(default), "ajax"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component
widthWidth of a simple toggle panel might be defined as pixels or in percents. By default width is not defined


On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:simpleTogglePanel> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-stglpanel-header{
    
font-style:italic;
}
...

This is a result:


In the example the font style for header was changed.

Also it's possible to change styles of particular <rich:simpleTogglePanel> component. In this case you should create own style classes and use them in corresponding <rich:simpleTogglePanel> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
background-color:#ffead9;
}
...

The "bodyClass" attribute for <rich:simpleTogglePanel> is defined as it's shown in the example below:

Example:


<rich:simpleTogglePanel ... bodyClass="myClass"/>

This is a result:


As it could be seen on the picture above,background color for body was changed.

On the component LiveDemo page you can see the example of <rich:simpleTogglePanel> usage and sources for the given example.



On the component LiveDemo page you can see the example of <rich:spacer> usage and sources for the given example.

Table 6.499. rich : suggestionbox attributes

Attribute NameDescription
ajaxSingleBoolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only. Default value is "true"
bgcolorDeprecated. This attribute sets the background color for the document body or table cells. This attribute sets the background color of the canvas for the document body (the BODY element) or for tables (the TABLE, TR, TH, and TD elements). Additional attributes for specifying text color can be used with the BODY element. This attribute has been deprecated in favor of style sheets for specifying background color information
bindingThe attribute takes a value-binding expression for a component property of a backing bean
borderThis attributes specifies the width (in pixels only) of the frame around a table
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
cellpaddingThis attribute specifies the amount of space between the border of the cell and its contents. If the value of this attribute is a pixel length, all four margins should be this distance from the contents. If the value of the attribute is percentage length, the top and bottom margins should be equally separated from the content based on percentage of the available vertical space, and the left and right margins should be equally separated from the content based on percentage of the available horizontal space
cellspacingThis attribute specifies how much space the user agent should leave between the table and the column on all four sides. The attribute also specifies the amount of space to leave between cells
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
entryClassName of the CSS class for a suggestion entry element. (table row)
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
fetchValueA value to set in the target input element on a choice suggestion that isn't shown in the suggestion table. It can be used for descriptive output comments or suggestions. If not set, all text in the suggestion row is set as a value
firstA zero-relative row number of the first row to display
forid (or full path of id's) of target components, for which this element must provide support. If a target component inside of the same <code>NamingContainer</code> (UIForm, UIData in base implementations), can be simple value of the "id" attribute. For other cases must include id's of <code>NamingContainer</code> components, separated by ':'. For search from the root of components, must be started with ':'.
frameThis attribute specifies which sides of the frame surrounding a table will be visible. Possible values: "void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box" and "border". The default value is "void".
frequencyDelay (in seconds) before activating the suggestion pop-up. Default value is 400ms
heightHeight of the pop-up window in pixels. Default value is "200".
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase.
langCode describing the language used in the generated markup for this component
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
minCharsMinimal number of chars in input to activate suggestion pop-up
nothingLabel"nothingLabel" is inserted to popup list if the autocomplete returns empty list. It isn't selectable and list is closed as always after click on it and nothing is put to input.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
oncompleteJavaScript code for call after request completed on client side
onobjectchangeHTML: script expression; selected objects are changed
onselectHTML: script expression; after value of target element is updated
onsubmitHTML: script expression; before ajax event is submited
paramName the HTTP request parameter with the value of input element token. If not set, it be will sent as an input element name. In this case, input will perform validation and update the value. Default value is "inputvalue".
popupClassHTML CSS class attribute of element for pop-up suggestion content
popupStyleHTML CSS style attribute of element for pop-up suggestion content
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rowClassesA comma-delimited list of CSS style classes that is applied to popup table rows. A space separated list of classes may also be specified for any individual row. The styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again
rulesThis attribute specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values: * none: No rules. This is the default value. * groups: Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. * rows: Rules will appear between rows only. * cols: Rules will appear between columns only. * all: Rules will appear between all rows and columns
selectedClassName of the CSS class for a selected suggestion entry element (table row)
selectValueClassName of the CSS class for a selected suggestion entry element (table cell)
selfRenderedIf "true", forces active Ajax region render response directly from stored components tree, bypasses page processing. Can be used for increase performance. Also, must be set to 'true' inside iteration components, such as dataTable.
shadowDepthPop-up shadow depth for suggestion content
shadowOpacityAttribute defines shadow opacity for suggestion content
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
suggestionActionMethod calls an expression to get a collection of suggestion data on request. It must have one parameter with a type of Object with content of input component and must return any type allowed for <h:datatable>
summaryThis attribute provides a summary of the table's purpose and structure for user agents rendering to non-visual media such as speech and Braille
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
tokensThe list (or single value) of symbols which can be used for division chosen of suggestion pop-up values in a target element. After input of a symbol from the list suggestion pop-up it is caused again
usingSuggestObjectsif true, a suggested object list will be created and will be updated every time when an input value is changed. Default value is "false".
varA request-scope attribute via which the data object for the current row will be used when iterating
widthWidth of the pop-up window in pixels. Default value is "200".
zindexAttribute is similar to the standard HTML attribute and can specify window placement relative to the content. Default value is "200".


As it is shown in the example above, the main component attribute are:

There are also two size attributes ( "width" and "height" ) that are obligatory for the suggestion component. The attributes have initial Defaults but should be specified manually in order to be changed.

The suggestionbox component, as it is shown on the screenshot, could get any collection for an output and outputs it in a ToolTip window the same as a custom dataTable (in several columns)


...
    <rich:suggestionbox for="test" suggestionAction="#{bean.autocomplete}" var="cit" fetchValue="#{cit.text}">
        <h:column>
            <h:outputText value="#{cit.label}"/>
        </h:column>
        <h:column>
            <h:outputText value="#{cit.text}"/>
        </h:column>
    </rich:suggestionbox>
...

It looks on a page in the following way:


When some string is chosen input receives the corresponding value from the second column containing #{cit.text}

There is also one more important attribute named "tokens" that specifies separators after which a set of some characters sequence is defined as a new prefix beginning from this separator and not from the string beginning.

Example:


...
    <rich:suggestionbox for="test" suggestionAction="#{bean.autocomplete}" var="cit" selfRendered="true" tokens=","> 
        <h:column>
            <h:outputText value="#{cit.text}"/>
        </h:column>
    </rich:suggestionbox>
...

This example shows that when a city is chosen and a comma and first letter character are input, Ajax request is called again, but it submits a value starting from the last token:


For a multiple definition use either ",.; " syntax as a value for tokens or link a parameter to some bean property transmitting separators collection.

The component also encompasses "style" attributes corresponding to dataTable ones for a table appearing in popup (for additional information, read JSF Reference) and custom attribute managing AJAX requests sending (for additional information, see Ajax4JSF Project).

In addition to these attributes common for Ajax action components and limiting requests quantity and frequency, suggestionbox has one more its own attribute limiting requests (the "minChars" attribute). The attribute defines characters quantity inputted into a field after which Ajax requests are called to perform suggestion.

There is possibility to define what be shown if the autocomplete returns empty list. Attribute "nothingLabel" or facet with the same name could be used for it.

Example:


...
    <rich:suggestionbox nothingLabel="Empty" for="test" suggestionAction="#{bean.autocomplete}" var="cit"> 
        <h:column>
            <h:outputText value="#{cit.text}"/>
        </h:column>
    </rich:suggestionbox>
...

Example:


...
<rich:suggestionbox for="test" suggestionAction="#{bean.autocomplete}" var="cit"> 
    <f:facet name="nothingLabel">
        <h:outputText value="Empty"/>
    </f:facet>      
    <h:column>
        <h:outputText value="#{cit.text}"/>
    </h:column>
</rich:suggestionbox>
...

It looks on a page in the following way:


There is such feature in <rich:suggestionbox> component as object selection. If you want that selected item has been represented as object, you could set to "true" the value for "usingSuggestObjects" attribute, "false" value means that selected item represents as string.

Example:


...
<rich:suggestionbox for="test" suggestionAction="#{bean.autocomplete}" var="cit" usingSuggestObjects="true"> 
        <h:column>
                <h:outputText value="#{cit.text}"/>
        </h:column>
</rich:suggestionbox>
...

Information about the "process" attribute usage you can findin the "Decide what to process" guide section.

Here you can find example of getting additional properties.


On the screenshot, there are classes names defining specified elements.


In order to redefine styles for all <rich:suggestionbox> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:


...
.rich-sb-int{
        
font-weight:bold;
}
...

This is a result:


In the example the font weight for rows was changed.

Also it's possible to change styles of particular <rich:suggestionbox> component. In this case you should create own style classes and use them in corresponding <rich:suggestionbox> styleClass attributes. An example is placed below:

Example:


...
.myClass{
        
background-color:#f0ddcd;
}
...

The "selectedClass" attribute for <rich:suggestionbox> is defined as it's shown in the example below:

Example:


<rich:suggestionbox ... selectedClass="myClass"/>

This is a result:


As it could be seen on the picture above,background color for selected item was changed.

Vizit SuggestionBox page at RichFaces Livedemo for examples of component usage and sources.

RichFaces cookbook at JBoss Portal includes some articles that cover different aspects of working with <rich:suggestionbox> :

Table 6.508. rich : tabPanel attributes

Attribute NameDescription
activeTabClassA CSS class to be applied to an active tab
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassA CSS class for content of a tab panel
contentStyleA CSS style is for the content of a tab panel
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledTabClassA CSS class to be applied to a disabled tab
headerAlignmentSets tab headers alignment. It can be "left" or "right". Default value is "left".
headerClassA CSS style is for the header of a tab panel.
headerSpacingSets tab headers spacing. It should be a valid size unit expression. Default value is "1px".
heightHeight of a tab panel defined in pixels or in percents
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inactiveTabClassCSS class to be applied to an inactive (but not disabled) tab
labelA localized user presentable name for this component.
langCode describing the language used in the generated markup for this component
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
ontabchangeHTML: a script expression; a tab has been changed
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
selectedTabAttribute defines name of selected tab
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTabs switch mode: "client", "server"(default), "ajax"
tabClassA CSS class to be applied to all tabs
titleAdvisory title information about markup elements generated for this component
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes
widthWidth of a tab panel defined in pixels or in percents. The default value is 100%


As it was mentioned above, tabPanel groups content on panels and performs switching from one to another. Hence, modes of switching between panels are described first of all.

Note:

All tabPanels should be wrapped into a form element so as content is correctly submitted inside. If a form is placed into each tab, the Action elements of Tab controls appear to be out of the form and content submission inside the panels could be performed only for Action components inside tabs.

Switching mode could be chosen with the tabPanel attribute "switchType" with three possible parameters.

  • Server (DEFAULT)

    The common submission is performed around tabPanel and a page is completely rendered on a called panel. Only one at a time tabPanel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the tabPanel, content of the called tabPanel is uploaded on Ajax request. Only one at a time tabPanel is uploaded on the client.

  • Client

    All tabPanels are uploaded on the client side. The switching from the active to the hidden panel is performed with client JavaScript.

As a result, the tabPanel is switched to the second tab according to the action returning outcome for moving onto another page and switching from the second to the first tab is performed.

There is also the "selectedTab" attribute. The attribute keeps an active tab name; therefore, an active tabPanel could be changed with setting a name of the necessary tab to this attribute.

There is also the "headerAlignment" attribute responsible for rendering of tabPanel components. The attribute has several values: "left" (Default), "right", "center", which specify Tabs components location on the top of the tabPanel.

Example:


...
    <rich:tabPanel width="40%" headerAlignment="right">
        <rich:tab label="Canon">
            ...
        </rich:tab>
        <rich:tab label="Nikon">
            ...
        </rich:tab>
        <rich:tab label="Olympus">
            ...
        </rich:tab>
    </rich:tabPanel>
...

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM", {2} for "ShortConverter.SHORT".

Except the specific attributes, the component has all necessary attributes for JavaScript events definition.

  • "onmouseover"

  • "onmouseout"

  • etc.

On the screenshot there are classes names that define styles for component elements.




In order to redefine styles for all <rich:tabPanel> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:


...
.rich-tabhdr-cell-active{
    
font-weight: bold;
}
...

This is a result:


In the example a tab active font weight and text color were changed.

Also it's possible to change styles of particular <rich:tabPanel> component. In this case you should create own style classes and use them in corresponding <rich:tabPanel> styleClass attributes. An example is placed below:

Example:


...
.myClass{
       
font-style: italic;
}
...

The "styleClass" attribute for <rich:tabPanel> is defined as it's shown in the example below:

Example:


<rich:tabPanel ... activeTabClass="myClass"/>

This is a result:


As it could be seen on the picture above, font style on inactive tab was changed.

On the component LiveDemo page you can see the example of <rich:tabPanel> usage and sources for the given example.

Table 6.514. rich : tab attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledDisables a tab in a tab panel
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
labelText for the actual "tab" in a tab section
labelWidthLength for the actual "tab" in a tab section defined in pixels. If it is not defined, the length is calculated basing on a tab label text length
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
nameAttribute defines tab name. Default value is "getId()".
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onlabelclickA JavaScript event handler; a label of the tab is clicked
onlabeldblclickA JavaScript event handler; a pointer within label is double-clicked
onlabelkeydownA JavaScript event handler; a key within label is pressed down
onlabelkeypressA JavaScript event handler; a key within label is pressed and released
onlabelkeyupA JavaScript event handler; a key within label is released
onlabelmousedownA JavaScript event handler; a pointer within label is pressed down
onlabelmousemoveA JavaScript event handler; a pointer is moved within label
onlabelmouseupA JavaScript event handler; a pointer within label is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
ontabenterEvent must occur on the tab which has been entered
ontableaveEvent must occur on the tab which has been left
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTabs switch mode. Possible values are "client", "server", "ajax", "page".
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleHTML: An advisory title for this element. Often displayed as a tooltip


The main component function is to define a content group that is rendered and processed when the tab is active, i.e. click on a tab causes switching onto a tab containing content corresponded to this tab.

The "label" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "label" attribute.

Example:


...
    <rich:tab>
        <f:facet name="label">  
            <h:graphicImage value="/images/img1.png"/>
        </f:facet>
        ...
        <!--Any Content inside-->
        ...
    </rich:tab>
...

A marker on a tab header defined with the "label" attribute. Moreover, each tab could be disabled (switching on this tab is impossible) with the "disable" attribute.

Example:


...
    <rich:tabPanel width="20%"> 
        <tabs:tab  label="Canon">
        <h:outputText value="Canon EOS Digital Rebel XT" />
              ...
      </tabs:tab>
      <tabs:tab  label="Nikon">
          <h:outputText value="Nikon D70s" />
             ...
        </tabs:tab>
        <tabs:tab label="Olympus">
            <h:outputText value="Olympus EVOLT E-500" />
                ...
            </tabs:tab>
            <tabs:tab disabled="true" name="disabled" label="Disabled"/>
    </rich:tabPanel>
...

With this example it's possible to generate the tab panel with the last disabled and three active tabs (see the picture).


Switching mode could be defined not only for the whole panel tab, but also for each particular tab, i.e. switching onto one tab could be performed right on the client with the corresponding JavaScript and onto another tab with an Ajax request on the server. Tab switching modes are the same as tabPanel ones.

Each tab also has an attribute name (alias for "id" attribute). Using this attribute value it's possible e.g. to set an active tab on a model level specifying this name in the corresponding attribute of the whole tab.

Except the specific component attributes it has all necessary attributes for JavaScript event definition.

  • "onmouseover"

  • "onmouseout"

  • etc.

Some event could be performed on the tab which has been entered/left using "ontabenter" / "ontableave" attributes. See the example below.

Example:


...
    <rich:tabPanel>
        <rich:tab label="Tab1" ontabenter="alert()">
            ...
        </rich:tab>
        ...
    </rich:tabPanel>
...

The following example shows how on the client side to get the names of entered/left tabs.

ontabenter="alert(leftTabName)"

Information about the "process" attribute usage you can find in the "Decide what to process" guide section.

Table 6.523. rich : togglePanel attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
initialStateIt contains a name of the first active facet
labelA localized user presentable name for this component.
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
stateOrderNames of the facets in the switching order. If ToggleControl doesn't contain information about a next facet to be shown it is switched corresponding to this attribute
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeFacets switch mode: "client", "server"(default), "ajax".
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe initial value to set when rendered for the first time. It contains information about an active facet
valueChangeListenerListener for value changes


As it was mentioned above, togglePanel splits content into named facets that become rendered and processed when a click performed on controls linked to this togglePanel (either switched on the client or send requests on the server for switching).

The initial component state is defined with "initialState" attribute, where a facet name that is shown at first is defined.

Note:

It's also possible to define an "empty" facet to implement the functionality as drop-down panels have and make the facet active when no content is required to be rendered.

Switching mode could be defined with the "switchType" attribute with three possible parameters:

  • Server (DEFAULT)

    The common submission is performed around togglePanel and a page is completely rendered on a called panel. Only one at a time the panel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the panel, content of the called panel is uploaded on an Ajax request . Only one at a time the panel is uploaded on the client side.

  • Client

    All panels are uploaded on the client side. The switching from the active to the hidden panel is performed with client JavaScript.

"Facets" switching order could be defined on the side of <rich:toggleControl> component or on the panel. On the side of the togglePanel it's possible to define facets switching order with the "stateOrder" attribute. The facets names are enumerated in such an order that they are rendered when a control is clicked, as it's not defined where to switch beforehand.

Example:


...
    <rich:togglePanel id="panel" initialState="panelB" switchType="client"
                        stateOrder="panelA,panelB,panelC">
        <f:facet name="panelA">
            ...
        </f:facet>
        <f:facet name="panelB">
            ...
        </f:facet>
        <f:facet name="panelC">
            ...
        </f:facet>
    </rich:togglePanel> 
    <rich:toggleControl for="panel" value="Switch"/>
...

The example shows a togglePanel initial state when the second facet (panelB) is rendered and successive switching from the first to the second happens.

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for "DoubleRangeValidator.MAXIMUM", {2} for "ShortConverter.SHORT".

On the component LiveDemo page you can see the example of <rich:togglePanel> usage and sources for the given example.

Table 6.526. rich : toggleControl attributes

Attribute NameDescription
accesskeyAccess key that, when pressed, transfers focus to this element
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleBoolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only.
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase skip updates of model beans an force render response. Can be used for validate components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dirDirection indication for text that does not inherit directionality. Possible values are "LTR" (left-to-right) and "RTL" (right-to-left).
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move, etc.)
focusid of element to set focus after request completed on client side
forString, which contains id (in the format of a UIComponent.findComponent() call) of the target Toggle Panel.
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. if "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onblurJavaScript code executed when this element loses focus
onclickJavaScript code executed when a pointer button is clicked over this element
oncompleteJavaScript code for call after request completed on client side
ondblclickJavaScript code executed when a pointer button is double clicked over this element
onfocusJavaScript code executed when this element receives focus
onkeydownJavaScript code executed when a key is pressed down over this element
onkeypressJavaScript code executed when a key is pressed and released over this element
onkeyupJavaScript code executed when a key is released over this element
onmousedownJavaScript code executed when a pointer button is pressed down over this element
onmousemoveJavaScript code executed when a pointer button is moved within this element
onmouseoutJavaScript code executed when a pointer button is moved away from this element
onmouseoverJavaScript code executed when a pointer button is moved onto this element
onmouseupJavaScript code executed when a pointer button is released over this element
panelIdAttribute defines Id for corresponding panel
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) to be applied when this component is rendered
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
switchToStateContains one of the facets names where target togglePanel is switched to
tabindexPosition of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
valueInitial value to set when rendered for the first time


As it was mentioned above, the control could be in any place in layout and linked to a switching panel that is managed with "for" attribute (in the "for" attribute the full component "id" is specified according to naming containers).

The togglePanel could be also switched from the side of the control instead of being strictly defined in "switchOrder" attribute of <rich:togglePanel>.

Example:


...
    <rich:togglePanel id="panel" initialState="empty" switchType="client">
        <f:facet name="first">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty" switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" Second" switchToState="second"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
    <f:facet name="second">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty" switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" first" switchToState="first"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
        <f:facet name="empty">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="first" switchToState="first"/>
                <rich:toggleControl for="helloForm:panel" value=" second" switchToState="second"/>
            </h:panelGroup>
        </f:facet>
    </rich:togglePanel>
...

In this example the switching is performed on facets specified in the "switchToState" attribute.

Information about the "process" attribute usage you can find " Decide what to process " guide section.

Table 6.529. rich : toolBar attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassA CSS style is to be applied to each element of tool bar content. Use this style, for example, to setup parameters of the font.
contentStyleA CSS style is to be applied to each element of tool bar content.
heightA height of a bar in pixels. If a height is not defined, a bar height depends of the "headerFontSize" skin parameter.
idEvery component may have a unique id that is automatically created if omitted
itemSeparatorA separator between items on a bar. Possible values are "none", "line", "square", "disc" and "grid". Default value is "none".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onitemclickHTML: a script expression; a pointer button is clicked on an item
onitemdblclickHTML: a script expression; a pointer button is double-clicked on an item
onitemkeydownHTML: a script expression; a key is pressed down on an item
onitemkeypressHTML: a script expression; a key is pressed and released on an item
onitemkeyupHTML: a script expression; a key is released on an item
onitemmousedownHTML: script expression; a pointer button is pressed down on an item
onitemmousemoveHTML: a script expression; a pointer is moved on an item
onitemmouseoutHTML: a script expression; a pointer is moved away from an item
onitemmouseoverHTML: a script expression; a pointer is moved onto an item
onitemmouseupHTML: script expression; a pointer button is released on an item
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
separatorClassA CSS class to be applied to tool bar separators.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
widthA width of a bar that can be defined in pixels or as percentage. Default value is "100%".


As it could be seen in the picture above, the image for itemSeparator was changed.

On the component LiveDemo page you can see the example of <rich:toolBar> usage and sources for the given example.


Table 6.537. rich : toolTip attributes

Attribute NameDescription
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which sends the request only. Default value is "true"
attachedIf the value of the "attached" attribute is "true", a component is attached to the parent component; if "false", component does not listen to activating browser events, but could be activated externally. Default value is "true"
bindingThe attribute takes a value-binding expression for a component property of a backing bean
directionDefines direction of the popup list to appear. Possible values are "top-right", "top-left", "bottom-right", "bottom-left", "auto". Default value is "bottom-right"
disabledIf false the components is rendered on the client but JavaScript for calling disabled. Default value is "false"
eventDEPRECATED. Use showEvent instead. Default value is "mouseover"
followMouseIf "true" tooltip should follow the mouse while it moves over the parent element. Default value is "false"
forId of the target component
hideDelayDelay in milliseconds before tooltip will be hidden. Default value is "0"
hideEventEvent that triggers the tooltip disappearance. Default value is "none" (so, the component does not disappears)
horizontalOffsetSets the horizontal offset between pop-up list and mouse pointer. Default value is "10"
idEvery component may have a unique id that is automatically created if omitted
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
layoutBlock/inline mode flag. Possible value are: "inline" or "block". Default value is "inline". Tooltip will contain div/span elements respectively
modeControls the way of data loading to a tooltip. May have following values: "client" (default) and "ajax"
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after the tooltip shown
ondblclickHTML: a script expression; a pointer button is double-clicked
onhideJavaScript code for call after the tooltip hidden
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onshowJavaScript code for call after the tooltip called (some element overed) but before its requesting
renderedIf "false", this component is not rendered
showDelayDelay in milliseconds before tooltip will be displayed. Default value is "0"
showEventEvent that triggers the tooltip. Default value is "onmouseover"
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
valueThe current value for this component
verticalOffsetSets the vertical offset between pop-up list and mouse pointer. Default value is "10"
zorderThe same as CSS z-index for toolTip. Default value is "99"


Text information, labeled on the <rich:toolTip> , is specified with "value" attribute. Text that is put between tooltip start and end tags will also be rendered as tooltip content and could be marked with HTML tags. Images, links, buttons and other RichFaces components are also may be put and composed inside the <rich:toolTip> . The <rich:toolTip> borders are stretched automatically to enclose the contents.

There are three ways to attach the <rich:toolTip> to a page element. The first and simplest one is when the <rich:toolTip> is nested into a page element the tooltip is applied to. This way is shown on example in the Creating the Component with a Page Tag section. The "attached" attribute is "true" by default in this case, which means that the tolltip will be invoked automatically when the mouse cursor is hovered above the parent component.

The second one uses <rich:toolTip> "for" attribute. In this case the <rich:toolTip> is defined separately from a component it is applied to.

Example:


<rich:panel id="panelId">
...
</rich:panel>
<rich:toolTip value="This is a tooltip." for="panelId"/>

These two ways are also applicable for HTML elements that are not presented in components tree built by facelets. Use "for" attribute to attach the <rich:toolTip> in both cases.

Example:


<!-- The <rich:toolTip> is nested into the parent HTML element -->
<div id="para1">
      <p>This paragraph and tooltip are nested into the same <div> element.</p>
      <rich:toolTip for="para1">This is a tooltip.</rich:toolTip>
</div>

<!-- The <rich:toolTip> is defined separately -->
<div id="para2">
      <p>The tooltip for this paragraph is defined separately.</p>
</div>
<rich:toolTip for="para2">This is a tooltip.</rich:toolTip>

The third way to invoke the <rich:toolTip> uses JS API function. List of JS API functions available for <rich:toolTip> is listed below. JS API functions are defined for a component the <rich:toolTip> is applied to. The <rich:toolTip> "attached" attribute should be set to "false" in this case.

Example:


<rich:panel id="panelId" onclick="#{rich:component("tooltipId")}.show(event);" />
<a4j:form>
      <rich:toolTip id="tooltipId" attached="false" value="This is a tooltip."/>
</a4j:form>

Notes:

To provide <rich:toolTip> component proper work in complex cases do the following:

  • specify "id's" for both <rich:toolTip> and component it is applied to;

  • define the <rich:toolTip> as last child, when nesting it into the component the <rich:toolTip> is applied to;

  • put the <rich:toolTip> into <a4j:form> when invoking it with JS API function.

The "mode" attribute is provided you to control the way of data loading to <rich:toolTip> . The component works properly in client and Ajax modes. In client mode <rich:toolTip> content is rendered once on the server and could be rerendered only via external submit. In Ajax mode <rich:toolTip> content is requested from server for every activation. For Ajax mode there is possibility to define a facet "defaultContent" , which provides default <rich:toolTip> content to be displayed, while main content is loading into the <rich:toolTip> (see the example below).

Example:


...
<h:commandLink value="Simple Link" id="link">
    <rich:toolTip followMouse="true" direction="top-right" mode="ajax" value="#{bean.toolTipContent}" horizontalOffset="5" 
        verticalOffset="5" layout="block">
        <f:facet name="defaultContent">
            <f:verbatim>DEFAULT TOOLTIP CONTENT</f:verbatim>
        </f:facet>
    </rich:toolTip>
</h:commandLink>
...

This is the result:


And after <rich:toolTip> loaded it is changed to next one:


<rich:toolTip> appears attached to the corner dependent on the "direction" attribute. By default it is positioned bottom-right. <rich:toolTip> activation occurs after an event, defined on the parent component, takes into consideration the "delay" attribute or after calling JS API function show(). "hideEvent" attribute defines the way how <rich:toolTip> disappears. It default value is "none", so the <rich:toolTip> does not disappears. Deactivation may be set for example on mouseout event on the parent component (excepting the situation when the mouse is hovered onto the <rich:toolTip> itself) or after calling JS API function hide().

By default, <rich:toolTip> appears smart positioned. But as you can see from the previous example, you can define an appearance direction via the corresponding attribute "direction" . And also it's possible to define vertical and horizontal offsets relatively to a mouse position.

Disabled <rich:toolTip> is rendered to a page as usual but JS that responds for its activation is disabled until enable() is called.

Moreover, to add some JavaScript effects, client events defined on it are used:

Standart:

  • "onclick"

  • "ondblclick"

  • "onmouseout"

  • "onmousemove"

  • "onmouseover"

Special:

  • "onshow" - Called after the tooltip is called (some element hovered) but before its request

  • "oncomplete" - Called just after the tooltip is shown

  • "onhide" - Called after the tooltip is hidden

On the component LiveDemo page you can see the example of <rich:toolTip> usage and sources for the given example.

Table 6.543. rich : tree attributes

Attribute NameDescription
acceptCursorsList of comma separated cursors that indicates when acceptable draggable over dropzone
acceptedTypesA list of drag zones types, which elements are accepted by a drop zone
adviseNodeOpenedMethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is expanded; java.lang.Boolean.FALSE, a particular treeNode is collapsed; null, a particular treeNode saves the current state
adviseNodeSelectedMethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is selected; java.lang.Boolean.FALSE, a particular treeNode is unselected; null, a particular treeNode saves the current state
ajaxChildActivationEncodeBehaviorDefines which nodes keys will be added to AjaxNodeKeys automatically on the request from the children of the node. Values: "none" - nothing, "node" - only current node, "subtree" - node and all its children.
ajaxKeysajaxKeys
ajaxNodeKeysKeys of the nodes (without subtree) to be updated for ajax request risen by the node itself
ajaxNodeSelectionEncodeBehaviorDefines which nodes keys will be added to AjaxNodeKeys automatically on selecting ajax request from the node. Values: "none" - nothing, "node" - only current node, "subtree" - node and all its children.
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
ajaxSubmitSelectionIf "true", an Ajax request to be submit when selecting node. Default value is "false".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
changeExpandListenerListener called on expand/collapse event on the node
componentStateIt defines EL-binding for a component state for saving or redefinition
cursorTypeMappingMapping between drop types and acceptable cursors
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disableKeyboardNavigationDisables keyboard navigation. Default value is "false"
dragIndicatorId of a component that is used as drag pointer during the drag operation
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeA drag zone type that is used for zone definition, which elements can be accepted by a drop zone
dragValueData to be sent to the drop zone after a drop event. Default value is "getRowKey()".
dropListenerMethodBinding representing an action listener method that will be notified after drop operation
dropValueData to be processed after a drop event. Default value is "getRowKey()".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
grabbingCursorsList of comma separated cursors that indicates when you has grabbed something
grabCursorsList of comma separated cursors that indicates when you can grab and drag an object
highlightedClassCorresponds to the HTML class attribute. Applied to highlighted node
iconThe icon for node
iconCollapsedThe icon for collapsed node
iconExpandedThe icon for expanded node
iconLeafAn icon for component leaves
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediateA flag indicating that this component value must be converted and validated immediately (during an Apply Request Values phase), rather than waiting until a Process Validations phase
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
nodeFaceNode face facet name
nodeSelectListenerMethodBinding representing an action listener method that will be notified after selection of node.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression to invoke on node collapsing
oncompleteJavaScript code for call after request completed on client side
oncontextmenuJavaScript handler to be called on right click. Returning false prevents default browser context menu from being displayed
ondblclickHTML: a script expression; a pointer button is double-clicked
ondragendA JavaScript event handler called after a drag operation
ondragenterA JavaScript event handler called on enter draggable object to zone
ondragexitA JavaScript event handler called after a drag object leaves zone
ondragstartA JavaScript event handler called before drag operation
ondropIt's an event that is called when something is dropped on a drop zone
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available
ondropoutA JavaScript event handler called after a out operation
ondropoverA JavaScript event handler called after a drop operation
onexpandHTML: script expression to invoke on node expansion
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectedHTML: script expression to invoke on node selection
preserveDataInRequestIf "true", data is preserved in a request. Default value is "true".
preserveModelPossible values are "state", "request", "none". Default value is "request"
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rejectCursorsList of comma separated cursors that indicates when rejectable draggable over dropzone
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rightClickSelectionAllow to select tree item using mouse right click
rowKeyConverterConverter for a row key object
rowKeyVarThe attribute provides access to a row key in a Request scope
selectedClassCorresponds to the HTML class attribute. Applied to selected node
showConnectingLinesIf "true", connecting lines are show
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
stateAdvisorValueBinding pointing at instance of class implementing org.richfaces.component.state.TreeStateAdvisor interface.
stateVarThe attribute provides access to a component state on the client side
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeTree Nodes switch mode: "client", "server", "ajax"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
toggleOnClickIf "false" do not toggle node state on click. If "true", than node will be toggles on click on ether node content, or node icon. Default value is "false".
treeNodeVarThe attribute provides access to a TreeNode instance in a Request scope
typeMappingThe attribute associates a type of dragable zone (dragType) with <rich:dndParam> defined for <rich:dropSupport> for passing parameter value to <rich:dragIndicator>. It uses JSON format: (drag_type: parameter_name).
valueThe current value for this component
varAttribute contains a name providing an access to data defined with value


As it has been mentioned above the <rich:tree> component allows rendering any tree-like data model.

You can build your <rich:tree> using model (org.richfaces.model.TreeNode or javax.swing.tree.TreeNode). In this case the <rich:tree> component interacts with data model via "TreeNode" interface ( org.richfaces.model.TreeNode ) that is used for the <rich:tree> nodes representation.

Actually you can develop and use your own implementation of the "TreeNode" interface or use a default one, which is defined with a default class "TreeNodeImpl" ( org.richfaces.model.TreeNodeImpl ).

The "value" attribute of the <rich:tree> component contains a nodes structure defined in a bean property.

When the <rich:tree> component is being rendered it iterates over the model nodes and renders them using one of its immediate <rich:treeNode> children. Data property of the current model TreeNode is exposed using "var" attribute, so if var="station" you can refer to that data using #{station} syntax.

In the following example the <rich:tree> is built from a simple org.richfaces.model.TreeNode model:

...

private TreeNodeImpl<String> stationRoot = new TreeNodeImpl<String>();
private TreeNodeImpl<String> stationNodes = new TreeNodeImpl<String>(); 
private String[] kickRadioFeed = { "Hall & Oates - Kiss On My List",
    "David Bowie - Let's Dance", "Lyn Collins - Think (About It)",
    "Kim Carnes - Bette Davis Eyes",
    "KC & the Sunshine Band - Give It Up" };
    ... 
stationRoot.setData("KickRadio");
stationNodes.addChild(0, stationRoot);
for (int i = 0; i < kickRadioFeed.length; i++){
    TreeNodeImpl<String> child = new TreeNodeImpl<String>();
    child.setData(kickRadioFeed[i]);
    stationRoot.addChild(i, child);
}
...

As it is mentioned before you need to pass #{stations.stationNodes} property to the "value" attribute and define the "var" attribute in order to refer to the data:


...
<rich:tree value="#{stations.stationNodes}" var="station">
    <rich:treeNode>
        <h:outputText value="#{station}" />
    </rich:treeNode>
</rich:tree>
...

This is a result:


Implementation of the <rich:tree> component provides another way to build a tree. This approach implies using a "XmlTreeDataBuilder" class ( org.richfaces.component.xml.XmlTreeDataBuilder ) that allows to transform XML into structures of objects containing "XmlNodeData" ( org.richfaces.component.xml.XmlNodeData ) instances as data, which could be represented by the <rich:tree> component.

Let's try to build a simple <rich:tree> from a local XML file. In the following example a simple XML file (stations.xml) is used as a radio station playlist:


<?xml version="1.0"?>
<station name="KickRadio">
        <feed date="today">
            <song time="07:00">Hall & Oates - Kiss On My List</song>
            <song time="07:03">David Bowie - Let's Dance</song> 
            <song time="07:06">Lyn Collins - Think (About It)</song>
            <song time="07:10">Kim Carnes - Bette Davis Eyes</song>
            <song time="07:15">KC & the Sunshine Band - Give It Up</song>
        </feed>
</station>

Now you need to create a bean that holds a model nodes:

...

private TreeNode data;
    ...
FacesContext context = FacesContext.getCurrentInstance();
data = XmlTreeDataBuilder.build(new InputSource(getClass().getResourceAsStream("stations.xml")));
...

Finally you should set the "value" attribute to the data bean property and define the "var" attribute in order to refer to the data of nodes:


...
<rich:tree id="treeXML" value="#{stations.data}" var="vardata">
    <rich:treeNode>
        <h:outputText value="#{vardata.attributes['name']}" />
        <h:outputText value="#{vardata.attributes['date']}" />
        <h:outputText value="#{vardata.attributes['time']}" />
        <h:outputText value=" #{vardata.text}" />
    </rich:treeNode>
</rich:tree>
...

This is a result:


It's possible to define a visual representation of a node data model (to define a node icon) and its behavior in correspondence with the data contained in this node (with a value of the "var" attribute). The node behavior is defined by the components nested into the <rich:treeNode> (e.g. links or buttons). For these purposes you should use "nodeFace" attribute. For each tree node a value of "nodeFace" attribute is evaluated and <rich:treeNode> with a value of "type" attribute equal to a value of "nodeFace" is used for node representation. See an example below.

Example:


...
<h:form>
    <rich:tree style="width:300px" value="#{library.data}" var="item" nodeFace="#{item.type}">
        <rich:treeNode type="artist" iconLeaf="/images/tree/singer.png" icon="/images/tree/singer.png">
            <h:outputText value="#{item.name}" />
        </rich:treeNode>
        <rich:treeNode type="album" iconLeaf="/images/tree/disc.png" icon="/images/tree/disc.png">
            <h:outputText value="#{item.title}" />
        </rich:treeNode>
        <rich:treeNode type="song" iconLeaf="/images/tree/song.png" icon="/images/tree/song.png">
            <h:outputText value="#{item.title}" />
        </rich:treeNode>
    </rich:tree>
</h:form>
...

This is a result:


In the example above, when each node of data model is processed, data contained in the "data" property of "TreeNode" interface is assigned to a request scope variable, which name is defined with "var" attribute. The value of the "nodeFace" attribute is evaluated in correspondence with the data assigned to the "var" attribute. The corresponding <rich:treeNode> component (with a value of "type" attribute equal to a value of "nodeFace" ) is used for the node representation. For example, during data model processing, an object with a name "Chris Rea" was inserted in the "var" attribute. Then the value of "nodeFace" attribute was evaluated as "artist". Thus, for the node representation the <rich:treeNode> with "type" equal to "artist" was used.

You can also assign an EL-expression as value of the "nodeFace" attribute. See an example below:

Example:



nodeFace="#{data.name != 'param-value' ? 'artist' : 'album'}"
 

There are some essential points in a "nodeFace" attribute usage: you need to define notions for typeless and a default nodes.

The typeless node is the first <rich:treeNode> component (from all children nodes nested to the <rich:tree> component) with not defined "type" attribute and defined "rendered" attribute. The typeless node is used for representation when "nodeFace" attribute is null.

Default node has the following interior presentation:

Example:


...
<h:outputText value="#{varAttributeName}">
...

"varAttributeName" is a value for "var" attribute.

Default node is used in the following cases:

  • "nodeFace" attribute is defined, but its value isn't equal to any "type" attribute value from all children nodes;

  • "nodeFace" attribute is defined and its value is equal to a value of some "type" attribute from all children nodes, but the value of "rendered" attribute for this node is "false".

There is also one thing that has to be remembered using "type" and "rendered" attributes: it's possible to define several <rich:treeNode> components with equal values of "type" attribute and different values of "rendered" attribute. It provides a possibility to define different representation styles for the same node types. In the example with artists and their albums (see above) it's possible to represent albums that are available for sale and albums that are not available. Please study the example below:

Example:


...
<h:form>
    <rich:tree style="width:300px" value="#{library.data}" var="item" nodeFace="#{item.type}">
    ...
        <rich:treeNode type="album" iconLeaf="/images/tree/album.gif" icon="/images/tree/album.gif"
                      rendered="#{item.exist}">
            <h:outputText value="#{item.name}" />
        </rich:treeNode>
        <rich:treeNode type="album" iconLeaf="/images/tree/album_absent.gif" icon="/images/tree/album_absent.gif"
                      rendered="#{not item.exist}">
            <h:outputText value="#{item.name}" />
        </rich:treeNode>
    ...
    </rich:tree>
</h:form>
...

This is a result of the code:


In the example the <rich:treeNode> components has equal values of the "type" attribute. Depending on value of the "rendered" attribute the corresponding <rich:treeNode> component is selected for node representation. If an album is available for sale the value of the "rendered" for the first <rich:treeNode> component is "true", for the second one is "false". Thus, the first <rich:treeNode> is selected for node representation.

Tree node can be run in tree modes. Modes can be specified with "switchType" attribute for <rich:tree> component.

  • Ajax (default value) - Ajax submission is used performing the functionality. Note, that for collapse/expand operations an Ajax request is sent to the server and it can cause a short delay.

  • Server - regular form of submission request is used.

  • Client – all operations are performed totally on the client; no interaction with a server is involved. Full page content is reloaded after every action.

The "icon" , "iconCollapsed" , "iconExpanded" , "iconLeaf" attributes set the icons' images for the component. You can also define icons using facets with the same names. If the facets are defined, the corresponding attributes are ignored and facets' content is used as icons. By default the width of a rendered facet area is 16px.

Example:


...
<rich:tree value="#{library.data}" var="item">
    ...
    <f:facet name="icon">
        <h:graphicImage value="/images/tree/singer.png "/>
    </f:facet>
    <f:facet name="iconCollapsed">
        <h:graphicImage value="/images/tree/singer.png" />
    </f:facet>
    <f:facet name="iconExpanded">
        <h:graphicImage value="/images/tree/singer.png" />
    </f:facet>
    <f:facet name="iconLeaf">
        <h:graphicImage value="/images/tree/song.png" />
    </f:facet>
    ...
</rich:tree>
...

The <rich: tree> component can be used together with <rich: treeNodeAdaptor> . In this case there is no need to specify the attributes "value" and "var" . Besides, visual representation shouldn't be defined right in the tree. In this case a <rich: tree> tag is applied mainly for defining common attributes such as "ajaxSubmitSelection" etc.

Information about the "process" attribute usage you can find in the "Decide what to process" guide section.

The value of "rowKeyConverter" can be:

  • org.richfaces.TreeRowKeyConverter - it used for the simple tree.

  • org.richfaces.TreeAdaptorRowKeyConverter used for tree with <rich:treeNodesAdaptor>

  • The org.richfaces.TreeAdaptorIntegerRowKeyConverter converter used for adaptor-based tree for implementing custom converters

Words "built-in" in this context mean, that <rich:tree> component has its own attributes, that provide drag-and-drop capability. These attributes can be divided into two groups: those ones which provide drag and those which provide drop operations (see the tables below).



Consider drag-and-drop inside a tree. All zones, which are assumed to be dragged, must be marked. In terms of <rich:tree> these zones completely correspond to tree nodes. So, all dragging nodes should be marked with "dragType" attribute. Then, to mark zone(-s), where the dragging node could be dropped, pass the type of dragging node to the "acceptedTypes" attribute of the drop zone. It would be good to itemize, that each tree node in the <rich:tree> component’s structure has its own key. Depending on how the component is used, these keys can be generated by the component itself or can be taken from the component’s data model. Keys help to identify each node in a tree; key is what exactly being passing from one node to another in drag-and-drop operations. Finally, the method binding, that will process drag-and-drop operation, should be pointed via "dropListener" attribute of the <rich:tree> .

Chapters "6.40 <dragIndicator>" and "6.39 <dndParam>" describes how to apply visual element, that show some additional information (e.g. dragging item name) while operating with drag-and-drop.

Page code, that describes a tree with built in drag-and-drop in the way it is considered, is shown below.

Example:


...
<h:form>
     <rich:tree style="width:300px" value="#{libraryAjaxTree.data}" nodeFace="#{item.type}" var="item" dragIndicator=":treeDragIndicator" dropListener="#{libraryAjaxTree.processDrop}">
          <rich:treeNode type="artist" icon="/images/tree/group.png" iconLeaf="/images/tree/group.png" acceptedTypes="album">
               <h:outputText value="#{item.name}" />
          </rich:treeNode>
          <rich:treeNode type="album" icon="/images/tree/cd.png" iconLeaf="/images/tree/cd.png" dragType="album" acceptedTypes="song">
               <h:outputText value="#{item.title}" />
               <rich:dndParam name="label" type="drag" value="Album: #{item.title}" />
          </rich:treeNode>
          <rich:treeNode type="song" icon="/images/tree/music.png" iconLeaf="/images/tree/music.png" dragType="song">
               <h:outputText value="#{item.title}" />
               <rich:dndParam name="label" type="drag" value="Song: #{item.title}" />
          </rich:treeNode>
    </rich:tree>
</h:form>
...

This code renders following tree:


Listeners classes that process events on the server side are defined with the help of:

Listener methods can be defined using the following attributes or using nested tags.

Client event attributes are:

  • "onexpand" is a script expression to invoke when a node is expanded

  • "oncollapse" is a script expression to invoke when a node is collapsed

  • "ondragexit" is a script expression to invoke when an element passing out from a tree zone

  • "ondragstart" is a script expression to invoke when dragging starts

  • "ondragend" is a script expression to invoke when dragging ends (a drop event)

  • "ondragenter" is a script expression to invoke when a dragged element appears on a tree

They can be used to add some JavaScript effects.

Standart HTML event attributes like "onclick" , "onmousedown" , "onmouseover" etc. can be also used. Event handlers of a <rich:tree> component capture events occured on any tree part. But event handlers of treeNode capture events occured on treeNode only, except for children events.

On the component LiveDemo page you can see the example of <rich:tree> usage and sources for the given example.

How to Expand/Collapse Tree Nodes from code, see in thiswiki article.

Table 6.550. rich : treeNode attributes

Attribute NameDescription
acceptCursorsList of comma separated cursors that indicates when acceptable draggable over dropzone
acceptedTypesA list of drag zones types, which elements are accepted by a drop zone
ajaxSingleboolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
ajaxSubmitSelectionAn algorithm of AJAX request submission. Possible values are "inherit", "true", "false". Default value is "inherit".
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
changeExpandListenerListener called on expand/collapse event on the node
cursorTypeMappingMapping between drop types and acceptable cursors
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
dragIndicatorId of a component that is used as drag pointer during the drag operation
dragListenerMethodBinding representing an action listener method that will be notified after drag operation
dragTypeA drag zone type that is used for zone definition, which elements can be accepted by a drop zone
dragValueData to be sent to the drop zone after a drop event. Default value is "getUITree().getDragValue()".
dropListenerMethodBinding representing an action listener method that will be notified after drop operation
dropValueData to be processed after a drop event. Default value is "getUITree().getDropValue()".
eventsQueueName of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focusid of element to set focus after request completed on client side
grabbingCursorsList of comma separated cursors that indicates when you has grabbed something
grabCursorsList of comma separated cursors that indicates when you can grab and drag an object
highlightedClassCorresponds to the HTML class attribute. Applied to highlighted node
iconThe icon for node
iconCollapsedThe icon for collapsed node
iconExpandedThe icon for expanded node
iconLeafAn icon for component leaves
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
nodeClassName of node CSS class
nodeSelectListenerMethodBinding representing an action listener method that will be notified after selection of node.
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseHTML: script expression to invoke on node collapsing
oncompleteJavaScript code for call after request completed on client side
oncontextmenuJavaScript handler to be called on right click. Returning false prevents default browser context menu from being displayed
ondblclickHTML: a script expression; a pointer button is double-clicked
ondragendA JavaScript event handler called after a drag operation. Default value is "getDefaultOndragend()".
ondragenterA JavaScript event handler called on enter draggable object to zone. Default value is "getDefaultOndragenter()".
ondragexitA JavaScript event handler called after a drag object leaves zone. Default value is "getDefaultOndragexit()".
ondragstartA JavaScript event handler called before drag object. Default value is "getDefaultOndragstart()".
ondropIt's an event that is called when something is dropped on a drop zone. Default value is "getDefaultOndrop()".
ondropendA JavaScript handler for event fired on a drop even the drop for a given type is not available. Default value is "getDefaultOndropend()".
ondropoutA JavaScript event handler called after a out operation
ondropoverA JavaScript event handler called after a drop operation
onexpandHTML: script expression to invoke on node expansion
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectedHTML: script expression to invoke on node selection
processId['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rejectCursorsList of comma separated cursors that indicates when rejectable draggable over dropzone
renderedIf "false", this component is not rendered
requestDelayAttribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRenderId['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection. Default value is "getDefaultReRender()".
selectedClassCorresponds to the HTML class attribute. Applied to selected node
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
timeoutGets timeout in ms. Default value is "getDefaultTimeout()".
typeA node type
typeMappingThe attribute associates a type of dragable zone (dragType) with <rich:dndParam> defined for <rich:dropSupport> for passing parameter value to <rich:dragIndicator>. It uses JSON format: (drag_type: parameter_name).


The "icon" , "iconCollapsed" , "iconExpanded" , "iconLeaf" attributes define icons for the component. Also you can define icons using facets with the same names. If the facets are defined, the corresponding attributes are ignored and facets contents are used as icons. The width of a rendered facet area is 16px.


...
    <rich:tree ...>
        ...
        <rich:treeNode ...>
            <f:facet name="icon">
                <outputText value="A"/>
            </f:facet>
            <f:facet name="iconCollapsed">
                <outputText value="B"/>
            </f:facet>      
            <f:facet name="iconExpanded">
                <outputText value="C"/>
            </f:facet>
            <f:facet name="iconLeaf">
                <outputText value="D"/>
            </f:facet>
        </rich:treeNode>
        ...
    </rich:tree>
...

As it has been mentioned above, <rich:treeNode> defines a template for nodes rendering in a tree. Thus, during XML document rendering (a web.xml application) as a tree, the following nodes output (passed via var="data" on a tree) happens:

Example:


...
    <rich:tree ... faceNode="simpleNode" ... value="#{bean.data}" var="data">
        <rich:treeNode type="simpleNode">
            <h:outputText value="context-param:"/>
            <h:inputText value="#{data.name}"/>
        </rich:treeNode>
    </rich:tree >
...

Hence, <h:outputText /> tag outputs the "context-param" string and then the <h:inputText /> outputs the data.name element of this node.

Different nodes for rendering could be defined depending on some conditions on the tree level. Each condition represents some rendering template. To get more information on various treeNodesAdaptorAdaptor definition for nodes, see the tree component chapter.

Switching between expanded/collapsed modes is also managed on the tree level and defined in the corresponding section.

Default nodes of the tree level as well as the ones defined with the treeNodesAdaptorAdaptor component could send Ajax requests when selected with the mouse, it's managed with the "ajaxSubmitSelection" attribute (true/false).

Information about the "process" attribute usage you can find " Decide what to process " guide section.

The main information on Drag and Drop operations is given in the corresponding paragraph of the tree component chapter. It's only necessary to mention that each node could also be a Drag element as well as a Drop container, i.e. the container and the element have all attributes, listeners and ways of behavior similar to the ones of the <rich:dragSupport > and <rich:dropSupport > components simultaneously.



The <rich:changeExpandListener> is used as a nested tag with <rich:tree> and <rich:treeNode> components.

Attribute "type" defines the fully qualified Java class name for the listener. This class should implement org.richfaces.event.NodeExpandedListener interface.

The typical variant of using:


...
<rich:tree switchType="server" value="#{project.data}" var="item" nodeFace="#{item.type}">
    <rich:changeExpandListener type="demo.ListenerBean"/>
    ...
    <!-- Tree nodes --> 
    ...
</rich:tree>
...

Java bean source:

package demo;

import org.richfaces.event.NodeExpandedEvent;
public class ListenerBean implements org.richfaces.event.NodeExpandedListener{
... 
    public void processExpansion(NodeExpandedEvent arg0){
        //Custom Developer Code 
    }
...
}
...


The <rich:nodeSelectListener> is used as a nested tag with <rich:tree> and <rich:treeNode> components.

Attribute "type" defines the fully qualified Java class name for listener. This class should implement org.richfaces.event.NodeSelectedListener . interface

The typical variant of using:


...
<rich:tree switchType="server" value="#{project.data}" var="item" nodeFace="#{item.type}">
    <rich:nodeSelectListener type="demo.ListenerBean"/>
    ...
    <!-- Tree nodes --> 
    ...
</rich:tree>
...

Java bean source:

package demo;

import org.richfaces.event.NodeSelectedEvent;
public class ListenerBean implements org.richfaces.event.NodeSelectedListener{
... 
    public void processSelection(NodeSelectedEvent arg0){
        //Custom Developer Code 
    }
...
}


The <rich:recursiveTreeNodesAdaptor> component has a "roots" attribute that defines collection to use at the top of recursion.

The "nodes" attribute defines collection to use on another recursion levels.

The "var" attribute is used to access to the current collection element.

The <rich:recursiveTreeNodesAdaptor> component can be nested without any limitations. See the following example.

Example:


...
<rich:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
    <rich:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">   
        <rich:treeNode>
            <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
        </rich:treeNode>
        <rich:recursiveTreeNodesAdaptor id="dir" var="dir" root="#{project.dirs}" nodes="#{dir.directories}">
            <rich:treeNode>
                <h:commandLink action="#{dir.click}" value="Directory: #{dir.name}" />
            </rich:treeNode>            
            <rich:treeNodesAdaptor id="file" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>
            <rich:treeNodesAdaptor id="file1" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File1: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>
            <rich:recursiveTreeNodesAdaptor id="archiveEntry" var="archiveEntry"
                roots="#{dir.files}" nodes="#{archiveEntry.archiveEntries}" 
                includedRoot="#{archiveEntry.class.simpleName == 'ArchiveFile'}"
                includedNode="#{archiveEntry.class.simpleName == 'ArchiveEntry'}">      
                <rich:treeNode id="archiveEntryNode">
                    <h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
                </rich:treeNode>
            </rich:recursiveTreeNodesAdaptor>
        </rich:recursiveTreeNodesAdaptor>
    </rich:treeNodesAdaptor>
</rich:tree>
...

On the component Live Demo page you can see the example of <rich:recursiveTreeNodesAdaptor> usage.



The <rich:treeNodesAdaptor> component has a "nodes" attribute that defines a collection of elements to iterate through.

Collections are allowed to include lists, arrays, maps, XML NodeList and NamedNodeMap either as a single object.

The "var" attribute is used to access to the current collection element.

The <rich:treeNodesAdaptor> component can be nested without any limitations. See the following example.

Example:


...
<rich:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
    <rich:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">
        <rich:treeNode>
            <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
        </rich:treeNode>
    <rich:treeNodesAdaptor id="srcDir" var="srcDir" nodes="#{project.srcDirs}">
        <rich:treeNode>
            <h:commandLink action="#{srcDir.click}" value="Source directory: #{srcDir.name}" />
        </rich:treeNode>
    <rich:treeNodesAdaptor id="pkg" var="pkg" nodes="#{srcDir.packages}">
        <rich:treeNode>
            <h:commandLink action="#{pkg.click}" value="Package: #{pkg.name}" />
        </rich:treeNode>
    <rich:treeNodesAdaptor id="class" var="class" nodes="#{pkg.classes}">
        <rich:treeNode>
            <h:commandLink action="#{class.click}" value="Class: #{class.name}" />
        </rich:treeNode>
    </rich:treeNodesAdaptor>    
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
</rich:tree>
...

On the component LiveDemo page you can see the example of <rich:treeNodesAdaptor > usage and sources for the given example.

RichFaces support is implemented in JBoss Developer Studio 1.0.0 GA and in Jboss Tools. JBoss Developer Studio is a fully packaged IDE that provides full support for Java Server Faces, RichFaces, Facelets, Struts and other Web technologies. In addition to this, it seamlessly combines visual and source-oriented development approaches. One of the special support feature for RichFaces is that it is available as project "capabilitiy" which can be added to any existing JSF project by adding libraries and modifying configuration files as required."