<br><br><div class="gmail_quote">2010/3/29 Ed Burns <span dir="ltr"><<a href="mailto:edward.burns@oracle.com">edward.burns@oracle.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
>>>>> On Sun, 28 Mar 2010 21:21:10 -0500, Leonardo Uribe <<a href="mailto:lu4242@gmail.com">lu4242@gmail.com</a>> said:<br>
<br>
LU> The problem is why it is mandatory to set "javax.faces.Composite" as<br>
LU> renderer type. The javadoc should say:<br>
<br>
LU> "...If the renderer type is not set (return null), Call<br>
LU> 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<br>
LU> the<br>
LU> UIComponent instance, passing "javax.faces.Composite" as the argument...".<br>
LU> In that case, a user can override the rendererType on the constructor and<br>
LU> 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> Why override the default Renderer and use a custom one? Let's<br>
LU> suppose the component proposed needs some custom code for converter,<br>
LU> or for decode. The right place to put that kind of code is the<br>
LU> Renderer class, not the component, but note it is possible to put<br>
LU> 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'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 <span> instead use <a>.<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'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><composite:implementation><br><f:facet name="normal"><br>......some html markup......<br></f:facet><br><f:facet name="disabled"><br>
......some html markup......<br>
</f:facet><br><f:facet name="special"><br>
......some html markup......<br>
</f:facet><br><composite:implementation><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>