LOG.debug("var " + var);
LOG.debug("list " + sheet.getValue());
}
writer.startElement(HtmlElements.TR, null);
Markup rowMarkup = odd ? Markup.ODD : Markup.EVEN;
final boolean selected = selectedRows.contains(rowIndex);
if (selected) {
rowMarkup = rowMarkup.add(Markup.SELECTED);
}
writer.writeClassAttribute(Classes.create(sheet, "row", rowMarkup));
if (rowIndex == sheet.getFirst()) {
writer.writeAttribute("rowIndexInModel", Integer.toString(sheet.getFirst()), false);
}
int columnIndex = -1;
for (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) {
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 {
List<UIComponent> children = sheet.getRenderedChildrenOf(column);
for (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) {
LayoutBase base = (LayoutBase) grandKid;
if (base.getLeft() != null) {
base.setLeft(null);
}
if (base.getTop() != null) {
base.setTop(null);
}
}
RenderUtils.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 (UIColumn column : renderedColumnList) {
columnIndex++;
writer.startElement(HtmlElements.TD, null);
writer.startElement(HtmlElements.DIV, null);
Integer divWidth = sheet.getWidthList().get(columnIndex);
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 (showHeader) {
renderColumnHeaders(
facesContext, sheet, writer, resourceManager, contextPath, sheetId, renderedColumnList, tableBodyWidth);
}
if (sheet.isPagingVisible()) {
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);