|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Table
public class Table
Provides a HTML Table control: <table>.
public class CustomersPage extends BorderPage { public Table table = new Table(); public ActionLink deleteLink = new ActionLink("Delete", this, "onDeleteClick"); public CustomersPage() { table.setClass(Table.CLASS_ITS); table.setPageSize(4); table.setShowBanner(true); table.setSortable(true); table.addColumn(new Column("id")); table.addColumn(new Column("name")); Column column = new Column("email"); column.setAutolink(true); table.addColumn(column); table.addColumn(new Column("investments")); column = new Column("Action"); column.setDecorator(new LinkDecorator(table, deleteLink, "id")); column.setSortable(false); table.addColumn(column); // Set data provider to populate the table row list from table.setDataProvider(new DataProvider() { public List getData() { return getCustomerService().getCustomersSortedByName(); } }); } public boolean onDeleteClick() { Integer id = deleteLink.getValueInteger(); getCustomerService().deleteCustomer(id); return true; } }
DataProvider
is used to populate the Table row list
from. DataProviders are used to provide data on demand to controls. For very
large data sets use a PagingDataProvider
instead. See the section large data sets for
details.
<html> <head> $headElements </head> <body> $table $jsElements </body> </html>
public LineItemsPage() { Table table = new Table("table"); table.setClass(Table.CLASS_SIMPLE); .. }An alternative method of specifying the table class to use globally for your application is to define a table-default-class message property in your applications click-pages.properties file. For example:
table-default-class=blue2
setPageSize(int)
and
optionally make the Table Banner visible: setShowBanner(boolean)
.
Table supports rendering different paginators through the method
setPaginator
.
The default Table Paginator is TablePaginator
.
setSortable(boolean)
.
controlLink
.
For example:
public CompanyPage extends BorderPage { // companyId is the criteria used to limit Table rows to clients from // the specified company. This variable could be selected from a drop // down list or similar means. public String companyId; public Table table = new Table(); public onInit() { // Set the companyId on the table's controlLink. If you view the // output rendered by Table note that the companyId parameter // is rendered for each Paging and Sorting link. table.getControlLink().setParameter("companyId", companyId); // Set data provider to populate the table row list from table.setDataProvider(new DataProvider() { public List getData() { return getCompanyDao().getCompanyClients(companyId); } }); } ... }
addRowAttributes(java.util.Map, java.lang.Object, int)
and add custom attributes to the row's attribute Map.
PagingDataProvider
.
A PagingDataProvider has two responsibilities. First, it must load
only those rows to be displayed on the current page e.g. rows 50 - 59.
Second, it must return the total number of rows represented by the
PagingDataProvider.
The Table methods getFirstRow()
, getLastRow()
and getPageSize()
provides the necessary information to limit
the rows to the selected page. For sorting, the Table methods
getSortedColumn()
and isSortedAscending()
provides the
necessary information to sort the data.
Please note: when using a PagingDataProvider, you are responsible
for sorting the data, as the Table does not have access to all the data.
Example usage:
public CustomerPage() { Table table = new Table("table"); table.setPageSize(10); table.setShowBanner(true); table.setSortable(true); table.addColumn(new Column("id")); table.addColumn(new Column("name")); table.addColumn(new Column("investments")); table.setDataProvider(new PagingDataProvider() { public List getData() { int start = table.getFirstRow(); int count = table.getPageSize(); String sortColumn = table.getSortedColumn(); boolean ascending = table.isSortedAscending(); return getCustomerService().getCustomersForPage(start, count, sortColumn, ascending); } public int size() { return getCustomerService().getNumberOfCustomers(); } }); }For a live demonstration see the Large Dataset Demo. See the W3C HTML reference Tables and the W3C CSS reference Tables.
Column
,
Decorator
,
Serialized FormField Summary | |
---|---|
static String |
ASCENDING
The control ActionLink page number parameter name: "ascending". |
protected int |
bannerPosition
The table pagination banner position: [ POSITION_TOP | POSITION_BOTTOM | POSITION_BOTH ]. |
protected String |
caption
The table HTML <caption> element. |
static String |
CLASS_BLUE1
The table CSS style: "blue1". |
static String |
CLASS_BLUE2
The table CSS style: "blue2". |
static String |
CLASS_COMPLEX
The table CSS style: "complex". |
static String |
CLASS_ISI
The table CSS style: "isi". |
static String |
CLASS_ITS
The table CSS style: "its". |
static String |
CLASS_MARS
The table CSS style: "mars". |
static String |
CLASS_NOCOL
The table CSS style: "nocol". |
static String |
CLASS_ORANGE1
The table CSS style: "orange1". |
static String |
CLASS_ORANGE2
The table CSS style: "orange2". |
static String |
CLASS_REPORT
The table CSS style: "report". |
static String |
CLASS_SIMPLE
The table CSS style: "simple". |
static String[] |
CLASS_STYLES
The array of pre-defined table CSS class styles. |
static String |
COLUMN
The control ActionLink sorted column parameter name: "column". |
protected List<Column> |
columnList
The list of table Columns. |
protected Map<String,Column> |
columns
The map of table columns keyed by column name. |
protected ActionLink |
controlLink
The table paging and sorting control action link. |
protected List<Control> |
controlList
The list of table controls. |
protected DataProvider |
dataProvider
The table data provider. |
protected String |
height
The table HTML <td> height attribute. |
protected boolean |
hoverRows
The table rows set 'hover' CSS class on mouseover events flag. |
protected boolean |
nullifyRowListOnDestroy
Deprecated. stateful pages are not supported anymore, use stateful Controls instead |
static String |
PAGE
The control ActionLink page number parameter name: "page". |
protected int |
pageNumber
The currently displayed page number. |
protected int |
pageSize
The maximum page size in rows. |
protected Renderable |
paginator
The paginator used to render the table pagination controls. |
static int |
PAGINATOR_ATTACHED
The attached style pagination banner position. |
static int |
PAGINATOR_DETACHED
The detached style pagination banner position. |
static int |
PAGINATOR_INLINE
The attached style pagination banner position. |
protected int |
paginatorAttachment
The paginator attachment style: [ PAGINATOR_ATTACHED | PAGINATOR_DETACHED | PAGINATOR_INLINE ]. |
static int |
POSITION_BOTH
The table top and bottom pagination banner position. |
static int |
POSITION_BOTTOM
The table bottom pagination banner position. |
static int |
POSITION_TOP
The table top pagination banner position. |
protected boolean |
renderId
The default column render id attribute status. |
protected int |
rowCount
The total possible number of rows of the table. |
protected List |
rowList
The list Table rows. |
protected boolean |
showBanner
The show table banner flag detailing number of rows and current rows displayed. |
static String |
SORT
The control ActionLink sort number parameter name: "sort". |
protected boolean |
sortable
The default column are sortable status. |
protected boolean |
sorted
The row list is sorted status. |
protected boolean |
sortedAscending
The rows list is sorted in ascending order. |
protected String |
sortedColumn
The name of the sorted column. |
protected String |
width
The table HTML <td> width attribute. |
Fields inherited from class org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.click.Control |
---|
CONTROL_MESSAGES |
Constructor Summary | |
---|---|
Table()
Create a Table with no name defined. |
|
Table(String name)
Create an Table for the given name. |
Method Summary | |
---|---|
Control |
add(Control control)
Add the given Control to the table. |
Column |
addColumn(Column column)
Add the column to the table. |
Control |
addControl(Control control)
Deprecated. use add(org.apache.click.Control) instead |
protected void |
addRowAttributes(Map<String,String> attributes,
Object row,
int rowIndex)
Override this method to set HTML attributes for each Table row. |
protected List<Object> |
createRowList()
Create a new table row list. |
int |
getBannerPosition()
Return the Table pagination banner position. |
String |
getCaption()
Return the content of the table <caption> element, or null if not defined. |
Column |
getColumn(String name)
Return the Column for the given name. |
List<Column> |
getColumnList()
Return the list of table columns. |
Map<String,Column> |
getColumns()
Return the Map of table Columns, keyed on column name. |
ActionLink |
getControlLink()
Return the table paging and sorting control action link. |
List<Control> |
getControls()
Return the list of Controls added to the table. |
int |
getControlSizeEst()
Return the estimated rendered control size in characters. |
DataProvider |
getDataProvider()
Return the table row list DataProvider. |
int |
getFirstRow()
Return the index of the first row to display. |
List<Element> |
getHeadElements()
Return the Table HTML HEAD elements for the following resource: click/table.css Additionally, the HEAD elements of the getControlLink() will
also be returned. |
String |
getHeight()
Return the table HTML <td> height attribute. |
boolean |
getHoverRows()
Return true if the table row (<tr>) elements should have the class="hover" attribute set on JavaScript mouseover events. |
int |
getLastRow()
Return the index of the last row to display. |
boolean |
getNullifyRowListOnDestroy()
Return true if the Table will nullify the rowList when the onDestroy() method is invoked. |
int |
getNumberPages()
Return the number of pages to display. |
int |
getPageNumber()
Return the currently displayed page number. |
int |
getPageSize()
Return the maximum page size in rows. |
Renderable |
getPaginator()
Return the paginator for rendering the table pagination. |
int |
getPaginatorAttachment()
Return the paginator attachment style. |
boolean |
getRenderId()
Returns the column render id attribute status. |
int |
getRowCount()
The total possible number of rows of the table. |
List |
getRowList()
Return the list of table rows. |
boolean |
getShowBanner()
Return the show Table banner flag detailing number of rows and current rows displayed. |
boolean |
getSortable()
Return the table default column are sortable status. |
String |
getSortedColumn()
Return the name of the sorted column, or null if not defined. |
Object |
getState()
Return the Table state. |
String |
getTag()
Return the table's html tag: table. |
String |
getWidth()
Return the table HTML <td> width attribute. |
boolean |
hasControls()
Return true if the table has any controls defined. |
boolean |
isSorted()
Return the sorted status of the table row list. |
boolean |
isSortedAscending()
Return true if the sort order is ascending. |
void |
onDestroy()
This method will clear the rowList, if the property nullifyRowListOnDestroy is true, set the sorted flag to false and will invoke the onDestroy() method of any child controls. |
void |
onInit()
Initialize the controls contained in the Table. |
boolean |
onProcess()
Process any Table paging control requests, and process any added Table Controls. |
void |
onRender()
This method invokes getRowList() to ensure exceptions thrown
while retrieving table rows will be handled by the error page. |
void |
removeColumn(Column column)
Remove the given Column from the table. |
void |
removeColumn(String name)
Remove the named column from the Table. |
void |
removeColumns(List<String> columnNames)
Remove the list of named columns from the table. |
void |
removeState(Context context)
Remove the Table state from the session for the given request context. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the Table. |
protected void |
renderBodyNoRows(HtmlStringBuffer buffer)
Render the table body content if no rows are in the row list. |
protected void |
renderBodyRowColumns(HtmlStringBuffer buffer,
int rowIndex)
Render the current table body row cells. |
protected void |
renderBodyRows(HtmlStringBuffer buffer)
Render the table body rows for each of the rows in getRowList. |
protected void |
renderFooterRow(HtmlStringBuffer buffer)
Render the table header footer row. |
protected void |
renderHeaderRow(HtmlStringBuffer buffer)
Render the table header row of column names. |
protected void |
renderPaginator(HtmlStringBuffer buffer)
Render the table pagination display. |
protected void |
renderPagingControls(HtmlStringBuffer buffer)
Deprecated. use renderPaginator(HtmlStringBuffer) instead, this
method is provided to support backward compatibility older Click 1.4
customized tables. In these scenarios please override renderPaginator(HtmlStringBuffer)
method to invoke renderTableBanner(HtmlStringBuffer) and renderPagingControls(HtmlStringBuffer) . |
protected void |
renderTableBanner(HtmlStringBuffer buffer)
Deprecated. use renderPaginator(HtmlStringBuffer) instead, this
method is provided to support backward compatibility older Click 1.4
customized tables. In these scenarios please override renderPaginator(HtmlStringBuffer)
method to invoke renderTableBanner(HtmlStringBuffer) and renderPagingControls(HtmlStringBuffer) . |
void |
restoreState(Context context)
Restore the Table state from the session for the given request context. |
void |
saveState(Context context)
Save the Table state to the session for the given request context. |
void |
setBannerPosition(int value)
Set Table pagination banner position. |
void |
setCaption(String caption)
Set the content of the table <caption> element. |
void |
setClass(String value)
Set the HTML class attribute. |
void |
setDataProvider(DataProvider dataProvider)
Set the table row list DataProvider . |
void |
setHeight(String value)
Set the table HTML <td> height attribute. |
void |
setHoverRows(boolean hoverRows)
Set whether the table row (<tr>) elements should have the class="hover" attribute set on JavaScript mouseover events. |
void |
setName(String name)
Set the name of the Control. |
void |
setNullifyRowListOnDestroy(boolean value)
Set the flag to nullify the rowList when the onDestroy() method is invoked. |
void |
setPageNumber(int pageNumber)
Set the currently displayed page number. |
void |
setPageSize(int pageSize)
Set the maximum page size in rows. |
void |
setPaginator(Renderable value)
Set the paginator for rendering the table pagination controls. |
void |
setPaginatorAttachment(int value)
Set Table pagination attachment style. |
void |
setParent(Object parent)
Set the parent of the Table. |
void |
setRenderId(boolean renderId)
Set the column render id attribute status. |
void |
setRowList(List rowList)
Set the list of table rows. |
void |
setShowBanner(boolean showBanner)
Set the show Table banner flag detailing number of rows and current rows displayed. |
void |
setSortable(boolean sortable)
Set the table default column are sortable status. |
void |
setSorted(boolean value)
Set the sorted status of the table row list. |
void |
setSortedAscending(boolean ascending)
Set the ascending sort order status. |
void |
setSortedColumn(String columnName)
Set the name of the sorted column, or null if not defined. |
void |
setState(Object state)
Set the Table state. |
void |
setWidth(String value)
Set the table HTML <td> width attribute. |
protected void |
sortRowList()
The default row list sorting method, which will sort the row list based on the selected column if the row list is not already sorted. |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getId, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setListener, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int PAGINATOR_ATTACHED
public static final int PAGINATOR_DETACHED
public static final int PAGINATOR_INLINE
public static final int POSITION_TOP
public static final int POSITION_BOTTOM
public static final int POSITION_BOTH
public static final String ASCENDING
public static final String COLUMN
public static final String PAGE
public static final String SORT
public static final String CLASS_BLUE1
public static final String CLASS_BLUE2
public static final String CLASS_COMPLEX
public static final String CLASS_ISI
public static final String CLASS_ITS
public static final String CLASS_MARS
public static final String CLASS_NOCOL
public static final String CLASS_ORANGE1
public static final String CLASS_ORANGE2
public static final String CLASS_REPORT
public static final String CLASS_SIMPLE
public static final String[] CLASS_STYLES
protected int bannerPosition
protected String caption
protected Map<String,Column> columns
protected List<Column> columnList
protected ActionLink controlLink
protected List<Control> controlList
protected String height
protected DataProvider dataProvider
protected int rowCount
rowList
,
indicating that some rows have not been loaded yet.
protected boolean hoverRows
protected boolean nullifyRowListOnDestroy
setNullifyRowListOnDestroy(boolean)
protected int pageNumber
protected int pageSize
protected Renderable paginator
protected int paginatorAttachment
protected boolean renderId
protected List rowList
onDestroy()
method at the end of each request.
protected boolean showBanner
protected boolean sortable
protected boolean sorted
protected boolean sortedAscending
protected String sortedColumn
protected String width
Constructor Detail |
---|
public Table(String name)
name
- the table name
IllegalArgumentException
- if the name is nullpublic Table()
Method Detail |
---|
public String getTag()
getTag
in class AbstractControl
AbstractControl.getTag()
public void setParent(Object parent)
setParent
in interface Control
setParent
in class AbstractControl
parent
- the parent of the Table
IllegalStateException
- if AbstractControl.name
is not defined
IllegalArgumentException
- if the given parent instance is
referencing this object: if (parent == this)Control.setParent(Object)
public int getBannerPosition()
public void setBannerPosition(int value)
value
- the table pagination banner positionpublic String getCaption()
public void setCaption(String caption)
caption
- the content of the caption element.public void setClass(String value)
value
- the HTML class attributepublic Column addColumn(Column column)
columns
Map using its name.
column
- the column to add to the table
IllegalArgumentException
- if the table already contains a column
with the same name, or the column name is not definedpublic void removeColumn(Column column)
column
- the column to remove from the tablepublic void removeColumn(String name)
name
- the name of the column to remove from the tablepublic void removeColumns(List<String> columnNames)
columnNames
- the list of column names to remove from the tablepublic boolean getNullifyRowListOnDestroy()
public void setNullifyRowListOnDestroy(boolean value)
value
- the flag value to nullify the table rowList when onDestroy
is calledpublic Column getColumn(String name)
name
- the name of the column to return
public List<Column> getColumnList()
public Map<String,Column> getColumns()
public Control addControl(Control control)
add(org.apache.click.Control)
instead
control
- the Control to add to the table
public Control add(Control control)
control
- the Control to add to the table
public List<Control> getControls()
public boolean hasControls()
public ActionLink getControlLink()
public DataProvider getDataProvider()
public void setDataProvider(DataProvider dataProvider)
DataProvider
.
The Table will retrieve its data from the DataProvider on demand.
Please note: setting the dataProvider will nullify the table
rowList
.
Example usage:
public CustomerPage() { Table table = new Table("table"); table.addColumn(new Column("id")); table.addColumn(new Column("name")); table.addColumn(new Column("investments")); table.setDataProvider(new DataProvider() { public List getData() { return getCustomerService().getCustomers(); } }); }For large data sets use a
PagingDataProvider
instead.
The Table methods getFirstRow()
, getLastRow()
and getPageSize()
provides the necessary information to limit
the rows to the selected page. For sorting, the Table methods
getSortedColumn()
and isSortedAscending()
provides the
necessary information to sort the data.
Please note: when using a PagingDataProvider, you are responsible
for sorting the data, as the Table does not have access to all the data.
Example usage:
public CustomerPage() { Table table = new Table("table"); table.setPageSize(10); table.setShowBanner(true); table.setSortable(true); table.addColumn(new Column("id")); table.addColumn(new Column("name")); table.addColumn(new Column("investments")); table.setDataProvider(new PagingDataProvider() { public List getData() { int start = table.getFirstRow(); int count = table.getPageSize(); String sortColumn = table.getSortedColumn(); boolean ascending = table.isSortedAscending(); return getCustomerService().getCustomersForPage(start, count, sortColumn, ascending); } public int size() { return getCustomerService().getNumberOfCustomers(); } }); }
dataProvider
- the table row list DataProvidersetRowList(java.util.List)
public String getHeight()
public void setHeight(String value)
value
- the table HTML <td> height attributepublic boolean getHoverRows()
public void setHoverRows(boolean hoverRows)
hover:hover { color: navy }
hoverRows
- specify whether class 'hover' rows attribute is rendered
(default false).public List<Element> getHeadElements()
getControlLink()
will
also be returned.
getHeadElements
in interface Control
getHeadElements
in class AbstractControl
Control.getHeadElements()
public void setName(String name)
Control
setName
in interface Control
setName
in class AbstractControl
name
- of the control
IllegalArgumentException
- if the name is nullControl.setName(String)
public int getNumberPages()
public int getPageNumber()
public void setPageNumber(int pageNumber)
pageNumber
- set the currently displayed page numberpublic int getPageSize()
public Renderable getPaginator()
public void setPaginator(Renderable value)
value
- the table paginator to setpublic int getPaginatorAttachment()
public void setPaginatorAttachment(int value)
value
- the table pagination attachment stylepublic void setPageSize(int pageSize)
pageSize
- the maximum page size in rowspublic boolean getRenderId()
public void setRenderId(boolean renderId)
renderId
- set the column render id attribute statuspublic List getRowList()
onDestroy()
method at the end of each request.
If the rowList is null, this method delegates to createRowList()
to create a new row list.
public void setRowList(List rowList)
setDataProvider(org.apache.click.dataprovider.DataProvider)
instead.
Please note the rowList is cleared in table onDestroy()
method
at the end of each request.
rowList
- the list of table rows to setpublic boolean getShowBanner()
public void setShowBanner(boolean showBanner)
showBanner
- the show Table banner flagpublic boolean getSortable()
public void setSortable(boolean sortable)
sortable
- the table default column are sortable statuspublic boolean isSorted()
public void setSorted(boolean value)
value
- the sorted status to setpublic boolean isSortedAscending()
public void setSortedAscending(boolean ascending)
ascending
- the ascending sort order statuspublic String getSortedColumn()
public void setSortedColumn(String columnName)
columnName
- the name of the sorted columnpublic Object getState()
getState
in interface Stateful
public void setState(Object state)
setState
in interface Stateful
state
- the Table state to setpublic String getWidth()
public void setWidth(String value)
value
- the table HTML <td> width attributepublic final int getRowCount()
rowList
,
indicating that some rows have not been loaded yet.
This property is automatically set by the table to the appropriate value.
public int getFirstRow()
page size
must be set for this
method to correctly calculate the first row, otherwise this method will
return 0.
public int getLastRow()
row list
and
page size
must be set for this method to
correctly calculate the last row, otherwise this method will return 0.
public void onInit()
onInit
in interface Control
onInit
in class AbstractControl
Control.onInit()
public void onRender()
getRowList()
to ensure exceptions thrown
while retrieving table rows will be handled by the error page.
onRender
in interface Control
onRender
in class AbstractControl
Control.onRender()
public boolean onProcess()
onProcess
in interface Control
onProcess
in class AbstractControl
Control.onProcess()
public void onDestroy()
onDestroy
in interface Control
onDestroy
in class AbstractControl
Control.onDestroy()
public int getControlSizeEst()
AbstractControl
getControlSizeEst
in class AbstractControl
AbstractControl.getControlSizeEst()
public void render(HtmlStringBuffer buffer)
render
in interface Control
render
in class AbstractControl
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
public void removeState(Context context)
context
- the request contextsaveState(org.apache.click.Context)
,
restoreState(org.apache.click.Context)
public void restoreState(Context context)
setState(java.lang.Object)
to set the
table restored state.
context
- the request contextsaveState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
public void saveState(Context context)
getState()
to retrieve the table state
to save.
context
- the request contextrestoreState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
protected List<Object> createRowList()
dataProvider
is specified the new row list will be populated from the data provider.
protected void renderHeaderRow(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render the header row inprotected void renderBodyRows(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render the table body rows inprotected void addRowAttributes(Map<String,String> attributes, Object row, int rowIndex)
public CompanyPage extends BorderPage { public void onInit() { table = new Table() { public void addRowAttributes(Map attributes, Object row, int rowIndex) { Customer customer = (Customer) row; if (customer.isDisabled()) { // Set the row class to disabled. CSS can then be used // to set disabled rows background to a different color. attributes.put("class", "disabled"); } attributes.put("onclick", "alert('you clicked on row " + rowIndex + "')"); } }; } }Please note that in order to enable alternate background colors for rows, Click will automatically add a CSS class attribute to each row with a value of either odd or even. You are free to add other CSS class attributes as illustrated in the example above.
attributes
- the row attributesrow
- the domain object currently being renderedrowIndex
- the rows indexprotected void renderFooterRow(HtmlStringBuffer buffer)
private Table table; public void onInit() { table = new Table("table") { public void renderFooterRow(HtmlStringBuffer buffer) { double totalHoldings = getCustomerService().getTotalHoldings(customers); renderTotalHoldingsFooter(buffer); }; } addControl(table); ... } ... public void renderTotalHoldingsFooter(HtmlStringBuffer buffer,) { double total = 0; for (int i = 0; i < table.getRowList().size(); i++) { Customer customer = (Customer) table.getRowList().get(i); if (customer.getHoldings() != null) { total += customer.getHoldings().doubleValue(); } } String format = "<b>Total Holdings</b>: ${0,number,#,##0.00}"; String totalDisplay = MessageFormat.format(format, new Object[] { new Double(total) }); buffer.append("<foot><tr><td colspan='4' style='text-align:right'>"); buffer.append(totalDisplay); buffer.append("</td></tr></tfoot>"); }
buffer
- the StringBuffer to render the footer row inprotected void renderBodyRowColumns(HtmlStringBuffer buffer, int rowIndex)
buffer
- the StringBuffer to render the table row cells inrowIndex
- the 0-based index in tableRows to renderprotected void renderBodyNoRows(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render the no row message toprotected void renderPaginator(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render the pagination display toprotected void renderTableBanner(HtmlStringBuffer buffer)
renderPaginator(HtmlStringBuffer)
instead, this
method is provided to support backward compatibility older Click 1.4
customized tables. In these scenarios please override renderPaginator(HtmlStringBuffer)
method to invoke renderTableBanner(HtmlStringBuffer)
and renderPagingControls(HtmlStringBuffer)
.
buffer
- the StringBuffer to render the paging controls toprotected void renderPagingControls(HtmlStringBuffer buffer)
renderPaginator(HtmlStringBuffer)
instead, this
method is provided to support backward compatibility older Click 1.4
customized tables. In these scenarios please override renderPaginator(HtmlStringBuffer)
method to invoke renderTableBanner(HtmlStringBuffer)
and renderPagingControls(HtmlStringBuffer)
.
buffer
- the StringBuffer to render the paging controls toprotected void sortRowList()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |