On 6/6/12 11:24 PM, Phil Webb wrote:
> I do like the idea of not needing to revisit renderers to support passthough attributes, and it maps well with the information Ed sent earlier [1]. Having said that, there might be some complexities with existing code. For example, looking at PrimeFaces, in org.primefaces.component.inputtext.InputTextRenderer I noticed that no component is passed to startElement.
Oh, interesting. Yep, so it seems that this strategy may require a
small amount of work on the part of components/renderers that do not
currently specify a UIComponent when calling startElement() for their
root elements. Seems like a reasonable requirement.
> With Mojarra, the com.sun.faces.renderkit.html_basic.MenuRenderer calls startElement several times with the same component (once for "select" and again for "option" and "optiongroup"). Not much can be done if the component is not passed, but the menu case is particularly interesting because I would expect passthough attributes and overrides to apply to "select" but not "option" or "optiongroup".
>
> I guess the writer might need to keep a stack of the components (push on startElement, pop on endElement) and only apply overrides if the component does not appear higher in the stack.
Yep, something along these lines. The underlying goal would be for pass
through elements to be written on only the root element of the
containing component. Shouldn't be all that tricky for the
ResponseWriter to manage this.
Though this does raise an interesting question about what the correct
component/renderer behavior is. Should components that render multiple
HTML elements pass themselves into ResponseWriter.startElement() for
each element, or just for the root element? Would be nice if the spec
was clearer about the expectations here.
Andy
> I am sure this can be solved, but it will definitely need some thought.
>
> [1] https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20120606.080027-1-javadoc.jar/!/renderkitdocs/index.html