Registering a Custom Renderer with a Render Kit
2. Using the Tutorial Examples
3. Getting Started with Web Applications
4. JavaServer Faces Technology
7. Using JavaServer Faces Technology in Web Pages
8. Using Converters, Listeners, and Validators
9. Developing with JavaServer Faces Technology
10. JavaServer Faces Technology: Advanced Concepts
11. Using Ajax with JavaServer Faces Technology
12. Composite Components: Advanced Topics and Example
13. Creating Custom UI Components and Other Custom Objects
14. Configuring JavaServer Faces Applications
Using Annotations to Configure Managed Beans
Eager Application-Scoped Beans
Application Configuration Resource File
Ordering of Application Configuration Resource Files
Using the managed-bean Element
Initializing Properties Using the managed-property Element
Referencing a Context Initialization Parameter
Initializing Array and List Properties
Initializing Managed Bean Properties
Registering Application Messages
Using FacesMessage to Create a Message
Registering a Custom Validator
Registering a Custom Converter
To Configure a Navigation Rule
Registering a Custom Component
Basic Requirements of a JavaServer Faces Application
Configuring an Application with a Web Deployment Descriptor
Identifying the Servlet for Lifecycle Processing
To Specify a Path to an Application Configuration Resource File
To Specify Where State Is Saved
Including the Classes, Pages, and Other Resources
16. Uploading Files with Java Servlet Technology
17. Internationalizing and Localizing Web Applications
18. Introduction to Web Services
19. Building Web Services with JAX-WS
20. Building RESTful Web Services with JAX-RS
21. JAX-RS: Advanced Topics and Example
23. Getting Started with Enterprise Beans
24. Running the Enterprise Bean Examples
25. A Message-Driven Bean Example
26. Using the Embedded Enterprise Bean Container
27. Using Asynchronous Method Invocation in Session Beans
Part V Contexts and Dependency Injection for the Java EE Platform
28. Introduction to Contexts and Dependency Injection for the Java EE Platform
29. Running the Basic Contexts and Dependency Injection Examples
30. Contexts and Dependency Injection for the Java EE Platform: Advanced Topics
31. Running the Advanced Contexts and Dependency Injection Examples
32. Introduction to the Java Persistence API
33. Running the Persistence Examples
34. The Java Persistence Query Language
35. Using the Criteria API to Create Queries
36. Creating and Using String-Based Criteria Queries
37. Controlling Concurrent Access to Entity Data with Locking
38. Using a Second-Level Cache with Java Persistence API Applications
39. Introduction to Security in the Java EE Platform
40. Getting Started Securing Web Applications
41. Getting Started Securing Enterprise Applications
42. Java EE Security: Advanced Topics
Part VIII Java EE Supporting Technologies
43. Introduction to Java EE Supporting Technologies
45. Resources and Resource Adapters
46. The Resource Adapter Example
47. Java Message Service Concepts
48. Java Message Service Examples
49. Bean Validation: Advanced Topics
50. Using Java EE Interceptors
51. Duke's Bookstore Case Study Example
52. Duke's Tutoring Case Study Example
53. Duke's Forest Case Study Example
When the application developer creates a custom renderer, as described in Delegating Rendering to a Renderer, you must register it using the appropriate render kit. Because the image map application implements an HTML image map, the AreaRenderer and MapRenderer classes in the Duke’s Bookstore case study should be registered using the HTML render kit.
You register the renderer either by using the @FacesRenderer annotation, as described in Creating the Renderer Class, or by using the render-kit element of the application configuration resource file. Here is a hypothetical configuration of AreaRenderer:
<render-kit>
<renderer>
<component-family>Area</component-family>
<renderer-type>DemoArea</renderer-type>
<renderer-class>
dukesbookstore.renderers.AreaRenderer
</renderer-class>
<attribute>
<attribute-name>onmouseout</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
<attribute>
<attribute-name>onmouseover</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
<attribute>
<attribute-name>styleClass</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
</renderer>
...Attributes specified in a renderer tag override any settings in the @FacesRenderer annotation.
The render-kit element represents a javax.faces.render.RenderKit implementation. If no render-kit-id is specified, the default HTML render kit is assumed. The renderer element represents a javax.faces.render.Renderer implementation. By nesting the renderer element inside the render-kit element, you are registering the renderer with the RenderKit implementation associated with the render-kit element.
The renderer-class is the fully qualified class name of the Renderer.
The component-family and renderer-type elements are used by a component to find renderers that can render it. The component-family identifier must match that returned by the component class’s getFamily method. The component family represents a component or set of components that a particular renderer can render. The renderer-type must match that returned by the getRendererType method of the tag handler class.
By using the component family and renderer type to look up renderers for components, the JavaServer Faces implementation allows a component to be rendered by multiple renderers and allows a renderer to render multiple components.
Each of the attribute tags specifies a render-dependent attribute and its type. The attribute element doesn’t affect the runtime execution of your application. Rather, it provides information to tools about the attributes the Renderer supports.
The object responsible for rendering a component (be it the component itself or a renderer to which the component delegates the rendering) can use facets to aid in the rendering process. These facets allow the custom component developer to control some aspects of rendering the component. Consider this custom component tag example:
<d:dataScroller>
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Account Id"/>
<h:outputText value="Customer Name"/>
<h:outputText value="Total Sales"/>
</h:panelGroup>
</f:facet>
<f:facet name="next">
<h:panelGroup>
<h:outputText value="Next"/>
<h:graphicImage url="/images/arrow-right.gif" />
</h:panelGroup>
</f:facet>
...
</d:dataScroller>The dataScroller component tag includes a component that will render the header and a component that will render the Next button. If the renderer associated with this component renders the facets, you can include the following facet elements in the renderer element:
<facet>
<description>This facet renders as the header of the table. It should be
a panelGroup with the same number of columns as the data
</description>
<display-name>header</display-name>
<facet-name>header</facet-name>
</facet>
<facet>
<description>This facet renders as the content of the "next" button in
the scroller. It should be a panelGroup that includes an outputText
tag that has the text "Next" and a right arrow icon.
</description>
<display-name>Next</display-name>
<facet-name>next</facet-name>
</facet>If a component that supports facets provides its own rendering and you want to include facet elements in the application configuration resource file, you need to put them in the component’s configuration rather than the renderer’s configuration.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices


