public class GroupingBoxRenderer extends RendererBase {
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component);
final ResponseWriter writer = context.getResponseWriter();
final GroupingBox groupingBox = (GroupingBox) component;
final UIComponent parent = groupingBox.getParent();
if (!(parent instanceof DataTable))
throw new IllegalStateException("<o:groupingBox> can only be placed as a child component inside of " +
"a <o:dataTable> component. Though the following parent component has been encountered: " +
parent.getClass().getName());
final DataTable table = (DataTable) groupingBox.getParent();
final String boxClassName = Styles.getCSSClass(context, component, groupingBox.getStyle(), "o_groupingBox", groupingBox.getStyleClass());
final String headerClassName = Styles.getCSSClass(context, component, groupingBox.getHeaderStyle(), "o_groupingBox_header", groupingBox.getHeaderClass());
final String promptClassName = Styles.getCSSClass(context, component, groupingBox.getPromptTextStyle(), "o_groupingBox_promptText", groupingBox.getPromptTextClass());
final String connectorStyle = groupingBox.getConnectorStyle();
writer.startElement("table", component);
writeStandardEvents(writer, groupingBox);
writer.writeAttribute("class", boxClassName, null);
writeIdAttribute(context, component);
writer.writeAttribute("cellspacing", "0", null);
writer.writeAttribute("cellpadding", "0", null);
writer.writeAttribute("border", "0", null);
writer.startElement("tr", component);
writer.startElement("td", component);
writer.writeAttribute("style", "position: relative", null);
writer.startElement("span", component);
writer.writeAttribute("class", promptClassName, null);
writer.append(groupingBox.getPromptText());
writer.endElement("span");
writer.endElement("td");
writer.endElement("tr");
writer.endElement("table");
Rendering.renderInitScript(context, new ScriptBuilder()
.initScript(context, component, "O$.Table._initRowGroupingBox",
table,
connectorStyle, headerClassName,
groupingBox.getHeaderHorizOffset(), groupingBox.getHeaderVertOffset())
.semicolon());
Styles.renderStyleClasses(context, component);
}