myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Lessard <simon.lessar...@gmail.com>
Subject Re: [TRINIDAD][API] JIRA-1465 Allow public access to the UIXComponent renderer, if any
Date Thu, 30 Apr 2009 17:55:53 GMT
Hi,

I won't -1 it, most likely +0, but I'm curious, why can't
RenderKit.getRenderer be used for that case use case? The only case it does
not cover would be a component not getting its Renderer the standard way,
but to my knowledge all UIXComponent do so I'm not sure.


Regards,

~ Simon

On Thu, Apr 30, 2009 at 1:47 PM, Blake Sullivan
<blake.sullivan@oracle.com>wrote:

> The proposal is to allow public access to the UIXComponent's Renderer, if
> any.
>
> UIComponent only allows protected access to the Renderer, which is normally
> considered an implementation detail of the component. However, because of
> the Component/Renderer split, information is often only available on the
> Renderer and only applicable when that Renderer is present.
>
> /**
>  * Returns the Renderer of this component cast to the specified Renderer
> type or
>  * <code>null</code> if the component's Renderer isn't of the specified
> type.
>  * @param context FacesContext
>  * @param type The Renderer class to return the Renderer as
>  * @return the Renderer of this component cast to the specified Renderer
> type
>  */
> public final <S extends Renderer> S getRendererAs(FacesContext context,
> Class<S> type)
> {
>  Renderer renderer = getRenderer(context);
>
>  if (type.isInstance(renderer))
>  {
>    return type.cast(renderer);
>  }
>  else
>  {
>    return null;
>  }
> }
>
> A concrete example of how this api is used is code to handle embedding
> style definitions in an HTML document so that the HTML document can be
> e-mailed and viewed in e-mail readers that don't support external style
> sheets. This is implemented by having the DocumentRenderer walk the
> component tree, asking each component for its Renderer and then asking the
> Renderer what selector it renders when rendering content.
>
> Alternatives would be:
> 1) Exposing a Selector getComponentSelector() on UIXComponent and a similar
> method on CoreRenderer
>
> 2) Creating subclasses of every single UIXComponent class and exposing an
> interface with the method to do the same thing. However this would mean that
> we wouldn't be able to handle the case where a UIXComponent class was used
> with one of our Renderers directly and would also needlessly deepen the
> component hierarchy
>
> -- Blake Sullivan
>
>

Mime
View raw message