ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { writer.startElement(HtmlConstants.TABLE_ELEMENT, component); String clientId = component.getClientId(context); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId + ":r", null); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-rord rf-edt-tbl", null); writer.startElement(HtmlConstants.TR_ELEMENT, component); writer.startElement(HtmlConstants.TH_ELEM, component); writer.write("&#160;"); writer.endElement(HtmlConstants.TH_ELEM); writer.endElement(HtmlConstants.TR_ELEMENT); for (int i = 0; i < 6; i++) { writer.startElement(HtmlConstants.TR_ELEMENT, component); writer.startElement(HtmlConstants.TD_ELEM, component); writer.write("&#160;"); writer.endElement(HtmlConstants.TD_ELEM); writer.endElement(HtmlConstants.TR_ELEMENT); } writer.endElement(HtmlConstants.TABLE_ELEMENT); writer.startElement(HtmlConstants.DIV_ELEM, component); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId + ":d", null); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-rsz-mkr", null); writer.endElement(HtmlConstants.DIV_ELEM); writer.startElement(HtmlConstants.DIV_ELEM, component); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId + ":rm", null); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-rord-mkr", null); writer.endElement(HtmlConstants.DIV_ELEM); writer.startElement(HtmlConstants.INPUT_ELEM, component); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId + ":wi", null); writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, clientId + ":wi", null); writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN, null); writer.endElement(HtmlConstants.INPUT_ELEM); encodeSelectionInput(writer, context, component); AjaxFunction ajaxFunction = buildAjaxFunction(context, component); ajaxFunction.getOptions().setClientParameters(CLIENT_PARAMS); Map<String, Object> attributes = component.getAttributes(); Map<String, Object> options = new HashMap<String, Object>(); addToScriptHash(options, "selectionMode", attributes.get("selectionMode"), SelectionMode.multiple); addToScriptHash(options, "onbeforeselectionchange", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onbeforeselectionchange")), null, ScriptHashVariableWrapper.eventHandler); addToScriptHash(options, "onselectionchange", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onselectionchange")), null, ScriptHashVariableWrapper.eventHandler); addToScriptHash(options, "onready", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onready")), null, ScriptHashVariableWrapper.eventHandler); StringBuilder builder = new StringBuilder("new RichFaces.ui.ExtendedDataTable('"); builder.append(clientId).append("', ").append(getRowCount(component)).append(", function(event, clientParams) {") .append(ajaxFunction.toScript()).append(";}"); if (!options.isEmpty()) { builder.append(",").append(ScriptUtils.toScript(options)); } builder.append(");"); getUtils().writeScript(context, component, builder.toString()); writer.endElement(HtmlConstants.DIV_ELEM); }  void encodeHeader(RendererState state); void encodeBody(RendererState state); void encodeFooter(RendererState state); void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); RendererState createRowHolder(FacesContext context, UIComponent component, Object[] options); void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder); void consumeTableState(FacesContext facesContext, UIDataTableBase table, ExtendedDataTableState tableState);  }
@Test public final void testDoEncodeEnd() throws IOException { HtmlPage page = environment.getPage("/extendedDataTableTest.jsf"); HtmlElement table = page.getElementById("table"); assertEquals("footerFacet", table.getElementById("table:footerFacet").getTextContent()); assertEquals("rf-edt-rsz-mkr", table.getElementById("table:d").getAttribute("class")); assertEquals("rf-edt-rord rf-edt-tbl", table.getElementById("table:r").getAttribute("class")); assertEquals("rf-edt-rord-mkr", table.getElementById("table:rm").getAttribute("class")); assertEquals("table:wi", table.getElementById("table:wi").getAttribute("name")); assertTrue(table.getElementsByTagName("script").get(0).getTextContent().contains("RichFaces.ui.ExtendedDataTable")); }