public UIData getUIData() { String forStr = getFor(); UIData forComp = (UIData) CoreComponentUtils.findComponent(forStr, this); if (forComp == null) { throw new IllegalArgumentException( "could not find UIData referenced by attribute @for = '" + forStr + "'"); } else if (!(forComp instanceof UIData)) { throw new IllegalArgumentException( "uiComponent referenced by attribute @for = '" + forStr + "' must be of type " + UIData.class.getName() + ", not type " + forComp.getClass().getName()); } // compare with cached DataModel to check for updates if (_origDataModelHash != 0 && _origDataModelHash != forComp.getValue().hashCode()) { reset(); } if (!isIgnorePagination() && ((first != Integer.MIN_VALUE && first != forComp.getFirst()) || (rows != Integer.MIN_VALUE && rows != forComp.getRows()))) { reset(); } Object value = forComp.getValue(); if (null != value) { _origDataModelHash = forComp.getValue().hashCode(); } return forComp; }
private void renderToHandler(OutputTypeHandler outputHandler, UIData uiData, FacesContext fc) { try { int rowIndex = 0; int numberOfRowsToDisplay = 0; if (!isIgnorePagination()) { rowIndex = uiData.getFirst(); numberOfRowsToDisplay = uiData.getRows(); first = rowIndex; rows = numberOfRowsToDisplay; } int countOfRowsDisplayed = 0; uiData.setRowIndex(rowIndex); String[] includeColumnsArray = null; String includeColumns = getIncludeColumns(); if (includeColumns != null) includeColumnsArray = includeColumns.split(","); List columns = getRenderedChildColumnsList(uiData); // System.out.println("DataExporter.renderToHandler() columns.size: " + columns.size()); // write header // System.out.println("DataExporter.renderToHandler() HEADERS"); processAllColumns(fc, outputHandler, columns, includeColumnsArray, -1, false); // System.out.println("DataExporter.renderToHandler() ROWS"); while (uiData.isRowAvailable()) { if (numberOfRowsToDisplay > 0 && countOfRowsDisplayed >= numberOfRowsToDisplay) { break; } // render the child columns; each one in a td processAllColumns( fc, outputHandler, columns, includeColumnsArray, countOfRowsDisplayed, false); // keep track of rows displayed countOfRowsDisplayed++; // maintain the row index property on the underlying UIData // component rowIndex++; uiData.setRowIndex(rowIndex); } // reset the underlying UIData component uiData.setRowIndex(-1); // write footer // System.out.println("DataExporter.renderToHandler() FOOTERS"); processAllColumns( fc, outputHandler, columns, includeColumnsArray, countOfRowsDisplayed, true); outputHandler.flushFile(); } catch (Exception e) { log.error("renderToHandler()", e); } }