JSF 1.2 startElement and writeAttribute explanation

I had to write some own renderers for my project and work perfectly. However, I am somewhat confused by some parameters in the ResponseWriter methods. The documentation does not explain this very well, so I hope one of the JSF resident experts can explain it better. In particular:

public abstract void startElement(java.lang.String name, javax.faces.component.UIComponent component) throws java.io.IOException Parameters: name - Name of the element to be started component - The UIComponent (if any) to which this element corresponds 

What does this second parameter do? Does it seem to work fine for me to skip "null" or "this" in my renderer?

Similarly for writeAttribute:

 public abstract void writeAttribute(java.lang.String name, java.lang.Object value, java.lang.String property) throws java.io.IOException Parameters: name - Attribute name to be added value - Attribute value to be added property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds 

Why should ResponseWriter know the backing property? Again, this seems like normal if I pass null or "styleClass" when writing a class attribute.

Curious minds want to know, and my google-fu fails on this ...

+4
source share
1 answer

The standard Mojarra implementation does nothing with them. The component argument of startElement() and the property writeAttribute() ignored.

However, a custom responder can be provided. For some real-world implementations, it would be absolutely necessary to know about the original UIComponent and / or the related UIComponent property within the author of the answer.

Although JSF 2.0 is targeted, the Html5ResponseWriter OmniFaces will be a good example. startElement() defines the UIComponent type with a few instanceof checks before allowing / writing some specific HTML5 attributes.

+2
source

All Articles