* This method is separated from the encodeChildren so that it can be overridden by
* subclasses. One class that uses this functionality is autoUpdateDataTable.
*/
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{
UIData uiData = (UIData) component;
ResponseWriter writer = facesContext.getResponseWriter();
// begin the table
// get the CSS styles
Styles styles = getStyles(uiData);
int first = uiData.getFirst();
int rows = uiData.getRows();
int last;
if (rows <= 0)
{
last = uiData.getRowCount();
}
else
{
last = first + rows;
if (last > uiData.getRowCount())
{
last=uiData.getRowCount();
}
}
int newspaperColumns = getNewspaperColumns(component);
int newspaperRows;
if((last - first) % newspaperColumns == 0)
newspaperRows = (last - first) / newspaperColumns;
else newspaperRows = ((last - first) / newspaperColumns) + 1;
boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);
// walk through the newspaper rows
for(int nr = 0; nr < newspaperRows; nr++)
{
// walk through the newspaper columns
for(int nc = 0; nc < newspaperColumns; nc++) {
// the current row in the 'real' table
int currentRow;
if (newspaperHorizontalOrientation)
currentRow = nr * newspaperColumns + nc + first;
else
currentRow = nc * newspaperRows + nr + first;
// if this row is not to be rendered
if(currentRow >= last) continue;
// bail if any row does not exist
uiData.setRowIndex(currentRow);
if(!uiData.isRowAvailable()) {
log.error("Row is not available. Rowindex = " + currentRow);
break;
}
if (nc == 0) {
// first column in table, start new row
beforeRow(facesContext, uiData);
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
renderRowStart(facesContext, writer, uiData, styles, nr);
}
List children = getChildren(component);
for (int j = 0, size = getChildCount(component); j < size; j++)
{
UIComponent child = (UIComponent) children.get(j);
if (child.isRendered())
{
boolean columnRendering = child instanceof UIColumn;
if (columnRendering)
beforeColumn(facesContext, uiData, j);
encodeColumnChild(facesContext, writer, uiData, child, styles, nc * uiData.getChildCount() + j);
if (columnRendering)
afterColumn(facesContext, uiData, j);
}
}