writer.startElement(HtmlElements.TR, null);
if (rowRendered instanceof Boolean) {
// if rowRendered attribute is set we need the rowIndex on the client
writer.writeAttribute(DataAttributes.ROW_INDEX, rowIndex);
}
Markup rowMarkup = odd ? Markup.ODD : Markup.EVEN;
final boolean selected = selectedRows.contains(rowIndex);
if (selected) {
rowMarkup = rowMarkup.add(Markup.SELECTED);
}
final String[] rowMarkups = (String[]) sheet.getAttributes().get("rowMarkup");
if (rowMarkups != null) {
rowMarkup = rowMarkup.add(Markup.valueOf(rowMarkups));
}
writer.writeClassAttribute(Classes.create(sheet, "row", rowMarkup));
if (!sheet.isRowVisible()) {
final Style rowStyle = new Style();
rowStyle.setDisplay(Display.NONE);
writer.writeStyleAttribute(rowStyle);
}
final String parentId = sheet.getRowParentClientId();
if (parentId != null) {
writer.writeAttribute(DataAttributes.TREE_PARENT, parentId, false);
}
int columnIndex = -1;
for (final UIColumn column : renderedColumnList) {
columnIndex++;
writer.startElement(HtmlElements.TD, column);
Markup markup = column instanceof SupportsMarkup ? ((SupportsMarkup) column).getMarkup() : Markup.NULL;
if (markup == null) {
markup = Markup.NULL;
}
if (columnIndex == 0) {
markup = markup.add(Markup.FIRST);
}
if (hasClickAction) {
markup = markup.add(Markup.CLICKABLE);
}
if (isPure(column)) {
markup = markup.add(Markup.PURE);
}
writer.writeClassAttribute(Classes.create(sheet, "cell", markup));
final TextAlign align = TextAlign.parse((String) column.getAttributes().get(Attributes.ALIGN));
if (align != null) {
final Style alignStyle = new Style();
alignStyle.setTextAlign(align);
writer.writeStyleAttribute(alignStyle);
}
if (column instanceof UIColumnSelector) {
final boolean disabled = ComponentUtils.getBooleanAttribute(column, Attributes.DISABLED);
writer.startElement(HtmlElements.INPUT, null);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.CHECKBOX, false);
writer.writeAttribute(HtmlAttributes.CHECKED, selected);
writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
writer.writeIdAttribute(sheetId + "_data_row_selector_" + rowIndex);
writer.writeClassAttribute(Classes.create(sheet, "columnSelector"));
writer.endElement(HtmlElements.INPUT);
} else if (column instanceof AbstractUIColumnNode) {
EncodeUtils.prepareRendererAll(facesContext, column);
RenderUtils.encode(facesContext, column);
} else {
final List<UIComponent> children = sheet.getRenderedChildrenOf(column);
for (final UIComponent grandKid : children) {
// set height to 0 to prevent use of layoutheight from parent
grandKid.getAttributes().put(Attributes.LAYOUT_HEIGHT, HEIGHT_0);
// XXX hotfix
if (grandKid instanceof LayoutBase) {
final LayoutBase base = (LayoutBase) grandKid;
if (base.getLeft() != null) {
base.setLeft(null);
}
if (base.getTop() != null) {
base.setTop(null);
}
}
EncodeUtils.prepareRendererAll(facesContext, grandKid);
RenderUtils.encode(facesContext, grandKid);
}
}
writer.endElement(HtmlElements.TD);
}
writer.startElement(HtmlElements.TD, null);
writer.writeClassAttribute(Classes.create(sheet, "cell", Markup.FILLER));
// writer.write(" ");
writer.startElement(HtmlElements.DIV, null);
writer.endElement(HtmlElements.DIV);
writer.endElement(HtmlElements.TD);
writer.endElement(HtmlElements.TR);
}
sheet.setRowIndex(-1);
if (emptySheet && showHeader) {
writer.startElement(HtmlElements.TR, null);
int columnIndex = -1;
for (final UIColumn ignored : renderedColumnList) {
columnIndex++;
writer.startElement(HtmlElements.TD, null);
writer.startElement(HtmlElements.DIV, null);
final Integer divWidth = sheet.getWidthList() != null ? sheet.getWidthList().get(columnIndex) : 100;
final Style divStyle = new Style();
divStyle.setWidth(Measure.valueOf(divWidth));
writer.writeStyleAttribute(divStyle);
writer.endElement(HtmlElements.DIV);
writer.endElement(HtmlElements.TD);
}
writer.startElement(HtmlElements.TD, null);
writer.writeClassAttribute(Classes.create(sheet, "cell", Markup.FILLER));
// writer.write(" ");
writer.startElement(HtmlElements.DIV, null);
writer.endElement(HtmlElements.DIV);
writer.endElement(HtmlElements.TD);
writer.endElement(HtmlElements.TR);
}
writer.endElement(HtmlElements.TABLE);
writer.endElement(HtmlElements.DIV);
// END RENDER BODY CONTENT
if (sheet.isPagingVisible()) {
final Style footerStyle = new Style();
footerStyle.setWidth(sheet.getCurrentWidth());
if (ie6SelectOneFix) {
footerStyle.setTop(headerHeight);
}
writer.startElement(HtmlElements.DIV, sheet);
writer.writeClassAttribute(Classes.create(sheet, "footer"));
writer.writeStyleAttribute(footerStyle);
// show row range
final Markup showRowRange = markupForLeftCenterRight(sheet.getShowRowRange());
if (showRowRange != Markup.NULL) {
UICommand pagerCommand = (UICommand) sheet.getFacet(Facets.PAGER_ROW);
if (pagerCommand == null) {
pagerCommand = createPagingCommand(application, PageAction.TO_ROW, false);
sheet.getFacets().put(Facets.PAGER_ROW, pagerCommand);
}
final String pagerCommandId = pagerCommand.getClientId(facesContext);
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(Classes.create(sheet, "pagingOuter", showRowRange));
writer.writeAttribute(HtmlAttributes.TITLE,
ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "sheetPagingInfoRowPagingTip"), true);
writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
writer.write(createSheetPagingInfo(sheet, facesContext, pagerCommandId, true));
writer.endElement(HtmlElements.SPAN);
}
// show direct links
final Markup showDirectLinks = markupForLeftCenterRight(sheet.getShowDirectLinks());
if (showDirectLinks != Markup.NULL) {
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(Classes.create(sheet, "pagingOuter", showDirectLinks));
writer.writeIdAttribute(sheetId + ComponentUtils.SUB_SEPARATOR + "pagingLinks");
writeDirectPagingLinks(writer, facesContext, application, sheet);
writer.endElement(HtmlElements.SPAN);
}
// show page range
final Markup showPageRange = markupForLeftCenterRight(sheet.getShowPageRange());
if (showPageRange != Markup.NULL) {
UICommand pagerCommand = (UICommand) sheet.getFacet(Facets.PAGER_PAGE);
if (pagerCommand == null) {
pagerCommand = createPagingCommand(application, PageAction.TO_PAGE, false);
sheet.getFacets().put(Facets.PAGER_PAGE, pagerCommand);