Originally posted by Vijay Venkat:
Hi
I am able to understand the concept of a render kit - which is something similar to different look feel in swing.
It is clear that a Component has a renderer associated with it for it to be rendered.
Why do we associate a renderer type with a component family?
Is it that many components can share the same renderer?
<renderer>
<component-family>javax.faces.Input</component-family>
<renderer-type>com.company.sometype</renderer-type>
<renderer-class>com.company.SomeRenderer</renderer-class>
</renderer>
Does it imply that there can be components whose renderer types are not set and in these cases we can get the renderer based on the component-family?
but why is the component-family specified with in the renderer and not in the component itself?
I am seriously missing the concept which connects the components, family and renderers
Any pointers to this would be very useful.
Thanks,
Vijay V
This is tricky, and I explain it in much more detail in my book, but basically, this is how it works.
There may be many different render kits with renderers of the same type, say one with renderers for HTML and one for WML. Components are associates with renderer types (symbolic names for the renderers), so that by switching the render kit for a view, all components will use the same type of renderer from the new kit without having to reassign new renderers for the components.
Each components belongs to a component family, for instance "javax.faces.Command", and each renderer supports components that belong to the same family. This makes it possible to use the same renderer for all component classes with the same basic behavior, e.g., that of a "command". A concrete example, say you want to subclass the UICommand component to add additional behavior. By declaring that your subclass belongs to the "javax.faces.Command" family, you can automatically use the standard Link and Button renderers supporting this component family.
Hope this helps some. If not, you may want to ask for clarifications in Sun's
JSF forum:
http://forum.java.sun.com/forum.jsp?forum=427