Rafael Nami wrote:
2 - Why the hell isn't any writer, or encode, or even decode code in
faces components (I've searched for this kind of code in the components,
but in the four that I've searched, there were no code like this)???
JSF supports separating the "rendering" of a component into a separate
class from the component itself.
In a component constructor the component typically calls
this.setRendererType(stringContainingRendererName)
which defines the default renderer "name" for the component.
A JSP tag can override this by calling setRendererType on the component
it creates.
When the JSF framework wants to render the object it calls
component.getRendererType. If a non-null value is returned it then looks
up in its config files to map the renderer name to an actual renderer
class-name, instantiates the renderer class, and invokes renderer
methods encodeBegin/encodeChildren/encodeEnd etc on the renderer object
rather than on the component. This separates out the rendering from the
component logic and also allows different renderers (HTML/XHTML/WAP/etc)
to be attached to the same component.
If the JSF component calls component.getRendererType and gets null
returned then the encodeBegin/encodeChildren/encodeEnd get called on the
component itself. This can be useful when writing a custom component for
a specific project where only one renderer will ever be used with it, as
it's simpler to manage everything in one class and no
renderertype->renderer-class mapping needs to be defined in the
faces-config.xml file.
Note: I'm fairly new to JSF so some details may not be 100% correct!
Regards,
Simon