@Override
public void encodeBegin(FacesContext context) throws IOException
{
if (this.getChildCount() > 0) {
if (this.getChildren().get(0) instanceof UIDocument) {
UIDocument document = (UIDocument) this.getChildren().get(0);
document.setSendRedirect(false);
JSF.renderChildren(context, this);
} else {
setValue(encode(context).getBytes());
if (getContentType() == null) {
// User hasn't specified content, assume html