aspose file tools*
The moose likes Struts and the fly likes JSF: component-family, component type and renderer relation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF: component-family, component type and renderer relation." Watch "JSF: component-family, component type and renderer relation." New topic
Author

JSF: component-family, component type and renderer relation.

Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
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
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
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


Hans Bergsten, hans@gefionsoftware.com<br />Author of O'Reilly's<br />- JavaServer Pages,<br />- JavaServer Faces<br /><a href="http://www.hansbergsten.com/" target="_blank" rel="nofollow">http://www.hansbergsten.com/</a>
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Once again Hans thanks for your explanation.
Couldn't get hold of a book today - should be getting it tomorrow.
Can you let me know in which chapter you talk about component-family and rendererType, render specific attributes in detail, so that i look directly in it.

Thanks,
Vijay V
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by Vijay Venkat:
Once again Hans thanks for your explanation.
Couldn't get hold of a book today - should be getting it tomorrow.
Can you let me know in which chapter you talk about component-family and rendererType, render specific attributes in detail, so that i look directly in it.

Thanks,
Vijay V


I sure can; it's in Chapter 13, Developing Custom Renderers and Other Pluggable Classes.
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Hans thanks a lot. Hmm.. couldn't find a Indian edition of your book :-(. Is there any plans for Indian edition of your book?
Vijay V
Hans Bergsten
Author
Ranch Hand

Joined: Dec 01, 2003
Posts: 106
Originally posted by Vijay Venkat:
Hans thanks a lot. Hmm.. couldn't find a Indian edition of your book :-(. Is there any plans for Indian edition of your book?
Vijay V


I don't know. Translations are out of my control, but typically, a popular O'Reilly book is eventually translated to all languages there is demand for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF: component-family, component type and renderer relation.