A table writer that formats a table in HTML and writes it to a JSP page.
| Method from org.displaytag.render.HtmlTableWriter Detail: |
public String getOpenTag() {
if (this.uid != null && attributeMap.get(TagConstants.ATTRIBUTE_ID) == null)
{
// we need to clone the attribute map in order to "fix" the html id when using only the "uid" attribute
Map localAttributeMap = (Map) attributeMap.clone();
localAttributeMap.put(TagConstants.ATTRIBUTE_ID, this.uid);
StringBuffer buffer = new StringBuffer();
buffer.append(TagConstants.TAG_OPEN).append(TagConstants.TABLE_TAG_NAME);
buffer.append(localAttributeMap);
buffer.append(TagConstants.TAG_CLOSE);
return buffer.toString();
}
// fast, no clone
StringBuffer buffer = new StringBuffer();
buffer.append(TagConstants.TAG_OPEN).append(TagConstants.TABLE_TAG_NAME);
buffer.append(attributeMap);
buffer.append(TagConstants.TAG_CLOSE);
return buffer.toString();
}
create the open tag containing all the attributes. |
public void write(String string) {
if (string != null)
{
try
{
out.write(string);
}
catch (IOException e)
{
throw new WrappedRuntimeException(getClass(), e);
}
}
}
|
public void write(Object string) {
if (string != null)
{
try
{
out.write(string.toString());
}
catch (IOException e)
{
throw new WrappedRuntimeException(getClass(), e);
}
}
}
|
protected void writeBottomBanner(TableModel model) {
writeNavigationAndExportLinks();
}
Writes a banner containing search result, paging navigation, and export links below an HTML table to a JSP page. |
protected void writeCaption(TableModel model) {
this.write(captionTag.getOpenTag() + model.getCaption() + captionTag.getCloseTag());
}
Writes an HTML table's caption to a JSP page. |
protected void writeColumnCloser(Column column) {
this.write(column.getCloseTag());
}
Writes an HTML table's column-closing tag to a JSP page. |
protected void writeColumnOpener(Column column) throws DecoratorException, ObjectLookupException {
this.write(column.getOpenTag());
}
Writes an HTML table's column-opening tag to a JSP page. |
protected void writeColumnValue(Object value,
Column column) {
this.write(value);
}
Writes a HTML table column value to a JSP page. |
protected void writeDecoratedRowFinish(TableModel model) {
this.write(model.getTableDecorator().finishRow());
}
|
protected void writeDecoratedRowStart(TableModel model) {
this.write(model.getTableDecorator().startRow());
}
|
protected void writeDecoratedTableFinish(TableModel model) {
model.getTableDecorator().finish();
}
|
protected void writeEmptyListMessage(String emptyListMessage) {
this.write(emptyListMessage);
}
Writes an HTML message to a JSP page explaining that the table model contains no data. |
protected void writeEmptyListRowMessage(String message) {
this.write(message);
}
Writes an HTML message to a JSP page explaining that the row contains no data. |
public void writeNavigationAndExportLinks() {
// Put the page stuff there if it needs to be there...
if (this.properties.getAddPagingBannerBottom())
{
writeSearchResultAndNavigation();
}
// add export links (only if the table is not empty)
if (this.export && this.tableModel.getRowListPage().size() != 0)
{
writeExportLinks();
}
}
Generates table footer with links for export commands. |
protected void writePreBodyFooter(TableModel model) {
this.write(TagConstants.TAG_TFOOTER_OPEN);
this.write(model.getFooter());
this.write(TagConstants.TAG_TFOOTER_CLOSE);
}
Writes an HTML table's footer to a JSP page; HTML requires tfoot to appear before tbody. |
protected void writeRowCloser(Row row) {
this.write(row.getCloseTag());
}
Writes an HTML table's row-closing tag to a JSP page. |
protected void writeRowOpener(Row row) {
this.write(row.getOpenTag());
}
Writes an HTML table's row-opening tag to a JSP page. |
protected void writeRowWithNoColumns(String rowValue) {
this.write(TagConstants.TAG_TD_OPEN);
this.write(rowValue);
this.write(TagConstants.TAG_TD_CLOSE);
}
Writes to a JSP page an HTML table row that has no columns. |
public void writeSearchResultAndNavigation() {
if ((this.paginatedList == null && this.pagesize != 0 && this.listHelper != null)
|| (this.paginatedList != null))
{
// create a new href
Href navigationHref = (Href) this.baseHref.clone();
write(this.listHelper.getSearchResultsSummary());
String pageParameter;
if (paginatedList == null)
{
pageParameter = encodeParameter(TableTagParameters.PARAMETER_PAGE);
}
else
{
pageParameter = properties.getPaginationPageNumberParam();
if ((paginatedList.getSearchId() != null)
&& (!navigationHref.getParameterMap().containsKey(properties.getPaginationSearchIdParam())))
{
navigationHref.addParameter(properties.getPaginationSearchIdParam(), paginatedList.getSearchId());
}
}
write(this.listHelper.getPageNavigationBar(navigationHref, pageParameter));
}
}
generates the search result and navigation bar. |
public void writeTable(TableModel model,
String id) throws JspException {
super.writeTable(model, id);
}
|
protected void writeTableBodyCloser(TableModel model) {
this.write(TagConstants.TAG_TBODY_CLOSE);
}
Writes the end of an HTML table's body to a JSP page. |
protected void writeTableBodyOpener(TableModel model) {
this.write(TagConstants.TAG_TBODY_OPEN);
}
Writes the start of an HTML table's body to a JSP page. |
protected void writeTableCloser(TableModel model) {
this.write(TagConstants.TAG_OPENCLOSING);
this.write(TagConstants.TABLE_TAG_NAME);
this.write(TagConstants.TAG_CLOSE);
}
Writes the closing structure of an HTML table to a JSP page. |
protected void writeTableHeader(TableModel model) {
if (log.isDebugEnabled())
{
log.debug("[" + tableModel.getId() + "] getTableHeader called");
}
// open thead
write(TagConstants.TAG_THEAD_OPEN);
// open tr
write(TagConstants.TAG_TR_OPEN);
// no columns?
if (this.tableModel.isEmpty())
{
write(TagConstants.TAG_TH_OPEN);
write(TagConstants.TAG_TH_CLOSE);
}
// iterator on columns for header
Iterator iterator = this.tableModel.getHeaderCellList().iterator();
while (iterator.hasNext())
{
// get the header cell
HeaderCell headerCell = (HeaderCell) iterator.next();
if (headerCell.getSortable())
{
String cssSortable = this.properties.getCssSortable();
headerCell.addHeaderClass(cssSortable);
}
// if sorted add styles
if (headerCell.isAlreadySorted())
{
// sorted css class
headerCell.addHeaderClass(this.properties.getCssSorted());
// sort order css class
headerCell.addHeaderClass(this.properties.getCssOrder(this.tableModel.isSortOrderAscending()));
}
// append th with html attributes
write(headerCell.getHeaderOpenTag());
// title
String header = headerCell.getTitle();
// column is sortable, create link
if (headerCell.getSortable())
{
// creates the link for sorting
Anchor anchor = new Anchor(getSortingHref(headerCell), header);
// append to buffer
header = anchor.toString();
}
write(header);
write(headerCell.getHeaderCloseTag());
}
// close tr
write(TagConstants.TAG_TR_CLOSE);
// close thead
write(TagConstants.TAG_THEAD_CLOSE);
if (log.isDebugEnabled())
{
log.debug("[" + tableModel.getId() + "] getTableHeader end");
}
}
Writes an HTML table's column header to a JSP page. |
protected void writeTableOpener(TableModel model) {
this.write(getOpenTag());
}
Writes an HTML table's opening tags to a JSP page. |
protected void writeTopBanner(TableModel model) {
writeSearchResultAndNavigation();
}
Writes a banner containing search result and paging navigation above an HTML table to a JSP page. |