Pro JSF and Ajax



Figure 1-7. UIComponent
inheritance
This model allows programmatic access to all properties and attributes defined by the dif-
ferent classes that build up the component. As mentioned earlier, the UIComponentBase class
contains behavioral agreements for all components, the UISelectOne subclass contains prop-
erties and methods specific to its behavior (for example, select one), and the renderer-specific
subclass (for example, HtmlSelectOneListbox) contains getters and setters for all renderer-
specific attributes as well as the rendererType for that particular component.

Using a Renderer-Specific Component Subclass
Code Sample 1-3 illustrates the benefit of using the behavioral superclass instead of the con-
venience class to manipulate the page at runtime. The first bit of code illustrates a page with
a simple selectOneRadio component with three options and a commandButton.

Code Sample 1-3.
JSF selectOneRadio Bound to a Renderer-Specific Subclass
<h:form>
<h:selectOneRadio binding="#{sample.selectOneRadio}" >
<f:selectItem itemLabel="Jonas" itemValue="jonas.jacobi" />
<f:selectItem itemLabel="John" itemValue="john.fallows" />
<f:selectItem itemLabel="Duke" itemValue="java.dude" />

</h:selectOneRadio>
<h:commandButton value="Select Duke"

actionListener="#{sample.onAction}" />
</h:form>
C H A P T E R 1
s
T H E F O U N D AT I O N O F J S F : C O M P O N E N T S
17