I'm having problems with a custom component I'm writing in that it won't render any nested controls. The component is a simple layout control, very loosely adapted from the ApplicationLayout control in the Extension Library. The XPage code looks like this:
<px:exampleControl id="exampleControl1">
<xp:span styleClass="mySpan">Inner Text</xp:span>
</px:exampleControl>
The exampleControl will render fine but the nested span won't. My basic renderer code is:
public class ExampleRenderer extends Renderer {
@Override
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.startElement("div", component);
writer.writeAttribute("class", "custom-banner", null);
writer.endElement("div");
writer.startElement("div", component);
writer.writeAttribute("class", "main-body", null);
}
@Override
public boolean getRendersChildren() {
return true;
}
@Override
public void encodeChildren(FacesContext context, UIComponent component) {
try {
super.encodeChildren(context, component);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void encodeEnd(FacesContext context, UIComponent component)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.endElement("div");
writer.startElement("div", component);
writer.writeAttribute("class", "custom-footer", null);
writer.endElement("div");
}
}
I've even attempted to use a specific render function borrowed from the Extension Library renderers (the utility functions in AbstractApplicationLayoutRenderer.java) but component.getChildCount() always returns 0.
So why aren't the nested controls rendering and what am I missing?