writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.toString(selectedRows), false);
writer.endElement(HtmlConstants.INPUT);
}
ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
UIViewRoot viewRoot = facesContext.getViewRoot();
String contextPath = facesContext.getExternalContext().getRequestContextPath();
//String checkedImage = contextPath + resourceManager.getImage(viewRoot, "image/sheetChecked.gif");
//String uncheckeImage = contextPath + resourceManager.getImage(viewRoot, "image/sheetUnchecked.gif");
String selectorDisabled = contextPath + resourceManager.getImage(viewRoot, "image/sheetUncheckedDisabled.gif");
String unchecked = contextPath + resourceManager.getImage(viewRoot, "image/sheetUnchecked.gif");
// Outer list div
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(sheetId + "_data_div");
writer.writeClassAttribute("tobago-simpleSheet-list");
writer.writeStyleAttribute(bodyStyle);
int top = 20;
boolean odd = false;
final int last = data.getFirst() + data.getRows();
for (int row = data.getFirst(); row < last; row++) {
data.setRowIndex(row);
if (!data.isRowAvailable()) {
break;
}
odd = !odd;
final String rowClass = odd ? "tobago-sheet-content-odd " : "tobago-sheet-content-even ";
//TODO make markup toago compatible
String[] rowMarkups = (String[]) data.getAttributes().get("rowMarkup");
String rowMarkup = "";
if (rowMarkup != null) {
rowMarkup = " " + org.apache.commons.lang.StringUtils.join(rowMarkups, " ");
}
writer.startElement(HtmlConstants.DIV, null);
writer.writeClassAttribute("tobago-simpleSheet-row " + rowClass + rowMarkup);
writer.writeIdAttribute(sheetId + "_data_tr_" + row);
writer.writeAttribute(HtmlAttributes.STYLE, "top: "+ top+ "px; left: 0px;", false);
writer.flush();
int columnIndex = -1;
int currentLeft = 0;
for (UIColumn column : renderedColumnList) {
columnIndex++;
writer.startElement(HtmlConstants.DIV, null);
writer.writeClassAttribute("tobago-simpleSheet-cell");
// todo cell markup
// + (rowSelected ? " tobabo-simpleSheet-cell-selected" : ""));
writer.writeIdAttribute(sheetId + "_" + row + "_" + columnIndex);
final String align = (String) column.getAttributes().get(TobagoConstants.ATTR_ALIGN);
writer.writeAttribute(HtmlAttributes.STYLE, "top: 0px; left: " + currentLeft + "px; width: "
+ columnWidths.get(columnIndex) + "px; "
+ (align!=null?HtmlRendererUtil.toStyleString("text-align", align):""), false);
if (column instanceof UIColumnSelector) {
final boolean disabled = ComponentUtil.getBooleanAttribute(column, TobagoConstants.ATTR_DISABLED);
writer.startElement(HtmlConstants.IMG, null);
if (disabled) {
writer.writeAttribute(HtmlAttributes.SRC, selectorDisabled, false);
} else {
writer.writeAttribute(HtmlAttributes.SRC, unchecked, false);
}
writer.writeIdAttribute(sheetId + "_data_row_selector_" + row);
writer.writeClassAttribute("tobago-sheet-column-selector");
writer.endElement(HtmlConstants.IMG);
} else {
List<UIComponent> childs = data.getRenderedChildrenOf(column);
for (UIComponent grandkid : childs) {
// set height to 0 to prevent use of layoutheight from parent
grandkid.getAttributes().put(TobagoConstants.ATTR_LAYOUT_HEIGHT, 0);
RenderUtil.encode(facesContext, grandkid);
}
if (childs.size() > 1) {
if (LOG.isInfoEnabled()) {
LOG.info(
"Column should not contain more than one child. Please surround the components with a tc:panel.");
}
}
}
writer.endElement(HtmlConstants.DIV);
currentLeft += columnWidths.get(columnIndex);
}
writer.endElement(HtmlConstants.DIV);
top += 20;
}
data.setRowIndex(-1);
writer.endElement(HtmlConstants.DIV);
String image1x1 = contextPath + resourceManager.getImage(viewRoot, "image/1x1.gif");
int columnCount = 0;
final int sortMarkerWidth = getAscendingMarkerWidth(facesContext, data);
String imageAscending = contextPath + resourceManager.getImage(viewRoot, "image/ascending.gif");
String imageDescending = contextPath + resourceManager.getImage(viewRoot, "image/descending.gif");
String img = resourceManager.getImage(viewRoot, "image/unsorted.gif", true);
String imageUnsorted = image1x1;
if (img != null) {
imageUnsorted = contextPath + img;
}
writer.startElement(HtmlConstants.DIV, null);