Java Reference
In-Depth Information
Whether or not you implement these methods in a component class, you can use the
javax.faces.STATE_SAVING_METHOD
context parameter to specify in the deploy-
ment descriptor where you want the state to be saved: either
client
or
server
. If state
is saved on the client, the state of the entire view is rendered to a hidden field on the page.
By default, the state is saved on the server.
The web applications in the Duke's Forest case study save their view state on the client.
Saving state on the client uses more bandwidth as well as more client resources, while
saving it on the server uses more server resources. You may also want to save state on the
client if you expect your users to disable cookies.
Delegating Rendering to a Renderer
Both
MapComponent
and
AreaComponent
delegate all of their rendering to a sep-
arate renderer. The section “
Performing Encoding
”
on page
109
explains how
MapRen-
derer
performs the encoding for
MapComponent
. This section explains in detail the
process of delegating rendering to a renderer using
AreaRenderer
, which performs the
rendering for
AreaComponent
.
To delegate rendering, you perform these tasks:
• Create the
Renderer
class.
• Register the renderer with a render kit by using the
@FacesRenderer
annota-
gistering a Custom Renderer with a Render Kit
”
on page
165
)
.
• Identify the renderer type in the
@FacesRenderer
annotation.
Creating the Renderer Class
When delegating rendering to a renderer, you can delegate all encoding and decoding to
the renderer, or you can choose to do part of it in the component class. The
AreaCom-
ponent
class delegates encoding to the
AreaRenderer
class.
The renderer class begins with a
@FacesRenderer
annotation:
@FacesRenderer(componentFamily = "Area",
rendererType = "dukesbookstore.renderers.AreaRenderer")
public class AreaRenderer extends Renderer {