protected void encodeScrollBody( FacesContext context, DataTable table, String tableStyle, String tableStyleClass) throws IOException { ResponseWriter writer = context.getResponseWriter(); String scrollHeight = table.getScrollHeight(); writer.startElement("div", null); writer.writeAttribute("class", DataTable.SCROLLABLE_BODY_CLASS, null); if (scrollHeight != null && scrollHeight.indexOf("%") == -1) { writer.writeAttribute("style", "height:" + scrollHeight + "px", null); } writer.startElement("table", null); writer.writeAttribute("role", "grid", null); if (tableStyle != null) writer.writeAttribute("style", tableStyle, null); if (table.getTableStyleClass() != null) writer.writeAttribute("class", tableStyleClass, null); encodeColGroup(context, table); encodeTbody(context, table, false); writer.endElement("table"); writer.endElement("div"); }
protected void encodeScript(FacesContext context, DataTable table) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = table.getClientId(context); String selectionMode = table.resolveSelectionMode(); WidgetBuilder wb = getWidgetBuilder(context); wb.widget("DataTable", table.resolveWidgetVar(), clientId, true); // Pagination if (table.isPaginator()) { encodePaginatorConfig(context, table, wb); } // Selection wb.attr("selectionMode", selectionMode, null); // Filtering if (table.isFilteringEnabled()) { wb.attr("filter", true) .attr("filterEvent", table.getFilterEvent(), null) .attr("filterDelay", table.getFilterDelay(), Integer.MAX_VALUE); } // Row expansion if (table.getRowExpansion() != null) { wb.attr("expansion", true); } // Scrolling if (table.isScrollable()) { wb.attr("scrollable", true) .attr("liveScroll", table.isLiveScroll()) .attr("scrollStep", table.getScrollRows()) .attr("scrollLimit", table.getRowCount()) .attr("scrollWidth", table.getScrollWidth(), null) .attr("scrollHeight", table.getScrollHeight(), null); } // Resizable/Draggable Columns wb.attr("resizableColumns", table.isResizableColumns(), false) .attr("liveResize", table.isLiveResize(), false) .attr("draggableColumns", table.isDraggableColumns(), false); // Editing if (table.isEditable()) { wb.attr("editable", true) .attr("editMode", table.getEditMode()) .attr("cellSeparator", table.getCellSeparator(), null); } // MultiColumn Sorting if (table.isMultiSort()) { wb.attr("multiSort", true); } // Behaviors encodeClientBehaviors(context, table, wb); startScript(writer, clientId); writer.write(wb.build()); endScript(writer); }