|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.toolbox.ui.StaticDataQueryBuilder
This class is used to create an implementation of
DataQueryBuilder
that relies on a static
DataQuery.
Example:
Page p = new Page("Data Table Page"); // Build a data query to retrieve all users. String sql = "select users.user_id," + "person_names.given_name, " + "person_names.family_name, " + "parties.primary_email " + "from users, person_names, parties " + "where users.name_id = person_names.name_id " + "and users.user_id = parties.party_id"; String cols[] = {"user_id", "given_name", "family_name", "primary_email"}; DataQueryBuilder dqb = new StaticDataQueryBuilder(sql, cols); DataTable dt = new DataTable(dqb); dt.setEmptyView(new Label(GlobalizationUtil.globalize("toolbox.ui.no_results"))); dt.addColumn("User ID", "user_id", true, new DefaultTableCellRenderer()); dt.addColumn("First Name", "given_name", true, new DefaultTableCellRenderer()); dt.addColumn("Last Name", "family_name", true, new DefaultTableCellRenderer()); dt.addColumn("Email", "primary_email", true, new DefaultTableCellRenderer()); // Put the table on the page and serve. p.add(dt); p.lock(); pm.servePage(p, request, response);
Field Summary | |
static String |
versionId
|
Constructor Summary | |
StaticDataQueryBuilder(DataQuery dq,
String keyColumn)
Creates a DataQueryBuilder that will always return the specified DataQuery and keyColumn. |
|
StaticDataQueryBuilder(String sql,
String[] columns)
Create a StaticDataQueryBuilder that consists of the specified SQL query. |
Method Summary | |
String |
getKeyColumn()
|
boolean |
isLocked()
Return whether an object is locked and thus immutable, or can still be modified. |
void |
lock()
Lock an object. |
DataQuery |
makeDataQuery(DataTable t,
PageState s)
Perform all neccessary database operations and return a DataQuery for the DataTable to use |
void |
setDataQuery(DataQuery dq)
Update the DataQuery returned by makeDataQuery(com.arsdigita.toolbox.ui.DataTable, com.arsdigita.bebop.PageState) to
the specified DataQuery. |
void |
setKeyColumn(String keyColumn)
Update the key column returned by getKeyColumn() to the
the specified key column. |
void |
update(DataQuery dq,
String keyColumn)
A convenience method to update the data query and key column with one call. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public StaticDataQueryBuilder(DataQuery dq, String keyColumn)
dq
- The DataQuery to be returned byt this
DataQueryBuilder.keyColumn
- The primary key column specified in
the DataQuery provided.public StaticDataQueryBuilder(String sql, String[] columns)
sql
- A SQL query.columns
- An array of column names corresponding to the
the columns in the SQL query.Method Detail |
public DataQuery makeDataQuery(DataTable t, PageState s)
DataQuery
for the DataTable
to use
makeDataQuery
in interface DataQueryBuilder
t
- the parent DataTables
- the page statepublic String getKeyColumn()
getKeyColumn
in interface DataQueryBuilder
public void setDataQuery(DataQuery dq)
makeDataQuery(com.arsdigita.toolbox.ui.DataTable, com.arsdigita.bebop.PageState)
to
the specified DataQuery.
public void setKeyColumn(String keyColumn)
getKeyColumn()
to the
the specified key column.
public void update(DataQuery dq, String keyColumn)
public void lock()
Lockable
setXXX
method
should lead to an exception.
Most lockable Bebop classes throw an IllegalStateException
if an attempt is made to modify a
locked instance.
lock
in interface Lockable
public boolean isLocked()
Lockable
isLocked
in interface Lockable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |