|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.TextStylable
com.arsdigita.bebop.BlockStylable
com.arsdigita.bebop.Table
com.arsdigita.toolbox.ui.DataTable
DataQuery
in a sortable Bebop Table
.
The DataQuery
is supplied by the DataQueryBuilder
class,
which the user must implement. The DataQueryBuilder
may
dynamically construct the query during each request, or return the
same named query for each request; the DataTable
does
not care where the query comes from.
This class may contain multiple QueryListener
s. These
listeners will be fired whenever the query is about to
be performed, thus giving the user a chance to set
additional filters on the query.
Columns may be added to the DataTable
by calling the
addColumn(java.lang.String, java.lang.String, boolean, com.arsdigita.bebop.table.TableCellRenderer)
method. The user may choose to make the column
sortable or non-sortable; sortable columns will appear as links
on the Web page which, when clicked, will sort the table by the
specified column. See the documentation on the various
addColumn
methods for more information.
Note that any DomainCollection
can be used with DataTable
, since the
DomainCollection
is merely a wrapper for a DataCollection
, which extends
DataQuery
. The DomainService
class may be used to retieve
the DataCollection
for any given
DomainCollection
.
This class sets the XSL "class" attribute to "dataTable"
DataTable
also
implements PaginationModelBuilder
. This means that
it could serve as the model builder for any Paginator
component. Pagination of the query occurs after all the sorting
and query events have finished. Consider a query which returns
the rows "A B C D E F". If the paginator displays 3 rows per page,
page 1 will contain "A B C" and page 2 will contain "D E F".
If the user then clicks on the header in the DataTable
,
causing the query to be sorted in reverse order, page 1 will
contain "F E D" and page 2 will contain "C B A". In order for
pagination to work properly, the following pattern must
be used:
TheDataTable table = new DataTable(...); Paginator paginator = new Paginator(table, ...); table.setPaginator(paginator);
setPaginator
call is required due to a
design flaw in the Paginator
component.
DataTable
will ordinarily interpret the labels
of its column headers as plain text, and spit them out on
the screen verbatim. However, if setResouceBundle
is called, DataTable
will instead interpret the
column header labels as keys into the specified resource bundle,
thus attempting to globalize the column headers at runtime.
Nested Class Summary | |
protected static class |
DataTable.DataBuilderAdapter
Adapts a DataQueryBuilder into a TableModelBuilder . |
protected static class |
DataTable.DataQueryTableModel
A TableModel which gets its data from a DataQuery. |
protected static class |
DataTable.DataTableColumnModel
A special column model that maintains an alternate key for each column. |
protected static class |
DataTable.GlobalizedHeaderCellRenderer
Always renders the table header as a link. |
static class |
DataTable.SortableTableColumn
A TableColumn that could potentially be sorted |
Nested classes inherited from class com.arsdigita.bebop.Table |
Table.MatrixTableModelBuilder |
Field Summary | |
static String |
ASCENDING
|
static String |
DESCENDING
|
static String |
DIRECTION
|
static String |
ORDER
|
static String |
versionId
|
Fields inherited from class com.arsdigita.bebop.Table |
CELL_EVENT, EMPTY_MODEL, SEP |
Fields inherited from class com.arsdigita.bebop.BlockStylable |
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP |
Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
Fields inherited from interface com.arsdigita.bebop.util.BebopConstants |
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA |
Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
Constructor Summary | |
DataTable(DataQueryBuilder builder)
Construct a new DataTable |
|
DataTable(DataQueryBuilder builder,
SingleSelectionModel orderModel)
Construct a new DataTable. |
|
DataTable(DataQueryBuilder builder,
SingleSelectionModel orderModel,
String resourceBundle)
Construct a new DataTable. |
Method Summary | |
TableColumn |
addColumn(String label,
String attribute)
Add a column to this table. |
TableColumn |
addColumn(String label,
String attribute,
boolean isSortable)
Add a column to this table. |
TableColumn |
addColumn(String label,
String attribute,
boolean isSortable,
TableCellRenderer renderer)
Add a column to this table. |
TableColumn |
addColumn(String label,
String attribute,
boolean isSortable,
TableCellRenderer renderer,
String orderAttribute)
Add a column to this table. |
TableColumn |
addColumn(String label,
TableCellRenderer renderer)
Add a column to this table. |
void |
addQueryListener(QueryListener l)
Add a QueryListener to this table. |
protected void |
fireQueryPending(PageState state,
DataQuery query)
Fire the query event listeners to indicate that a query is about to be performed |
void |
generateExtraXMLAttributes(PageState s,
Element element)
Adds type-specific XML attributes to the XML element representing this link. |
DataQuery |
getDataQuery(PageState s)
Return the DataQuery that will be used during the current
request |
DataQueryBuilder |
getDataQueryBuilder()
|
String |
getDefaultOrder()
Get the key of the default column which will be used to sort the entries |
String |
getOrder(PageState s)
|
String |
getOrderDirection(PageState s)
|
SingleSelectionModel |
getOrderSelectionModel()
|
Paginator |
getPaginator()
Return the paginator component used by this table, or null if the table is not paginated. |
protected RequestLocal |
getQuerySizeLocal()
Return the RequestLocal used for storing the query size during the request |
String |
getResourceBundle()
Return the resource bundle for globalization, or null if no bundle was specified |
int |
getTotalSize(Paginator paginator,
PageState s)
Paginate the query according to the paginator component. |
GlobalizedMessage |
globalize(String key)
Globalizes the specified key. |
void |
lock()
Lock this table |
void |
register(Page p)
Register the ordering parameter |
void |
removeQueryListener(QueryListener l)
Remove a QueryListener from this table. |
void |
setDataQueryBuilder(DataQueryBuilder builder)
|
void |
setDefaultOrder(String attribute)
Set the key of the default column which will be used to sort the entries |
void |
setOrder(PageState s,
String attr)
Set the column by which the table will be ordered |
void |
setOrderDirection(PageState s,
String dir)
Set the sort direction |
void |
setOrderSelectionModel(SingleSelectionModel orderModel)
Set the SingleSelectionModel that will determine the order
for the items in the tabke |
void |
setPaginator(Paginator p)
Set the paginator component used by this table, or null if the table should not be paginated. |
void |
setResourceBundle(String bundle)
Set the resource bundle for globalization, or null if no globalization is needed |
String |
toggleOrderDirection(PageState s)
Toggle the sort direction between ascending and descending |
Methods inherited from class com.arsdigita.bebop.BlockStylable |
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment |
Methods inherited from class com.arsdigita.bebop.TextStylable |
setBackgroundColor, setColor |
Methods inherited from class com.arsdigita.bebop.SimpleComponent |
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.arsdigita.bebop.PaginationModelBuilder |
isVisible |
Field Detail |
public static final String versionId
public static final String ORDER
public static final String DIRECTION
public static final String ASCENDING
public static final String DESCENDING
Constructor Detail |
public DataTable(DataQueryBuilder builder, SingleSelectionModel orderModel, String resourceBundle)
builder
- the DataQueryBuilder
that will be used for
this browserorderModel
- the SingleSelectionModel
that will be used
to determine the column to order byresourceBundle
- the name of the resource bundle that will be
used to globalize the column labels. If null, column labels will
be printed verbatim to the screen.public DataTable(DataQueryBuilder builder, SingleSelectionModel orderModel)
builder
- the DataQueryBuilder
that will be used for
this browserorderModel
- the SingleSelectionModel
that will be used
to determine the column to order bypublic DataTable(DataQueryBuilder builder)
builder
- the DataQueryBuilder
that will be used for
this browserMethod Detail |
public void register(Page p)
register
in interface Component
register
in class Table
p
- the page that contains this tablepublic void setDefaultOrder(String attribute)
attribute
- the default attribute to sort bypublic String getDefaultOrder()
public TableColumn addColumn(String label, String attribute, boolean isSortable, TableCellRenderer renderer)
label
- The user-readable label for the columnattribute
- The name of the attribute in the DataQuery
which will be used as the value for this column.isSortable
- true if it is possible to sort using this column, false
otherwiserenderer
- a TableCellRenderer
that will be used to
format the attribute as a string.
public TableColumn addColumn(String label, String attribute, boolean isSortable, TableCellRenderer renderer, String orderAttribute)
label
- The user-readable label for the columnattribute
- The name of the attribute in the DataQuery
which will be used as the value for this column.isSortable
- true if it is possible to sort using this column, false
otherwiserenderer
- a TableCellRenderer
that will be used to
format the attribute as a string.orderAttribute
- The name of the attribute which will be used
as the column to order by. This key may be different from
the attribute
parameter.
public TableColumn addColumn(String label, String attribute, boolean isSortable)
label
- The user-readable label for the columnattribute
- The name of the attribute in the DataQuery
which will be used as the value for this column.isSortable
- true if it is possible to sort using this column, false
otherwise
public TableColumn addColumn(String label, String attribute)
label
- The user-readable label for the columnattribute
- The name of the attribute in the DataQuery
which will be used as the value for this column.
public TableColumn addColumn(String label, TableCellRenderer renderer)
TableModel
or render it
directly in the TableCellRenderer
. Typically, this method
will be used to add ControlLink
s to the table.
label
- The user-readable label for the columnrenderer
- The cell renderer for the given column
public DataQueryBuilder getDataQueryBuilder()
DataQueryBuilder
that creates
a DataQuery
for this table during each requestpublic void setDataQueryBuilder(DataQueryBuilder builder)
builder
- the new DataQueryBuilder
for this tablepublic void setOrderSelectionModel(SingleSelectionModel orderModel)
SingleSelectionModel
that will determine the order
for the items in the tabke
orderModel
- The new modelpublic SingleSelectionModel getOrderSelectionModel()
SingleSelectionModel
that will determine the orderpublic void addQueryListener(QueryListener l)
QueryListener
to this table. The listener
will be fired whenever the query is about to be performed.
l
- the new query listenerpublic void removeQueryListener(QueryListener l)
QueryListener
from this table.
l
- the new query listenerprotected void fireQueryPending(PageState state, DataQuery query)
state
- The page statequery
- The DataQuery
public void setOrder(PageState s, String attr)
s
- the page stateattr
- the attribute by which the table will be sortedpublic String getOrder(PageState s)
s
- the page state
public String getOrderDirection(PageState s)
s
- the page state
public void setOrderDirection(PageState s, String dir)
s
- the page statedir
- the direction in which the current column
should be sorted; either ASCENDING or DESCENDINGpublic String toggleOrderDirection(PageState s)
s
- the page state
public DataQuery getDataQuery(PageState s)
DataQuery
that will be used during the current
request
s
- the page state for the current request
DataQuery
public int getTotalSize(Paginator paginator, PageState s)
Paginator
component to which this DataTable
has been added
as the model builder.
getTotalSize
in interface PaginationModelBuilder
paginator
- the parent Paginator
s
- the current page state
public final Paginator getPaginator()
public final void setPaginator(Paginator p)
protected final RequestLocal getQuerySizeLocal()
public void lock()
lock
in interface Lockable
lock
in class Table
Lockable.lock()
public void generateExtraXMLAttributes(PageState s, Element element)
Table
generateXML
produces by default.
generateExtraXMLAttributes
in class Table
s
- represents the current requestelement
- the XML element representing this tablepublic GlobalizedMessage globalize(String key)
public String getResourceBundle()
public void setResourceBundle(String bundle)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |