String image1x1 = contextPath + resourceManager.getImage(viewRoot, "image/1x1.gif");
String selectorDisabled = contextPath + resourceManager.getImage(viewRoot, "image/sheetUncheckedDisabled.gif");
String unchecked = contextPath + resourceManager.getImage(viewRoot, "image/sheetUnchecked.gif");
Map attributes = data.getAttributes();
HtmlStyleMap sheetStyle = (HtmlStyleMap) attributes.get(ATTR_STYLE);
//HtmlStyleMap headerStyle = (HtmlStyleMap) attributes.get(ATTR_STYLE_HEADER);
// String sheetWidthString = LayoutUtil.getStyleAttributeValue(sheetStyle,
// "width");
Integer sheetHeight = HtmlRendererUtil.getStyleAttributeIntValue(sheetStyle, "height");
if (sheetHeight == null) {
// FIXME: nullpointer if height not defined
LOG.error("no height in parent container, setting to 100");
sheetHeight = 100;
}
//HtmlStyleMap bodyStyle = (HtmlStyleMap) attributes.get(ATTR_STYLE_BODY);
int footerHeight = (Integer) attributes.get(ATTR_FOOTER_HEIGHT);
String selectable = data.getSelectable();
SheetState state = data.getSheetState(facesContext);
List<Integer> columnWidths = data.getWidthList();
String selectedRows = StringUtils.toString(getSelectedRows(data, state));
List<UIColumn> renderedColumnList = data.getRenderedColumns();
writer.startElement(HtmlConstants.INPUT, null);
writer.writeIdAttribute(sheetId + WIDTHS_POSTFIX);
writer.writeNameAttribute(sheetId + WIDTHS_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.toString(columnWidths), false);
writer.endElement(HtmlConstants.INPUT);
writer.startElement(HtmlConstants.INPUT, null);
writer.writeIdAttribute(sheetId + SCROLL_POSTFIX);
writer.writeNameAttribute(sheetId + SCROLL_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
Integer[] scrollPosition = data.getScrollPosition();
if (scrollPosition != null) {
String scroll = scrollPosition[0] + ";" + scrollPosition[1];
writer.writeAttribute(HtmlAttributes.VALUE, scroll, false);
} else {
writer.writeAttribute(HtmlAttributes.VALUE, "", false);
}
writer.endElement(HtmlConstants.INPUT);
if (!NONE.equals(selectable)) {
writer.startElement(HtmlConstants.INPUT, null);
writer.writeIdAttribute(sheetId + SELECTED_POSTFIX);
writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
writer.writeAttribute(HtmlAttributes.VALUE, selectedRows, true);
writer.endElement(HtmlConstants.INPUT);
}
final boolean showHeader = data.isShowHeader();
final boolean ie6SelectOneFix = showHeader
&& ClientProperties.getInstance(facesContext).getUserAgent().isMsie6()
&& ComponentUtil.findDescendant(data, UISelectOne.class) != null;
if (showHeader) {
// begin rendering header
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(sheetId + "_header_div");
writer.writeClassAttribute("tobago-sheet-header-div");
HtmlStyleMap headerStyle = (HtmlStyleMap) attributes.get(ATTR_STYLE_HEADER);
Integer zIndex = getZIndex(facesContext);
if (headerStyle != null) {
headerStyle.put("z-index", zIndex+1);
if (ie6SelectOneFix) {
headerStyle.put("position", "relative");
}
writer.writeStyleAttribute(headerStyle);
}
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;
}
for (UIColumn column : renderedColumnList) {
renderColumnHeader(facesContext, writer, data, columnCount, column,
imageAscending, imageDescending, imageUnsorted, image1x1, sortMarkerWidth);
columnCount++;
}
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(sheetId + "_header_box_filler");
writer.writeClassAttribute("tobago-sheet-header-box tobago-sheet-header-filler");
writer.writeAttribute(HtmlAttributes.STYLE, "width: 0px", false);
writer.startElement(HtmlConstants.DIV, null);
writer.writeClassAttribute("tobago-sheet-header");
writer.flush();
writer.write(" ");
writer.endElement(HtmlConstants.DIV);
writer.endElement(HtmlConstants.DIV);
writer.endElement(HtmlConstants.DIV);
// end rendering header
}
// BEGIN RENDER BODY CONTENT
HtmlStyleMap bodyStyle = (HtmlStyleMap) attributes.get(ATTR_STYLE_BODY);
int bodyHeight = (sheetHeight - footerHeight);
HtmlRendererUtil.replaceStyleAttribute(data, ATTR_STYLE_BODY, "height", bodyHeight);
writer.startElement(HtmlConstants.DIV, null);
writer.writeIdAttribute(sheetId + "_data_div");
writer.writeClassAttribute("tobago-sheet-body-div ");
if (ie6SelectOneFix) {
int headerHeight = getConfiguredValue(facesContext, data, "headerHeight");
bodyStyle.put("height", bodyHeight - headerHeight);
bodyStyle.put("position", "relative");
}
if (!showHeader||ie6SelectOneFix) {
bodyStyle.put("padding-top", "0");
}
writer.writeAttribute(HtmlAttributes.STYLE, bodyStyle.toString(), false);
if (ie6SelectOneFix) {
bodyStyle.remove("position");
}
if (!showHeader||ie6SelectOneFix) {
bodyStyle.remove("padding-top");
}
bodyStyle.remove("height");
Integer space = HtmlRendererUtil.getStyleAttributeIntValue(bodyStyle, "width");
HtmlStyleMap sheetBodyStyle = (HtmlStyleMap) bodyStyle.clone();
//String sheetBodyStyle;
if (space != null) {
// intSpace -= columnWidths.get(columnWidths.size() - 1);
space -= getContentBorder(facesContext, data);
if (needVerticalScrollbar(facesContext, data)) {
space -= getScrollbarWidth(facesContext, data);
}
sheetBodyStyle.put("width", space);
}
writer.startElement(HtmlConstants.TABLE, null);