<br><br><div class="gmail_quote">2010/3/29 Ed Burns <span dir="ltr">&lt;<a href="mailto:edward.burns@oracle.com">edward.burns@oracle.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
&gt;&gt;&gt;&gt;&gt; On Sun, 28 Mar 2010 21:21:10 -0500, Leonardo Uribe &lt;<a href="mailto:lu4242@gmail.com">lu4242@gmail.com</a>&gt; said:<br>
<br>
LU&gt; The problem is why it is mandatory to set &quot;javax.faces.Composite&quot; as<br>
LU&gt; renderer type. The javadoc should say:<br>
<br>
LU&gt; &quot;...If the renderer type is not set (return null), Call<br>
LU&gt; UIComponent.setRendererType(java.lang.String)&lt;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&gt;on<br>
LU&gt; the<br>
LU&gt; UIComponent instance, passing &quot;javax.faces.Composite&quot; as the argument...&quot;.<br>
LU&gt; In that case, a user can override the rendererType on the constructor and<br>
LU&gt; avoid this hack that works with the current spec:<br>
<br>
I understand the problem you have uncovered.  Take a look at the<br>
renderkit docs for javax.faces.NamingContainer/javax.faces.Composite.<br>
There are specific requirements in there that depend on the composite<br>
component metadata specification.<br>
<br>
I thought it would be toooooooo subtle to allow the Renderer to be<br>
customized beause this contract must also be followed in the custom<br>
renderer case.<br>
<br>
LU&gt; Why override the default Renderer and use a custom one? Let&#39;s<br>
LU&gt; suppose the component proposed needs some custom code for converter,<br>
LU&gt; or for decode. The right place to put that kind of code is the<br>
LU&gt; Renderer class, not the component, but note it is possible to put<br>
LU&gt; that on the component class.<br>
<br>
Yes I understand that the Renderer is the right place for such things<br>
but the chosen programming model for customization of composite<br>
components is to override the top level component.  Simple.  If we&#39;re<br>
going to change that I need a more compelling reason than correctness.<br>
<br></blockquote><div><br>The current behavior of javax.faces.NamingContainer/javax.faces.Composite renderer says that everything<br>inside the facet UIComponent.COMPOSITE_FACET_NAME should be rendered. But sometimes<br>
the markup of the component changes according to its inner state. One simple example is<br>h:commandLink. If this component is disabled, it should be rendered a &lt;span&gt; instead use &lt;a&gt;.<br>Other example is tomahawk displayValueOnly property, that when is set to true, only the value<br>
needs to be rendered.<br><br>Ok, if I have a composite component the first thought is use c:if tag, but remember that with<br>partial state saving enabled this tag is evaluated when the view is build, not when it is<br>rendered. Other alternative is use a component that allows to render one child at the time, and<br>
it is on myfaces commons (mc:renderOne, old sandbox s:limitRendered). The third alternative is<br>use a custom renderer. The example I&#39;m trying to do is this (all non relevant code has been removed:<br><br>    public void encodeEnd(FacesContext context, UIComponent component)<br>
            throws IOException<br>    {<br>        UIComponent compositeFacet = (UIComponent) component<br>                .getFacet(UIComponent.COMPOSITE_FACET_NAME);<br>        CompositeInputHtml editor = (CompositeInputHtml) component;        <br>
        if( HtmlRendererUtils.isDisplayValueOnly(editor) )<br>        {<br>            encodeDisplayValueOnly(context, editor);<br>        }<br>        else if ( useFallback(editor) )<br>        {<br>            encodeEndFallBackMode(context, editor);<br>
        }<br>        else<br>        {<br>            if( ! isVisible(editor) ){<br>                encodeHidden(context, editor);<br>            }<br>            else if( ! hasAnotherPropertyThatPreventsRenderThisOneCorrectly( context ) )<br>
            {<br>                compositeFacet.encodeAll(context);<br>            }<br>            else<br>            {<br>                encodeEndFallBackMode(context, editor);<br>            }<br>        }<br>    }<br>
<br>It is possible to think in other cases, like a composite component like this:<br><br>&lt;composite:implementation&gt;<br>&lt;f:facet name=&quot;normal&quot;&gt;<br>......some html markup......<br>&lt;/f:facet&gt;<br>&lt;f:facet name=&quot;disabled&quot;&gt;<br>

......some html markup......<br>
&lt;/f:facet&gt;<br>&lt;f:facet name=&quot;special&quot;&gt;<br>
......some html markup......<br>
&lt;/f:facet&gt;<br>&lt;composite:implementation&gt;<br><br>And use a custom renderer to control when one or other facet should be rendered.<br><br>Note that in fact, with the hack on the component class on setRendererType, it is possible<br>
to override the Renderer without problem, so for my particular problem I can live with it.<br>The question is if the spec should enforce the use of<br>javax.faces.NamingContainer/javax.faces.Composite renderer for composite components <br>
or not.<br><br>Leonardo<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Ed<br>
<font color="#888888"><br>
--<br>
| <a href="mailto:edward.burns@oracle.com">edward.burns@oracle.com</a>  | office: 408 884 9519 OR x31640<br>
| homepage:                | <a href="http://ridingthecrest.com/" target="_blank">http://ridingthecrest.com/</a><br>
</font></blockquote></div><br>