[jsr-314-open-mirror] [jsr-314-open] Use a Renderer on a composite component

Leonardo Uribe lu4242 at gmail.com
Sun Mar 28 22:21:10 EDT 2010


Hi

The javadoc of Application.createComponent(FacesContext context, Resource
componentResource) says this:

".....Call UIComponent.setRendererType(java.lang.String)<file:///D:/jdk-1_5_0-doc/jsf20/mojarra-2.0.3-SNAPSHOT/docs/javadocs/javax/faces/component/UIComponent.html#setRendererType%28java.lang.String%29>on
the
UIComponent instance, passing "javax.faces.Composite" as the
argument........"

Now suppose a custom composite component extending from UIInput, but
implementing NamingContainer/UniqueIdVendor. The component family in this
case is "javax.faces.Input". The result is the component will not work
because the renderer used for composite components assumes the family
"javax.faces.NamingContainer". This is ok, because the user just need to
register a custom renderer for its composite component under that
family/rendererType like the spec says.

The problem is why it is mandatory to set "javax.faces.Composite" as
renderer type. The javadoc should say:

"...If the renderer type is not set (return null), Call
UIComponent.setRendererType(java.lang.String)<file:///D:/jdk-1_5_0-doc/jsf20/mojarra-2.0.3-SNAPSHOT/docs/javadocs/javax/faces/component/UIComponent.html#setRendererType%28java.lang.String%29>on
the
UIComponent instance, passing "javax.faces.Composite" as the argument...".
In that case, a user can override the rendererType on the constructor and
avoid this hack that works with the current spec:

    public void setRendererType(String rendererType)
    {
        //Ignore this call !
        if (!"javax.faces.Composite".equals(rendererType))
        {
            super.setRendererType(rendererType);
        }
    }

Why override the default Renderer and use a custom one? Let's suppose the
component proposed needs some custom code for converter, or for decode. The
right place to put that kind of code is the Renderer class, not the
component, but note it is possible to put that on the component class.

Does that sounds reasonable? should I create an issue for this one?

regards,

Leonardo Uribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20100328/96b992d9/attachment-0002.html 


More information about the jsr-314-open-mirror mailing list