javascript = renderNameAndId(request, _tableState, null);
}
boolean addedDataAccessProvider = false;
try {
InternalStringBuilder builder = new InternalStringBuilder(2048);
AbstractRenderAppender appender = new StringBuilderRenderAppender(builder);
/* todo: perf -- this doesn't need to happen when the data set is empty */
DataAccessProviderStack.addDataAccessProvider(this, getJspContext());
DataGridUtil.putDataGridTagModel(getJspContext(), _dataGridTagModel);
addedDataAccessProvider = true;
StringWriter sw = new StringWriter();
/*
allow sub-tags to do work during START before rendering
this makes it possible to have tags out of order and to
have rendering work correctly
*/
/* todo: perf -- should you be able to turn this off for perf? */
fragment.invoke(sw);
/* todo: this needs to move into the DataGridTagModel */
PagerModel pm = _dataGridTagModel.getState().getPagerModel();
_dataGridTagModel.getDataSet().createWindow(pm.getRow(), pm.getPageSize());
/* now that the model objects have been initialized, it's time to start rendering */
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_START);
if(!_dataGridTagModel.isDisableDefaultPagerRendering())
_dataGridTagModel.renderPager(appender);
_tableState.styleClass = styleModel.getTableClass();
tableRenderer.openTable(_tableState, appender);
/* render the caption */
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_CAPTION);
sw = new StringWriter();
fragment.invoke(sw);
String caption = sw.toString();
if(caption != null)
appender.append(caption);
/* render the header */
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_HEADER);
sw = new StringWriter();
fragment.invoke(sw);
String header = sw.toString();
if(header != null)
appender.append(header);
/* intermediate storage for the body and footer content
these are required by the HTML spec:
http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3
as when the row groups are used, they must be re-ordered so that
<tfoot> preceeds <tbody>
*/
String tbody = null;
String tfoot = null;
/* render the body */
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_GRID);
sw = new StringWriter();
fragment.invoke(sw);
tbody = sw.toString();
/* render the footer */
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_FOOTER);
sw = new StringWriter();
fragment.invoke(sw);
String footer = sw.toString();
String trimmed = footer.trim();
if(footer != null && !trimmed.trim().equals(""))
tfoot = footer;
if(_dataGridTagModel.isRenderRowGroups()) {
if(tfoot != null)
appender.append(tfoot);
appender.append(tbody);
}
else {
appender.append(tbody);
if(tfoot != null)
appender.append(tfoot);
}
tableRenderer.closeTable(appender);
if(javascript != null)
appender.append(javascript);
_dataGridTagModel.changeRenderState(DataGridTagModel.RENDER_STATE_END);
write(builder.toString());
}
finally {
if(addedDataAccessProvider) {
DataAccessProviderStack.removeDataAccessProvider(getJspContext());
DataGridUtil.removeDataGridTagModel(getJspContext());