@Test public final void testEncodeRow() throws IOException { HtmlPage page = environment.getPage("/extendedDataTableTest.jsf"); HtmlElement table = (HtmlElement) page.getElementById("table"); HtmlElement cell = page.getElementById("table:0:f").getElementsByTagName("div").get(0); assertTrue(cell.getAttribute("class").contains("rf-edt-c")); HtmlElement cellContent = cell.getElementsByTagName("div").get(0); assertEquals("rf-edt-c-cnt", cellContent.getAttribute("class")); assertEquals("value", page.getElementById("table:0:outputText").getTextContent()); }
public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder) throws IOException { RendererState state = (RendererState) rowHolder; AbstractExtendedDataTable table = (AbstractExtendedDataTable) state.getRow(); writer.startElement(HtmlConstants.TR_ELEMENT, table); if (rowHolder.getRow() instanceof UIDataTableBase) { renderRowHandlers(facesContext, (UIDataTableBase) rowHolder.getRow()); } String rowClass = getRowClass(rowHolder); StringBuilder builder = new StringBuilder(); Collection<Object> selection = table.getSelection(); if (selection != null && selection.contains(table.getRowKey())) { builder.append("rf-edt-r-sel"); } if (table.getRowKey().equals(table.getAttributes().get("activeRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-act"); } if (table.getRowKey().equals(table.getAttributes().get("shiftRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-sht"); } rowClass = concatClasses(builder.toString(), rowClass); if (rowClass.length() > 0) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null); } Iterator<UIComponent> columns = null; Part part = state.getPart(); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, table.getContainerClientId(facesContext) + ":" + part.getName().getId(), null); columns = part.getColumns().iterator(); int frozenColumns = (state.getPart().name == PartName.normal ? state.frozenColumnsSize : 0); int columnNumber = 0 + frozenColumns; int lastColumnNumber = part.getColumns().size() + frozenColumns - 1; while (columns.hasNext()) { UIComponent column = (UIComponent) columns.next(); if (column.isRendered()) { writer.startElement(HtmlConstants.TD_ELEM, table); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, column.getContainerClientId(facesContext), null); if (column instanceof AbstractColumn) { writer.writeAttribute(DATA_ATTRIBUTE, ((AbstractColumn) column).getName(), null); } String columnClass = ""; if (columnNumber != lastColumnNumber) { columnClass = "rf-edt-td-" + column.getId(); } columnClass = concatClasses( columnClass, getColumnClass(rowHolder, columnNumber), column.getAttributes().get(HtmlConstants.STYLE_CLASS_ATTR)); if (!"".equals(columnClass)) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass, null); } String columnStyle = (String) column.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE); if (!"".equals(columnStyle)) { writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, columnStyle, null); } columnNumber++; writer.startElement(HtmlConstants.DIV_ELEM, table); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c rf-edt-c-" + column.getId(), null); writer.startElement(HtmlConstants.DIV_ELEM, column); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c-cnt", null); renderChildren(facesContext, column); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.TD_ELEM); } } writer.endElement(HtmlConstants.TR_ELEMENT); }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder) throws IOException { RendererState state = (RendererState) rowHolder; AbstractExtendedDataTable table = (AbstractExtendedDataTable) state.getRow(); writer.startElement(HtmlConstants.TR_ELEMENT, table); if (rowHolder.getRow() instanceof UIDataTableBase) { renderRowHandlers(facesContext, (UIDataTableBase) rowHolder.getRow()); } String rowClass = getRowClass(rowHolder); StringBuilder builder = new StringBuilder(); Collection<Object> selection = table.getSelection(); if (selection != null && selection.contains(table.getRowKey())) { builder.append("rf-edt-r-sel"); } if (table.getRowKey().equals(table.getAttributes().get("activeRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-act"); } if (table.getRowKey().equals(table.getAttributes().get("shiftRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-sht"); } rowClass = concatClasses(builder.toString(), rowClass); if (rowClass.length() > 0) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null); } Iterator<UIComponent> columns = null; Part part = state.getPart(); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, table.getContainerClientId(facesContext) + ":" + part.getName().getId(), null); columns = part.getColumns().iterator(); int frozenColumns = (state.getPart().name == PartName.normal ? state.frozenColumnsSize : 0); int columnNumber = 0 + frozenColumns; int lastColumnNumber = part.getColumns().size() + frozenColumns - 1; while (columns.hasNext()) { UIComponent column = (UIComponent) columns.next(); if (column.isRendered()) { writer.startElement(HtmlConstants.TD_ELEM, table); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, column.getContainerClientId(facesContext), null); if (column instanceof AbstractColumn) { writer.writeAttribute(DATA_ATTRIBUTE, ((AbstractColumn) column).getName(), null); } String columnClass = ""; if (columnNumber != lastColumnNumber) { columnClass = "rf-edt-td-" + column.getId(); } columnClass = concatClasses( columnClass, getColumnClass(rowHolder, columnNumber), column.getAttributes().get(HtmlConstants.STYLE_CLASS_ATTR)); if (!"".equals(columnClass)) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass, null); } String columnStyle = (String) column.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE); if (!"".equals(columnStyle)) { writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, columnStyle, null); } columnNumber++; writer.startElement(HtmlConstants.DIV_ELEM, table); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c rf-edt-c-" + column.getId(), null); writer.startElement(HtmlConstants.DIV_ELEM, column); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c-cnt", null); renderChildren(facesContext, column); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.TD_ELEM); } } writer.endElement(HtmlConstants.TR_ELEMENT); } }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder) throws IOException { RendererState state = (RendererState) rowHolder; AbstractExtendedDataTable table = (AbstractExtendedDataTable) state.getRow(); writer.startElement(HtmlConstants.TR_ELEMENT, table); if (rowHolder.getRow() instanceof UIDataTableBase) { renderRowHandlers(facesContext, (UIDataTableBase) rowHolder.getRow()); } String rowClass = getRowClass(rowHolder); StringBuilder builder = new StringBuilder(); Collection<Object> selection = table.getSelection(); if (selection != null && selection.contains(table.getRowKey())) { builder.append("rf-edt-r-sel"); } if (table.getRowKey().equals(table.getAttributes().get("activeRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-act"); } if (table.getRowKey().equals(table.getAttributes().get("shiftRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-sht"); } rowClass = concatClasses(builder.toString(), rowClass); if (rowClass.length() > 0) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null); } Iterator<UIComponent> columns = null; Part part = state.getPart(); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, table.getContainerClientId(facesContext) + ":" + part.getName().getId(), null); columns = part.getColumns().iterator(); int frozenColumns = (state.getPart().name == PartName.normal ? state.frozenColumnsSize : 0); int columnNumber = 0 + frozenColumns; int lastColumnNumber = part.getColumns().size() + frozenColumns - 1; while (columns.hasNext()) { UIComponent column = (UIComponent) columns.next(); if (column.isRendered()) { writer.startElement(HtmlConstants.TD_ELEM, table); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, column.getContainerClientId(facesContext), null); if (column instanceof AbstractColumn) { writer.writeAttribute(DATA_ATTRIBUTE, ((AbstractColumn) column).getName(), null); } String columnClass = ""; if (columnNumber != lastColumnNumber) { columnClass = "rf-edt-td-" + column.getId(); } columnClass = concatClasses( columnClass, getColumnClass(rowHolder, columnNumber), column.getAttributes().get(HtmlConstants.STYLE_CLASS_ATTR)); if (!"".equals(columnClass)) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass, null); } String columnStyle = (String) column.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE); if (!"".equals(columnStyle)) { writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, columnStyle, null); } columnNumber++; writer.startElement(HtmlConstants.DIV_ELEM, table); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c rf-edt-c-" + column.getId(), null); writer.startElement(HtmlConstants.DIV_ELEM, column); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c-cnt", null); renderChildren(facesContext, column); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.TD_ELEM); } } writer.endElement(HtmlConstants.TR_ELEMENT); }  }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder) throws IOException { RendererState state = (RendererState) rowHolder; AbstractExtendedDataTable table = (AbstractExtendedDataTable) state.getRow(); writer.startElement(HtmlConstants.TR_ELEMENT, table); if (rowHolder.getRow() instanceof UIDataTableBase) { renderRowHandlers(facesContext, (UIDataTableBase) rowHolder.getRow()); } String rowClass = getRowClass(rowHolder); StringBuilder builder = new StringBuilder(); Collection<Object> selection = table.getSelection(); if (selection != null && selection.contains(table.getRowKey())) { builder.append("rf-edt-r-sel"); } if (table.getRowKey().equals(table.getAttributes().get("activeRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-act"); } if (table.getRowKey().equals(table.getAttributes().get("shiftRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-sht"); } rowClass = concatClasses(builder.toString(), rowClass); if (rowClass.length() > 0) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null); } Iterator<UIComponent> columns = null; Part part = state.getPart(); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, table.getContainerClientId(facesContext) + ":" + part.getName().getId(), null); columns = part.getColumns().iterator(); int frozenColumns = (state.getPart().name == PartName.normal ? state.frozenColumnsSize : 0); int columnNumber = 0 + frozenColumns; int lastColumnNumber = part.getColumns().size() + frozenColumns - 1; while (columns.hasNext()) { UIComponent column = (UIComponent) columns.next(); if (column.isRendered()) { writer.startElement(HtmlConstants.TD_ELEM, table); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, column.getContainerClientId(facesContext), null); if (column instanceof AbstractColumn) { writer.writeAttribute(DATA_ATTRIBUTE, ((AbstractColumn) column).getName(), null); } String columnClass = ""; if (columnNumber != lastColumnNumber) { columnClass = "rf-edt-td-" + column.getId(); } columnClass = concatClasses( columnClass, getColumnClass(rowHolder, columnNumber), column.getAttributes().get(HtmlConstants.STYLE_CLASS_ATTR)); if (!"".equals(columnClass)) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass, null); } String columnStyle = (String) column.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE); if (!"".equals(columnStyle)) { writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, columnStyle, null); } columnNumber++; writer.startElement(HtmlConstants.DIV_ELEM, table); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c rf-edt-c-" + column.getId(), null); writer.startElement(HtmlConstants.DIV_ELEM, column); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c-cnt", null); renderChildren(facesContext, column); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.TD_ELEM); } } writer.endElement(HtmlConstants.TR_ELEMENT); }  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); }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder) throws IOException { RendererState state = (RendererState) rowHolder; AbstractExtendedDataTable table = (AbstractExtendedDataTable) state.getRow(); writer.startElement(HtmlConstants.TR_ELEMENT, table); if (rowHolder.getRow() instanceof UIDataTableBase) { renderRowHandlers(facesContext, (UIDataTableBase) rowHolder.getRow()); } String rowClass = getRowClass(rowHolder); StringBuilder builder = new StringBuilder(); Collection<Object> selection = table.getSelection(); if (selection != null && selection.contains(table.getRowKey())) { builder.append("rf-edt-r-sel"); } if (table.getRowKey().equals(table.getAttributes().get("activeRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-act"); } if (table.getRowKey().equals(table.getAttributes().get("shiftRowKey"))) { if (builder.length() > 0) { builder.append(' '); } builder.append("rf-edt-r-sht"); } rowClass = concatClasses(builder.toString(), rowClass); if (rowClass.length() > 0) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, rowClass, null); } Iterator<UIComponent> columns = null; Part part = state.getPart(); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, table.getContainerClientId(facesContext) + ":" + part.getName().getId(), null); columns = part.getColumns().iterator(); int frozenColumns = (state.getPart().name == PartName.normal ? state.frozenColumnsSize : 0); int columnNumber = 0 + frozenColumns; int lastColumnNumber = part.getColumns().size() + frozenColumns - 1; while (columns.hasNext()) { UIComponent column = (UIComponent) columns.next(); if (column.isRendered()) { writer.startElement(HtmlConstants.TD_ELEM, table); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, column.getContainerClientId(facesContext), null); if (column instanceof AbstractColumn) { writer.writeAttribute(DATA_ATTRIBUTE, ((AbstractColumn) column).getName(), null); } String columnClass = ""; if (columnNumber != lastColumnNumber) { columnClass = "rf-edt-td-" + column.getId(); } columnClass = concatClasses( columnClass, getColumnClass(rowHolder, columnNumber), column.getAttributes().get(HtmlConstants.STYLE_CLASS_ATTR)); if (!"".equals(columnClass)) { writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, columnClass, null); } String columnStyle = (String) column.getAttributes().get(HtmlConstants.STYLE_ATTRIBUTE); if (!"".equals(columnStyle)) { writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, columnStyle, null); } columnNumber++; writer.startElement(HtmlConstants.DIV_ELEM, table); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c rf-edt-c-" + column.getId(), null); writer.startElement(HtmlConstants.DIV_ELEM, column); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-edt-c-cnt", null); renderChildren(facesContext, column); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.DIV_ELEM); writer.endElement(HtmlConstants.TD_ELEM); } } writer.endElement(HtmlConstants.TR_ELEMENT); }  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);  }