C.1 Component Class Categories
The primary JSF component classes implement
render-independent behavior and must be combined with a renderer that
knows how to represent them in a particular markup language, such as
one of the renderers in the standard HTML render kit. Figure C-1 shows all render-independent component
classes.
Each component class belongs to a component
family, which identifies the basic nature of a component,
for example, that it's an output component or a
command component. More than one component class may belong to the
same family, e.g., both the base class and its subclasses, which
specialize the behavior of the base class. All standard component
family names starts with a javax.faces prefix
followed by descriptive name, e.g.,
javax.faces.Output for the
javax.faces.component.UIOutput class. A component
instance is associated with a renderer type that may be set
programmatically by the developer. The renderer
type
tells
in general terms how to represent the component, e.g., as a link or a
button. The standard renderer type IDs also have a
javax.faces prefix followed by a descriptive name,
e.g., javax.faces.Link for a link renderer.
The specific renderer class to use for a component is determined by
the combination of the renderer type it's configured
to use and the family it belongs to. This makes it possible to use
the same renderer type IDs for renderer classes with widely different
behavior. For instance, the renderer type ID
javax.faces.Link can be used for one renderer
class used with a component in the
javax.faces.Output family to render a regular HTML
link element with the components value as the URL, and also for
another renderer class used with a component in the
javax.faces.Command family to render an HTML link
element with JavaScript code for submitting the form it belongs to
and with the component's value as the link text.
Without the component family concept, one renderer class would have
to support both types of components, or renderer type IDs would have
to include the something similar to a family ID in their names, which
would lead to namespace scalability problems in the long run. Table C-1 lists all renderer type/component family
combinations a JSF implementation must include in the HTML renderer
kit. The renderer classes themselves are not defined by the JSF
specification, only
their behavior.
Table C-1. HTML Renderers|
javax.faces.Command
|
javax.faces.Button
|
javax.faces.Command
|
javax.faces.Link
|
javax.faces.Data
|
javax.faces.Table
|
javax.faces.Form
|
javax.faces.Form
|
javax.faces.Graphic
|
javax.faces.Image
|
javax.faces.Input
|
javax.faces.Hidden
|
javax.faces.Input
|
javax.faces.Secret
|
javax.faces.Input
|
javax.faces.Text
|
javax.faces.Input
|
javax.faces.Textare
|
javax.faces.Message
|
javax.faces.Message
|
javax.faces.Messages
|
javax.faces.Messages
|
javax.faces.Output
|
javax.faces.Format
|
javax.faces.Output
|
javax.faces.Label
|
javax.faces.Output
|
javax.faces.Link
|
javax.faces.Output
|
javax.faces.Text
|
javax.faces.Panel
|
javax.faces.Grid
|
javax.faces.Panel
|
javax.faces.Group
|
javax.faces.SelectBoolean
|
javax.faces.Checkbox
|
javax.faces.SelectMany
|
javax.faces.Checkbox
|
javax.faces.SelectMany
|
javax.faces.Listbox
|
javax.faces.SelectMany
|
javax.faces.Menu
|
javax.faces.SelectOne
|
javax.faces.Listbox
|
javax.faces.SelectOne
|
javax.faces.Menu
|
javax.faces.SelectOne
|
javax.faces.Radio
|
The separation of component and renderer classes is what makes JSF so
flexible and useful in many different scenarios, but it also makes it
tedious to manipulate components programmatically. You must be aware
of the distinction between render-independent properties and
render-dependent attributes. The render-independent properties are
represented by JavaBeans-style accessor methods in the component
classes, and render-dependent attributes used by the renderers are
set as generic component attributes, accessed with the get(
) and put() methods on the
java.util.Map returned by the component
getAttributes() method. Because HTML is by far
the most common rendering language, JSF defines classes that combine
the render-independent properties and render-dependent attributes for
all combinations of components and renderers in the HTML render kit,
allowing you to manipulate both groups as regular JavaBeans
properties. Table C-2 lists all these HTML-specific component
classes.
Table C-2. HTML-specific component classes|
javax.faces.component.html.HtmlCommandButton
|
javax.faces.component.html.HtmlCommandLink
|
javax.faces.component.html.HtmlDataTable
|
javax.faces.component.html.HtmlForm
|
javax.faces.component.html.HtmlGraphicImage
|
javax.faces.component.html.HtmlInputHidden
|
javax.faces.component.html.HtmlInputSecret
|
javax.faces.component.html.HtmlInputText
|
javax.faces.component.html.HtmlInputTextarea
|
javax.faces.component.html.HtmlMessage
|
javax.faces.component.html.HtmlMessages
|
javax.faces.component.html.HtmlOutputFormat
|
javax.faces.component.html.HtmlOutputFormat
|
javax.faces.component.html.HtmlOutputLabel
|
javax.faces.component.html.HtmlOutputText
|
javax.faces.component.html.HtmlPanelGrid
|
javax.faces.component.html.HtmlPanelGroup
|
javax.faces.component.html.HtmlSelectBooleanCheckbox
|
javax.faces.component.html.HtmlSelectManyCheckbox
|
javax.faces.component.html.HtmlSelectManyListbox
|
javax.faces.component.html.HtmlSelectManyMenu
|
javax.faces.component.html.HtmlSelectOneListbox
|
javax.faces.component.html.HtmlSelectOneMenu
|
javax.faces.component.html.HtmlSelectRadio
|
|