TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
String contextPath = facesContext.getExternalContext().getRequestContextPath();
String sheetId = sheet.getClientId(facesContext);
Measure sheetHeight;
if (style.getHeight() == null) {
// FIXME: nullpointer if height not defined
LOG.error("no height in parent container, setting to 100");
sheetHeight = Measure.valueOf(100);
} else {
sheetHeight = style.getHeight();
}
Measure footerHeight = getFooterHeight(facesContext, sheet);
Measure headerHeight = getHeaderHeight(facesContext, sheet);
String selectable = sheet.getSelectable();
Application application = facesContext.getApplication();
SheetState state = sheet.getSheetState(facesContext);
List<Integer> columnWidths = sheet.getWidthList();
final List<Integer> selectedRows = getSelectedRows(sheet, state);
final List<UIColumn> renderedColumnList = sheet.getRenderedColumns();
writer.startElement(HtmlElements.INPUT, null);
writer.writeIdAttribute(sheetId + WIDTHS_POSTFIX);
writer.writeNameAttribute(sheetId + WIDTHS_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.joinWithSurroundingSeparator(columnWidths), false);
writer.endElement(HtmlElements.INPUT);
writer.startElement(HtmlElements.INPUT, null);
writer.writeIdAttribute(sheetId + SCROLL_POSTFIX);
writer.writeNameAttribute(sheetId + SCROLL_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
Integer[] scrollPosition = sheet.getScrollPosition();
if (scrollPosition != null) {
String scroll = scrollPosition[0] + ";" + scrollPosition[1];
writer.writeAttribute(HtmlAttributes.VALUE, scroll, false);
} else {
writer.writeAttribute(HtmlAttributes.VALUE, "", false);
}
writer.endElement(HtmlElements.INPUT);
if (!UISheet.NONE.equals(selectable)) {
writer.startElement(HtmlElements.INPUT, null);
writer.writeIdAttribute(sheetId + SELECTED_POSTFIX);
writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
writer.writeAttribute(
HtmlAttributes.VALUE, StringUtils.joinWithSurroundingSeparator(selectedRows), true);
writer.endElement(HtmlElements.INPUT);
}
final boolean showHeader = sheet.isShowHeader();
final boolean ie6SelectOneFix = showHeader
&& ClientProperties.getInstance(facesContext).getUserAgent().isMsie6()
&& ComponentUtils.findDescendant(sheet, UISelectOne.class) != null;
// BEGIN RENDER BODY CONTENT
Style bodyStyle = new Style();
bodyStyle.setPosition(Position.RELATIVE);
Measure tableBodyWidth = sheet.getCurrentWidth().subtractNotNegative(getContentBorder(facesContext, sheet));
bodyStyle.setWidth(tableBodyWidth);
if (sheet.isPagingVisible()) {
sheetHeight = sheetHeight.subtract(footerHeight);
}
if (ie6SelectOneFix) {
bodyStyle.setTop(headerHeight);
}
if (showHeader) {
sheetHeight = sheetHeight.subtract(headerHeight);
}
bodyStyle.setHeight(sheetHeight);
writer.startElement(HtmlElements.DIV, null);
writer.writeIdAttribute(sheetId + ComponentUtils.SUB_SEPARATOR + "data_div");
writer.writeClassAttribute(Classes.create(sheet, "body"));
if (!showHeader || ie6SelectOneFix) {
bodyStyle.setPaddingTop(Measure.ZERO);
}
writer.writeStyleAttribute(bodyStyle);
bodyStyle.setHeight(null);
bodyStyle.setTop(null);
Style sheetBodyStyle = new Style(bodyStyle);
if (sheet.getNeedVerticalScrollbar() == null) {
LOG.warn("Value of needVerticalScrollbar undefined!"); // why this value isn't set by the layout manager?
} else {
if (sheet.getNeedVerticalScrollbar()) {
tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
}
}
sheetBodyStyle.setWidth(tableBodyWidth);
writer.startElement(HtmlElements.TABLE, null);