Java Reference
In-Depth Information
if (getRendererType() != null) {
super.encodeEnd(context);
return;
}
If there is a renderer available, this method invokes the superclass's
encodeEnd
method,
which does the work of finding the renderer. The
MapComponent
class delegates all ren-
dering to
MapRenderer
, so it does not need to check for available renderers.
In some custom component classes that extend standard components, you might need to
implement other methods in addition to
encodeEnd
. For example, if you need to re-
trieve the component's value from the request parameters, you must also implement the
decode
method.
Performing Decoding
During the Apply Request Values phase, the JavaServer Faces implementation processes
the
decode
methods of all components in the tree. The
decode
method extracts
a component's local value from incoming request parameters and uses a
javax.faces.convert.Converter
implementation to convert the value to a type
that is acceptable to the component class.
A custom component class or its renderer must implement the
decode
method only if
it must retrieve the local value or if it needs to queue events. The component queues the
event by calling
queueEvent
.
Here is the
decode
method of
MapRenderer
:
@Override
public void decode(FacesContext context, UIComponent component) {
if ((context == null) || (component == null)) {
throw new NullPointerException();
}
MapComponent map = (MapComponent) component;
String key = getName(context, map);
String value = (String) context.getExternalContext().
getRequestParameterMap().get(key);
if (value != null)
map.setCurrent(value);
}
}