I have a simple custom-component like this which does not respect the attribute rendered.
@FacesComponent("my.OutputText")
public class OutputText extends UIPanel
{
@Override public void encodeBegin(FacesContext context) throws IOException {...}
@Override public void encodeEnd(FacesContext context) throws IOException {...}
}
Of course, I can check for the attribute rendered in both methods, add @Override public boolean getRendersChildren()
and also check for the rendered attribute and then simple not render the children in encodeChildren
.
But what is the recommended rule for implementing this common feature?
That's already described in javadoc of
UIComponent
class.To take
encodeBegin()
method as an example:And
getRendersChildren()
method:Note the last statement. Here's the one for
UIComponent#encodeChildren()
:Note that
UIComponentBase
has them already implemented. If you have overridden a method, then you'd need to follow exactly the same rules or perhaps make use ofsuper.encodeXxx()
if possible. If you don't haveencodeChildren()
overridden, then you don't need to do so anyway.