You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2004/01/24 16:41:31 UTC
cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model ITablePagingState.java
mindbridge 2004/01/24 07:41:31
Modified: contrib/src/org/apache/tapestry/contrib/table/components
AbstractTableRowComponent.java TableFormRows.java
TableRows.jwc TableFormPages.jwc Table.jwc
TableFormPages.java Table.java FormTable.java
TableValues.java TablePages.java TableValues.jwc
TablePages.jwc TableColumns.java TableFormRows.jwc
AbstractTableViewComponent.java FormTable.jwc
TableRows.java TableView.java TableColumns.jwc
contrib/src/org/apache/tapestry/contrib/table/model
ITablePagingState.java
Log:
Applying comments from Erik Hatcher and adding some more docs
Revision Changes Path
1.5 +5 -0 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/AbstractTableRowComponent.java
Index: AbstractTableRowComponent.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/AbstractTableRowComponent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractTableRowComponent.java 19 Jan 2004 21:34:25 -0000 1.4
+++ AbstractTableRowComponent.java 24 Jan 2004 15:41:30 -0000 1.5
@@ -60,7 +60,12 @@
import org.apache.tapestry.contrib.table.model.ITableRowSource;
/**
+ * The base implementation for a component that is wrapped by
+ * the TableRows component. Provides a utility method for getting
+ * a pointer to TableRows.
+ *
* @author mindbridge
+ * @version $Id$
*
*/
public class AbstractTableRowComponent extends AbstractTableViewComponent
1.5 +24 -34 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.java
Index: TableFormRows.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TableFormRows.java 19 Jan 2004 21:34:25 -0000 1.4
+++ TableFormRows.java 24 Jan 2004 15:41:30 -0000 1.5
@@ -79,37 +79,10 @@
* You can define columns manually within, or
* you can use {@link org.apache.tapestry.contrib.table.components.TableValues}
* to generate the columns automatically.
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
*
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>row</td>
- * <td>Object</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The value object of the current row.</td>
- * </tr>
- *
- * <tr>
- * <td>element</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td>tr</td>
- * <td align="left">The tag to use to wrap the rows in.</td>
- * </tr>
- *
- * </table>
+ * [<a href="../../../../../../../ComponentReference/contrib.TableFormRows.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
@@ -121,7 +94,12 @@
public abstract IPrimaryKeyConvertor getConvertorCache();
public abstract void setConvertorCache(IPrimaryKeyConvertor convertor);
public abstract Map getConvertedValues();
-
+
+ /**
+ * Returns the PK convertor cached within the realm of the current request cycle.
+ *
+ * @return the cached PK convertor
+ */
public IPrimaryKeyConvertor getCachedConvertor()
{
IPrimaryKeyConvertor objConvertor = getConvertorCache();
@@ -133,7 +111,13 @@
return objConvertor;
}
-
+
+ /**
+ * Get the list of all table rows to be displayed on this page, converted
+ * using the PK.convertor.
+ *
+ * @return an iterator of all converted table rows
+ */
public Iterator getConvertedTableRowsIterator()
{
final Iterator objTableRowsIterator = getTableRowsIterator();
@@ -163,7 +147,13 @@
}
};
}
-
+
+ /**
+ * Sets the current table row PK and invokes {@link #setTableRow(Object)} as a result.
+ * This method is for internal use only.
+ *
+ * @param objConvertedTableRow The current converted table row (PK)
+ */
public void setConvertedTableRow(Object objConvertedTableRow)
{
Object objValue = objConvertedTableRow;
1.3 +12 -10 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableRows.jwc
Index: TableRows.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableRows.jwc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TableRows.jwc 1 Jun 2003 05:05:10 -0000 1.2
+++ TableRows.jwc 24 Jan 2004 15:41:30 -0000 1.3
@@ -8,30 +8,32 @@
allow-body="yes" allow-informal-parameters="yes">
<description>
+ A low level Table component that generates the rows of the current page in the table.
+ This component must be wrapped by TableView.
</description>
<parameter name="row"
type="Object"
required="no"
- direction="custom"/>
-
- <parameter name="value"
- type="Object"
- required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The current row being rendered.</description>
+ </parameter>
<parameter name="element"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="auto"
+ default-value="'tr'">
+ <description>The tag to use to wrap the rows in, 'tr' by default.</description>
+ </parameter>
<component id="iterRows" type="Foreach">
<binding name="source" expression="tableRowsIterator"/>
<binding name="value" expression="tableRow"/>
</component>
- <component id="informal" type="InheritInformalAny">
- <binding name="element" expression="element"/>
+ <component id="informal" type="Any" inherit-informal-parameters="yes">
+ <inherited-binding name="element" parameter-name="element"/>
</component>
<component id="wrapped" type="RenderBody"/>
1.3 +11 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.jwc
Index: TableFormPages.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.jwc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TableFormPages.jwc 7 Jan 2004 01:12:59 -0000 1.2
+++ TableFormPages.jwc 24 Jan 2004 15:41:30 -0000 1.3
@@ -8,12 +8,21 @@
allow-body="no" allow-informal-parameters="yes">
<description>
+ A version of TablePages that is designed for operation in a form.
+ It is a low level Table component that renders the pages in the table.
+ This component must be wrapped by TableView.
</description>
<parameter name="pagesDisplayed"
type="int"
required="no"
- direction="custom"/>
+ direction="auto"
+ default-value="7">
+ <description>
+ Determines the maximum number of pages to be displayed in the page list
+ when the table has more than one page.
+ </description>
+ </parameter>
<property-specification name="selectedPage" type="int"/>
1.6 +27 -8 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/Table.jwc
Index: Table.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/Table.jwc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Table.jwc 22 Jan 2004 13:52:51 -0000 1.5
+++ Table.jwc 24 Jan 2004 15:41:30 -0000 1.6
@@ -5,11 +5,13 @@
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.table.components.Table"
- allow-body="no" allow-informal-parameters="yes">
+ allow-body="yes" allow-informal-parameters="yes">
<description>
The main Table component that is implemented using the lower-level
Table components such as TableView and TableRows.
+ The component does not render its body, which makes it a good place
+ to declare Blocks defining the column appearances.
</description>
<parameter name="tableModel"
@@ -66,7 +68,7 @@
</description>
</parameter>
- <parameter name="pagesDisplayed"
+ <parameter name="pagesDisplayed"
type="int"
required="no">
<description>
@@ -97,32 +99,48 @@
<parameter name="arrowUpAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>
+ The image to use to describe a column sorted in an ascending order.
+ </description>
+ </parameter>
<parameter name="arrowDownAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>
+ The image to use to describe a column sorted in a descending order.
+ </description>
+ </parameter>
<parameter name="pagesClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table pages</description>
+ </parameter>
<parameter name="columnsClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table columns</description>
+ </parameter>
<parameter name="rowsClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table rows</description>
+ </parameter>
<parameter name="valuesClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table values</description>
+ </parameter>
<component id="tableElement" type="Any" inherit-informal-parameters="yes">
@@ -139,6 +157,7 @@
<inherited-binding name="source" parameter-name="source"/>
<inherited-binding name="columns" parameter-name="columns"/>
<inherited-binding name="tableSessionStateManager" parameter-name="tableSessionStateManager"/>
+ <inherited-binding name="tableSessionStoreManager" parameter-name="tableSessionStoreManager"/>
<inherited-binding name="columnSettingsContainer" parameter-name="columnSettingsContainer"/>
<static-binding name="element">span</static-binding>
</component>
1.4 +8 -32 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.java
Index: TableFormPages.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TableFormPages.java 19 Jan 2004 21:34:25 -0000 1.3
+++ TableFormPages.java 24 Jan 2004 15:41:30 -0000 1.4
@@ -74,34 +74,10 @@
* <p>
* The component generates a list of pages in the Table centered around the
* current one and allows you to navigate to other pages.
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
*
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>pagesDisplayed</td>
- * <td>int</td>
- * <td>in</td>
- * <td>no</td>
- * <td>7</td>
- * <td align="left">Determines the maximum number of pages to be displayed in the page list
- * when the table has more than one page.
- * <p>For example, if the table has 20 pages, and 10 is the current page,
- * pages from 7 to 13 in the page list will be shown if this parameter has
- * a value of 7.
- * </td>
- * </tr>
- *
- * </table>
- *
+ * [<a href="../../../../../../../ComponentReference/contrib.TableFormPages.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
@@ -204,7 +180,7 @@
}
/**
- * @param i
+ * @param i the current page
*/
public void setCurrentPage(int i)
{
@@ -212,7 +188,7 @@
}
/**
- * @param i
+ * @param i number of all pages to display
*/
public void setPageCount(int i)
{
@@ -220,7 +196,7 @@
}
/**
- * @param i
+ * @param i the first page to display
*/
public void setStartPage(int i)
{
@@ -228,7 +204,7 @@
}
/**
- * @param i
+ * @param i the last page to display
*/
public void setStopPage(int i)
{
1.3 +70 -185 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/Table.java
Index: Table.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/Table.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Table.java 19 Jan 2004 21:34:25 -0000 1.2
+++ Table.java 24 Jan 2004 15:41:30 -0000 1.3
@@ -56,212 +56,97 @@
package org.apache.tapestry.contrib.table.components;
import org.apache.tapestry.BaseComponent;
+import org.apache.tapestry.contrib.table.model.ITableColumn;
import org.apache.tapestry.contrib.table.model.ITableModel;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
/**
* The facade component in the Table family. Table allows you to present
* a sortable and pagable table simply and easily by using only this one component.
+ * Please see the Component Reference for details on how to use this component.
*
* [<a href="../../../../../../../ComponentReference/contrib.Table.html">Component Reference</a>]
*
- * <p>
- * The Table component allows you to manipulate its appearance by allowing you
- * to define the 'class' attributes of its internal elements.
- * If you want to change the structure of the table, however,
- * you can instead build your own using the lower level components
- * {@link TableView}, {@link TablePages}, {@link TableColumns}, {@link TableRows},
- * and {@link TableValues}.
- * <p>
- * The Table component delegates the handling of the table model and related
- * activities to the {@link TableView}, and more detailed information about the
- * process can be found in the documentation of that class.
- *
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>tableModel</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableModel}</td>
- * <td>in</td>
- * <td>yes</td>
- * <td> </td>
- * <td align="left">The TableModel to be used to render the table.
- * This binding is typically used only once at the beginning and then the
- * component stores the model in the session state.
- * <p>If you want the Table to read the model every time you can use
- * a session state manager such as
- * {@link org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager}
- * that will force it to get the TableModel from this binding every time.
- * If you do this, however, you will be responsible for saving the state of
- * the table yourself.
- * <p> You can also call the reset() method to force the Table to abandon
- * its old model and reload a new one.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStateManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}</td>
- * <td align="left">This is the session state manager that will control what part of the
- * table model will be saved in the session state.
- * It is then used to recreate the table model from
- * using what was saved in the session. By default, the
- * {@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}
- * is used, which just saves the entire model into the session.
- * This behaviour may not be appropriate when the data is a lot or it is not
- * {@link java.io.Serializable}.
- * <p> You can use one of the stock implementations of
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}
- * to determine the session state behaviour, or you can just define your own.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStoreManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>null</td>
- * <td align="left">Determines how the session state (returned by the session state manager)
- * will be saved in the session. If this parameter is null, then the state
- * will be saved as a persistent property. If it is not null, then the methods
- * of the interface will be used to save and load the state.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>row</td>
- * <td>Object</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The value object of the current row.</td>
- * </tr>
- *
- * <tr>
- * <td>column</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableColumn}</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The object representing the current column.</td>
- * </tr>
- *
- * <tr>
- * <td>pagesDisplayed</td>
- * <td>int</td>
- * <td>in</td>
- * <td>no</td>
- * <td>7</td>
- * <td align="left">Determines the maximum number of pages to be displayed in the page list
- * when the table has more than one page.
- * <p>For example, if the table has 20 pages, and 10 is the current page,
- * pages from 7 to 13 in the page list will be shown if this parameter has
- * a value of 7.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>arrowUpAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in an ascending order.</td>
- * </tr>
- *
- * <tr>
- * <td>arrowDownAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in a descending order.</td>
- * </tr>
- *
- * <tr>
- * <td>pagesClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table pages.</td>
- * </tr>
- *
- * <tr>
- * <td>columnsClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table columns.</td>
- * </tr>
- *
- * <tr>
- * <td>rowsClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table rows.</td>
- * </tr>
- *
- * <tr>
- * <td>valuesClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table values.</td>
- * </tr>
- *
- * </table>
- *
* @author mindbridge
* @version $Id$
*
*/
public class Table extends BaseComponent implements ITableModelSource
{
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
- */
- public ITableModel getTableModel()
- {
- return getTableView().getTableModel();
- }
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
+ */
+ public ITableModel getTableModel()
+ {
+ return getTableViewComponent().getTableModel();
+ }
/**
+ * Indicates that the table model has changed and it may need to saved.
+ * This method has to be invoked if modifications are made to the model.
+ *
* @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange()
*/
public void fireObservedStateChange()
{
- getTableView().fireObservedStateChange();
+ getTableViewComponent().fireObservedStateChange();
}
- /**
- * Resets the state of the component and forces it to load a new
+ /**
+ * Resets the state of the component and forces it to load a new
* TableModel from the tableModel binding the next time it renders.
- */
- public void reset()
- {
- getTableView().reset();
- }
-
- private TableView getTableView()
- {
- return (TableView) getComponent("tableView");
- }
+ */
+ public void reset()
+ {
+ getTableViewComponent().reset();
+ }
+
+ /**
+ * Returns the currently rendered table column.
+ * You can call this method to obtain the current column.
+ *
+ * @return ITableColumn the current table column
+ */
+ public ITableColumn getTableColumn()
+ {
+ Object objCurrentRow = getTableRow();
+
+ // if the current row is null, then we are most likely rendering TableColumns
+ if (objCurrentRow == null)
+ return getTableColumnsComponent().getTableColumn();
+ else
+ return getTableValuesComponent().getTableColumn();
+ }
+
+ /**
+ * Returns the currently rendered table row or null
+ * if the rows are not rendered at the moment.
+ * You can call this method to obtain the current row.
+ *
+ * @return Object the current table row
+ */
+ public Object getTableRow()
+ {
+ return getTableRowsComponent().getTableRow();
+ }
+
+ protected TableView getTableViewComponent()
+ {
+ return (TableView) getComponent("tableView");
+ }
+
+ protected TableColumns getTableColumnsComponent()
+ {
+ return (TableColumns) getComponent("tableColumns");
+ }
+
+ protected TableRows getTableRowsComponent()
+ {
+ return (TableRows) getComponent("tableRows");
+ }
+
+ protected TableValues getTableValuesComponent()
+ {
+ return (TableValues) getComponent("tableValues");
+ }
}
1.3 +7 -201 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/FormTable.java
Index: FormTable.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/FormTable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FormTable.java 19 Jan 2004 21:34:25 -0000 1.2
+++ FormTable.java 24 Jan 2004 15:41:30 -0000 1.3
@@ -55,219 +55,24 @@
package org.apache.tapestry.contrib.table.components;
-import org.apache.tapestry.BaseComponent;
-import org.apache.tapestry.contrib.table.model.ITableModel;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
/**
- * The facade component in the Table family. Table allows you to present
- * a sortable and pagable table simply and easily by using only this one component.
+ * A modified version of the facade component in the Table family.
+ * FormTable allows you to present a sortable and pagable table
+ * within a form by using only this one component.
*
- * [<a href="../../../../../../../ComponentReference/contrib.Table.html">Component Reference</a>]
- *
- * <p>
- * The Table component allows you to manipulate its appearance by allowing you
- * to define the 'class' attributes of its internal elements.
- * If you want to change the structure of the table, however,
- * you can instead build your own using the lower level components
- * {@link TableView}, {@link TablePages}, {@link TableColumns}, {@link TableRows},
- * and {@link TableValues}.
- * <p>
- * The Table component delegates the handling of the table model and related
- * activities to the {@link TableView}, and more detailed information about the
- * process can be found in the documentation of that class.
- *
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>tableModel</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableModel}</td>
- * <td>in</td>
- * <td>yes</td>
- * <td> </td>
- * <td align="left">The TableModel to be used to render the table.
- * This binding is typically used only once at the beginning and then the
- * component stores the model in the session state.
- * <p>If you want the Table to read the model every time you can use
- * a session state manager such as
- * {@link org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager}
- * that will force it to get the TableModel from this binding every time.
- * If you do this, however, you will be responsible for saving the state of
- * the table yourself.
- * <p> You can also call the reset() method to force the Table to abandon
- * its old model and reload a new one.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStateManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}</td>
- * <td align="left">This is the session state manager that will control what part of the
- * table model will be saved in the session state.
- * It is then used to recreate the table model from
- * using what was saved in the session. By default, the
- * {@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}
- * is used, which just saves the entire model into the session.
- * This behaviour may not be appropriate when the data is a lot or it is not
- * {@link java.io.Serializable}.
- * <p> You can use one of the stock implementations of
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}
- * to determine the session state behaviour, or you can just define your own.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStoreManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>null</td>
- * <td align="left">Determines how the session state (returned by the session state manager)
- * will be saved in the session. If this parameter is null, then the state
- * will be saved as a persistent property. If it is not null, then the methods
- * of the interface will be used to save and load the state.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>row</td>
- * <td>Object</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The value object of the current row.</td>
- * </tr>
- *
- * <tr>
- * <td>column</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableColumn}</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The object representing the current column.</td>
- * </tr>
- *
- * <tr>
- * <td>pagesDisplayed</td>
- * <td>int</td>
- * <td>in</td>
- * <td>no</td>
- * <td>7</td>
- * <td align="left">Determines the maximum number of pages to be displayed in the page list
- * when the table has more than one page.
- * <p>For example, if the table has 20 pages, and 10 is the current page,
- * pages from 7 to 13 in the page list will be shown if this parameter has
- * a value of 7.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>arrowUpAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in an ascending order.</td>
- * </tr>
- *
- * <tr>
- * <td>arrowDownAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in a descending order.</td>
- * </tr>
- *
- * <tr>
- * <td>pagesClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table pages.</td>
- * </tr>
- *
- * <tr>
- * <td>columnsClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table columns.</td>
- * </tr>
- *
- * <tr>
- * <td>rowsClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table rows.</td>
- * </tr>
- *
- * <tr>
- * <td>valuesClass</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The CSS class of the table values.</td>
- * </tr>
- *
- * </table>
+ * [<a href="../../../../../../../ComponentReference/contrib.FormTable.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
*
*/
-public abstract class FormTable extends BaseComponent implements ITableModelSource
+public abstract class FormTable extends Table implements ITableModelSource
{
// parameters
public abstract Object getColumns();
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
- */
- public ITableModel getTableModel()
- {
- return getTableView().getTableModel();
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange()
- */
- public void fireObservedStateChange()
- {
- getTableView().fireObservedStateChange();
- }
-
- /**
- * Resets the state of the component and forces it to load a new
- * TableModel from the tableModel binding the next time it renders.
- */
- public void reset()
- {
- getTableView().reset();
- }
-
- private TableView getTableView()
- {
- return (TableView) getComponent("tableView");
- }
-
/**
* If the columns are defined via a String, make sure they use
* the form-specific column headers.
@@ -279,4 +84,5 @@
objColumns = "*" + objColumns;
return objColumns;
}
+
}
1.4 +37 -84 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableValues.java
Index: TableValues.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableValues.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TableValues.java 19 Jan 2004 21:34:25 -0000 1.3
+++ TableValues.java 24 Jan 2004 15:41:30 -0000 1.4
@@ -58,7 +58,9 @@
import java.util.Iterator;
import org.apache.tapestry.IBinding;
+import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRender;
+import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.table.model.ITableColumn;
import org.apache.tapestry.contrib.table.model.ITableColumnModel;
@@ -73,50 +75,28 @@
* The column values are rendered using the renderer returned by the
* getValueRenderer() method in {@link org.apache.tapestry.contrib.table.model.ITableColumn}.
*
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>element</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td>td</td>
- * <td align="left">The tag to use to wrap the column values in.</td>
- * </tr>
- *
- * <tr>
- * <td>column</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableColumn}</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The object representing the current column.</td>
- * </tr>
- *
- * </table>
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
+ *
+ * [<a href="../../../../../../../ComponentReference/contrib.TableValues.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
*
*/
-public class TableValues extends AbstractTableRowComponent
+public abstract class TableValues extends AbstractTableRowComponent
{
- // Bindings (custom)
- private IBinding m_objElementBinding = null;
- private IBinding m_objColumnBinding = null;
+ // Bindings
+ public abstract IBinding getColumnBinding();
// Transient
private ITableColumn m_objTableColumn;
+ /**
+ * Get the list of all table columns to be displayed.
+ *
+ * @return an iterator of all table columns
+ */
public Iterator getTableColumnIterator()
{
ITableColumnModel objColumnModel =
@@ -124,19 +104,23 @@
return objColumnModel.getColumns();
}
- /**
- * Returns the tableColumn.
- * @return ITableColumn
- */
+ /**
+ * Returns the currently rendered table column.
+ * You can call this method to obtain the current column.
+ *
+ * @return ITableColumn the current table column
+ */
public ITableColumn getTableColumn()
{
return m_objTableColumn;
}
- /**
- * Sets the tableColumn.
- * @param tableColumn The tableColumn to set
- */
+ /**
+ * Sets the currently rendered table column.
+ * This method is for internal use only.
+ *
+ * @param tableColumn The current table column
+ */
public void setTableColumn(ITableColumn tableColumn)
{
m_objTableColumn = tableColumn;
@@ -146,6 +130,11 @@
objColumnBinding.setObject(tableColumn);
}
+ /**
+ * Returns the renderer to be used to generate the appearance of the current column
+ *
+ * @return the value renderer of the current column
+ */
public IRender getTableValueRenderer()
{
Object objRow = getTableRowSource().getTableRow();
@@ -156,50 +145,14 @@
}
/**
- * Returns the elementBinding.
- * @return IBinding
+ * @see org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
*/
- public IBinding getElementBinding()
+ protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
- return m_objElementBinding;
- }
+ super.renderComponent(writer, cycle);
- /**
- * Sets the elementBinding.
- * @param elementBinding The elementBinding to set
- */
- public void setElementBinding(IBinding elementBinding)
- {
- m_objElementBinding = elementBinding;
- }
-
- /**
- * Returns the columnBinding.
- * @return IBinding
- */
- public IBinding getColumnBinding()
- {
- return m_objColumnBinding;
+ // set the current column to null when the component is not active
+ m_objTableColumn = null;
}
- /**
- * Sets the columnBinding.
- * @param columnBinding The columnBinding to set
- */
- public void setColumnBinding(IBinding columnBinding)
- {
- m_objColumnBinding = columnBinding;
- }
-
- /**
- * Returns the element.
- * @return String
- */
- public String getElement()
- {
- IBinding objElementBinding = getElementBinding();
- if (objElementBinding == null || objElementBinding.getObject() == null)
- return "td";
- return objElementBinding.getString();
- }
}
1.4 +6 -59 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TablePages.java
Index: TablePages.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TablePages.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TablePages.java 19 Jan 2004 21:34:25 -0000 1.3
+++ TablePages.java 24 Jan 2004 15:41:30 -0000 1.4
@@ -55,7 +55,6 @@
package org.apache.tapestry.contrib.table.components;
-import org.apache.tapestry.IBinding;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
import org.apache.tapestry.util.ComponentAddress;
@@ -66,74 +65,22 @@
* <p>
* The component generates a list of pages in the Table centered around the
* current one and allows you to navigate to other pages.
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
*
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>pagesDisplayed</td>
- * <td>int</td>
- * <td>in</td>
- * <td>no</td>
- * <td>7</td>
- * <td align="left">Determines the maximum number of pages to be displayed in the page list
- * when the table has more than one page.
- * <p>For example, if the table has 20 pages, and 10 is the current page,
- * pages from 7 to 13 in the page list will be shown if this parameter has
- * a value of 7.
- * </td>
- * </tr>
- *
- * </table>
- *
+ * [<a href="../../../../../../../ComponentReference/contrib.TablePages.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
*
*/
-public class TablePages extends AbstractTableViewComponent
+public abstract class TablePages extends AbstractTableViewComponent
{
- private final static int DEFAULT_PAGE_COUNT = 7;
-
// Bindings
- private IBinding m_objPagesDisplayedBinding = null;
+ public abstract int getPagesDisplayed();
// Transient
private int m_nDisplayPage;
-
- /**
- * Returns the PagesDisplayedBinding.
- * @return IBinding
- */
- public IBinding getPagesDisplayedBinding()
- {
- return m_objPagesDisplayedBinding;
- }
-
- /**
- * Sets the PagesDisplayedBinding.
- * @param PagesDisplayedBinding The PagesDisplayedBinding to set
- */
- public void setPagesDisplayedBinding(IBinding PagesDisplayedBinding)
- {
- m_objPagesDisplayedBinding = PagesDisplayedBinding;
- }
-
- public int getPagesDisplayed()
- {
- IBinding objBinding = getPagesDisplayedBinding();
- if (objBinding == null || objBinding.getObject() == null)
- return DEFAULT_PAGE_COUNT;
- return objBinding.getInt();
- }
/**
* Returns the displayPage.
1.3 +16 -9 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableValues.jwc
Index: TableValues.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableValues.jwc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TableValues.jwc 1 Jun 2003 05:05:10 -0000 1.2
+++ TableValues.jwc 24 Jan 2004 15:41:30 -0000 1.3
@@ -8,25 +8,32 @@
allow-body="yes" allow-informal-parameters="yes">
<description>
+ A low level Table component that generates the columns for the current row in the table.
+ This component must be wrapped by TableRows.
</description>
- <parameter name="element"
- type="java.lang.String"
- required="no"
- direction="custom"/>
-
<parameter name="column"
type="org.apache.tapestry.contrib.table.model.ITableColumn"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The current column being rendered</description>
+ </parameter>
+
+ <parameter name="element"
+ type="java.lang.String"
+ required="no"
+ direction="auto"
+ default-value="'td'">
+ <description>The tag to use to wrap the values in, 'td' by default.</description>
+ </parameter>
<component id="iterColumns" type="Foreach">
<binding name="source" expression="tableColumnIterator"/>
<binding name="value" expression="tableColumn"/>
</component>
- <component id="informal" type="InheritInformalAny">
- <binding name="element" expression="element"/>
+ <component id="informal" type="Any" inherit-informal-parameters="yes">
+ <inherited-binding name="element" parameter-name="element"/>
</component>
<component id="insertValueRenderer" type="Delegator">
1.5 +10 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TablePages.jwc
Index: TablePages.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TablePages.jwc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TablePages.jwc 29 Dec 2003 00:13:52 -0000 1.4
+++ TablePages.jwc 24 Jan 2004 15:41:30 -0000 1.5
@@ -8,12 +8,20 @@
allow-body="no" allow-informal-parameters="yes">
<description>
+ A low level Table component that renders the pages in the table.
+ This component must be wrapped by TableView.
</description>
<parameter name="pagesDisplayed"
type="int"
required="no"
- direction="custom"/>
+ direction="auto"
+ default-value="7">
+ <description>
+ Determines the maximum number of pages to be displayed in the page list
+ when the table has more than one page.
+ </description>
+ </parameter>
<component id="informal" type="Any" inherit-informal-parameters="yes"/>
1.6 +61 -93 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableColumns.java
Index: TableColumns.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableColumns.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TableColumns.java 19 Jan 2004 21:34:25 -0000 1.5
+++ TableColumns.java 24 Jan 2004 15:41:30 -0000 1.6
@@ -74,55 +74,10 @@
* a header for each one of them using the renderer provided by the
* getColumnRender() method in {@link org.apache.tapestry.contrib.table.model.ITableColumn}.
* The headers are wrapped in 'th' tags by default.
- *
* <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>element</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td>th</td>
- * <td align="left">The tag to use to wrap the column headers.</td>
- * </tr>
- *
- * <tr>
- * <td>column</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableColumn}</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The object representing the current column.</td>
- * </tr>
- *
- * <tr>
- * <td>arrowUpAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in an ascending order.</td>
- * </tr>
- *
- * <tr>
- * <td>arrowDownAsset</td>
- * <td>{@link org.apache.tapestry.IAsset}</td>
- * <td>in</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The image to use to describe a column sorted in a descending order.</td>
- * </tr>
- *
- * </table>
+ * Please see the Component Reference for details on how to use this component.
+ *
+ * [<a href="../../../../../../../ComponentReference/contrib.TableColumns.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
@@ -130,74 +85,87 @@
*/
public abstract class TableColumns extends AbstractTableViewComponent
{
- public static final String TABLE_COLUMN_ARROW_UP_ATTRIBUTE =
+ public static final String TABLE_COLUMN_ARROW_UP_ATTRIBUTE =
"org.apache.tapestry.contrib.table.components.TableColumns.arrowUp";
- public static final String TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE =
+ public static final String TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE =
"org.apache.tapestry.contrib.table.components.TableColumns.arrowDown";
-
- // Transient
- private ITableColumn m_objTableColumn;
// Bindings
public abstract IBinding getColumnBinding();
- public abstract String getElement();
public abstract IAsset getArrowDownAsset();
public abstract IAsset getArrowUpAsset();
+ // Transient
+ private ITableColumn m_objTableColumn = null;
- public Iterator getTableColumnIterator()
- {
- ITableColumnModel objColumnModel =
- getTableModelSource().getTableModel().getColumnModel();
- return objColumnModel.getColumns();
- }
-
- /**
- * Returns the tableColumn.
- * @return ITableColumn
- */
- public ITableColumn getTableColumn()
- {
- return m_objTableColumn;
- }
-
- /**
- * Sets the tableColumn.
- * @param tableColumn The tableColumn to set
- */
- public void setTableColumn(ITableColumn tableColumn)
- {
- m_objTableColumn = tableColumn;
+ /**
+ * Returns the currently rendered table column.
+ * You can call this method to obtain the current column.
+ *
+ * @return ITableColumn the current table column
+ */
+ public ITableColumn getTableColumn()
+ {
+ return m_objTableColumn;
+ }
+
+ /**
+ * Sets the currently rendered table column.
+ * This method is for internal use only.
+ *
+ * @param tableColumn The current table column
+ */
+ public void setTableColumn(ITableColumn tableColumn)
+ {
+ m_objTableColumn = tableColumn;
IBinding objColumnBinding = getColumnBinding();
if (objColumnBinding != null)
objColumnBinding.setObject(tableColumn);
- }
+ }
- public IRender getTableColumnRenderer()
- {
- return getTableColumn().getColumnRenderer(
- getPage().getRequestCycle(),
- getTableModelSource());
- }
+ /**
+ * Get the list of all table columns to be displayed.
+ *
+ * @return an iterator of all table columns
+ */
+ public Iterator getTableColumnIterator()
+ {
+ ITableColumnModel objColumnModel = getTableModelSource().getTableModel().getColumnModel();
+ return objColumnModel.getColumns();
+ }
/**
- * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, IRequestCycle)
- */
- protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
- {
+ * Returns the renderer to be used to generate the header of the current column
+ *
+ * @return the header renderer of the current column
+ */
+ public IRender getTableColumnRenderer()
+ {
+ return getTableColumn().getColumnRenderer(
+ getPage().getRequestCycle(),
+ getTableModelSource());
+ }
+
+ /**
+ * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, IRequestCycle)
+ */
+ protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
+ {
Object oldValueUp = cycle.getAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
Object oldValueDown = cycle.getAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
cycle.setAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE, getArrowUpAsset());
cycle.setAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE, getArrowDownAsset());
- super.renderComponent(writer, cycle);
-
+ super.renderComponent(writer, cycle);
+
cycle.setAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE, oldValueUp);
cycle.setAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE, oldValueDown);
-
- }
+
+ // set the current column to null when the component is not active
+ m_objTableColumn = null;
+ }
}
1.4 +24 -10 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.jwc
Index: TableFormRows.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TableFormRows.jwc 7 Jan 2004 20:29:54 -0000 1.3
+++ TableFormRows.jwc 24 Jan 2004 15:41:30 -0000 1.4
@@ -8,29 +8,43 @@
allow-body="yes" allow-informal-parameters="yes">
<description>
+ A version of the TableRows designed for operation in a form.
+ This is a low level Table component that generates the rows of
+ the current page in the table. Each row is stored as a hidden value
+ in the form, which eliminates the chance of a stale link during rewinding.
+ This component must be wrapped by TableView.
</description>
<parameter name="row"
type="Object"
required="no"
- direction="custom"/>
-
- <parameter name="element"
- type="java.lang.String"
- required="no"
- direction="custom"
- default-value='"tr"'/>
+ direction="custom">
+ <description>The value object of the row currently being rendered.</description>
+ </parameter>
<parameter name="convertor"
type="org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor"
required="no"
direction="auto"
- default-value="null"/>
+ default-value="null">
+ <description>
+ An interface defining how the items iterated upon by this component
+ will be stored in the form as Hidden values. This interface allows only
+ the primary key of the items to be stored, rather than the whole item.
+ </description>
+ </parameter>
+ <parameter name="element"
+ type="java.lang.String"
+ required="no"
+ default-value='"tr"'>
+ <description>The tag to use to wrap the rows in, 'tr' by default.</description>
+ </parameter>
+
<component id="iterRows" type="ListEdit" inherit-informal-parameters="yes">
<binding name="source" expression="convertedTableRowsIterator"/>
<binding name="value" expression="convertedTableRow"/>
- <binding name="element" expression="element"/>
+ <inherited-binding name="element" parameter-name="element"/>
</component>
<property-specification name="convertedValues" type="java.util.Map" initial-value="new java.util.HashMap()"/>
1.5 +5 -0 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/AbstractTableViewComponent.java
Index: AbstractTableViewComponent.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/AbstractTableViewComponent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractTableViewComponent.java 19 Jan 2004 21:34:25 -0000 1.4
+++ AbstractTableViewComponent.java 24 Jan 2004 15:41:30 -0000 1.5
@@ -61,7 +61,12 @@
import org.apache.tapestry.contrib.table.model.ITableModelSource;
/**
+ * The base implementation for a component that is wrapped by
+ * the TableView component. Provides a utility method for getting
+ * a pointer to TableView.
+ *
* @author mindbridge
+ * @version $Id$
*
*/
public class AbstractTableViewComponent extends BaseComponent
1.4 +48 -16 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/FormTable.jwc
Index: FormTable.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/FormTable.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FormTable.jwc 7 Jan 2004 20:29:54 -0000 1.3
+++ FormTable.jwc 24 Jan 2004 15:41:30 -0000 1.4
@@ -5,11 +5,13 @@
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.table.components.FormTable"
- allow-body="no" allow-informal-parameters="yes">
+ allow-body="yes" allow-informal-parameters="yes">
<description>
The main Table component that is implemented using the lower-level
Table components such as TableView and TableRows.
+ The component does not render its body, which makes it a good place
+ to declare Blocks defining the column appearances.
</description>
<parameter name="tableModel"
@@ -57,6 +59,27 @@
</description>
</parameter>
+ <parameter name="columnSettingsContainer"
+ type="org.apache.tapestry.IComponent"
+ required="no"
+ default-value="container">
+ <description>
+ The component where Block and messages are pulled from when using source/columns.
+ </description>
+ </parameter>
+
+ <parameter name="convertor"
+ type="org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor"
+ required="no"
+ direction="auto"
+ default-value="null"/>
+ <description>
+ An interface defining how the items iterated upon by this component
+ will be stored in the form as Hidden values. This interface allows only
+ the primary key of the items to be stored, rather than the whole item.
+ </description>
+ </parameter>
+
<parameter name="pagesDisplayed"
type="int"
required="no">
@@ -88,39 +111,48 @@
<parameter name="arrowUpAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>
+ The image to use to describe a column sorted in an ascending order.
+ </description>
+ </parameter>
<parameter name="arrowDownAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>
+ The image to use to describe a column sorted in a descending order.
+ </description>
+ </parameter>
<parameter name="pagesClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table pages</description>
+ </parameter>
<parameter name="columnsClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table columns</description>
+ </parameter>
<parameter name="rowsClass"
type="java.lang.String"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The CSS class of the table rows</description>
+ </parameter>
<parameter name="valuesClass"
type="java.lang.String"
required="no"
- direction="custom"/>
-
- <parameter name="convertor"
- type="org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor"
- required="no"
- direction="auto"
- default-value="null"
- />
+ direction="custom">
+ <description>The CSS class of the table values</description>
+ </parameter>
<component id="tableElement" type="Any" inherit-informal-parameters="yes">
@@ -137,8 +169,8 @@
<binding name="columns" expression="formColumns"/>
<inherited-binding name="tableSessionStateManager" parameter-name="tableSessionStateManager"/>
<inherited-binding name="tableSessionStoreManager" parameter-name="tableSessionStoreManager"/>
+ <inherited-binding name="columnSettingsContainer" parameter-name="columnSettingsContainer"/>
<static-binding name="element">span</static-binding>
- <binding name="columnSettingsContainer" expression="container"/>
</component>
<component id="tablePages" type="TableFormPages">
1.4 +26 -112 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableRows.java
Index: TableRows.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableRows.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TableRows.java 19 Jan 2004 21:34:25 -0000 1.3
+++ TableRows.java 24 Jan 2004 15:41:30 -0000 1.4
@@ -74,60 +74,28 @@
* you can use {@link org.apache.tapestry.contrib.table.components.TableValues}
* to generate the columns automatically.
*
- * <p>
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>row</td>
- * <td>Object</td>
- * <td>out</td>
- * <td>no</td>
- * <td> </td>
- * <td align="left">The value object of the current row.</td>
- * </tr>
- *
- * <tr>
- * <td>element</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td>tr</td>
- * <td align="left">The tag to use to wrap the rows in.</td>
- * </tr>
- *
- * </table>
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
+ *
+ * [<a href="../../../../../../../ComponentReference/contrib.TableRows.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
*
*/
-public class TableRows extends AbstractTableViewComponent implements ITableRowSource
+public abstract class TableRows extends AbstractTableViewComponent implements ITableRowSource
{
- // Binding
- private IBinding m_objElementBinding = null;
- private IBinding m_objRowBinding = null;
- private IBinding m_objValueBinding = null;
+ // Parameters
+ public abstract IBinding getRowBinding();
// Transient
- private Object m_objTableRow;
-
- public Iterator getTableRowsIterator()
- {
- ITableModel objTableModel = getTableModelSource().getTableModel();
- return objTableModel.getCurrentPageRows();
- }
+ private Object m_objTableRow = null;
/**
- * Returns the tableRow.
- * @return Object
+ * Returns the currently rendered table row.
+ * You can call this method to obtain the current row.
+ *
+ * @return Object the current table row
*/
public Object getTableRow()
{
@@ -135,8 +103,10 @@
}
/**
- * Sets the tableRow.
- * @param tableRow The tableRow to set
+ * Sets the currently rendered table row.
+ * This method is for internal use only.
+ *
+ * @param tableRow The current table row
*/
public void setTableRow(Object tableRow)
{
@@ -145,76 +115,17 @@
IBinding objRowBinding = getRowBinding();
if (objRowBinding != null)
objRowBinding.setObject(tableRow);
-
- IBinding objValueBinding = getValueBinding();
- if (objValueBinding != null)
- objValueBinding.setObject(tableRow);
}
/**
- * Returns the valueBinding.
- * @return IBinding
+ * Get the list of all table rows to be displayed on this page.
+ *
+ * @return an iterator of all table rows
*/
- public IBinding getRowBinding()
- {
- return m_objRowBinding;
- }
-
- /**
- * Sets the valueBinding.
- * @param valueBinding The valueBinding to set
- */
- public void setRowBinding(IBinding valueBinding)
- {
- m_objRowBinding = valueBinding;
- }
-
- /**
- * Returns the valueBinding.
- * @return IBinding
- */
- public IBinding getValueBinding()
- {
- return m_objValueBinding;
- }
-
- /**
- * Sets the valueBinding.
- * @param valueBinding The valueBinding to set
- */
- public void setValueBinding(IBinding valueBinding)
- {
- m_objValueBinding = valueBinding;
- }
-
- /**
- * Returns the elementBinding.
- * @return IBinding
- */
- public IBinding getElementBinding()
- {
- return m_objElementBinding;
- }
-
- /**
- * Sets the elementBinding.
- * @param elementBinding The elementBinding to set
- */
- public void setElementBinding(IBinding elementBinding)
- {
- m_objElementBinding = elementBinding;
- }
-
- /**
- * Returns the element.
- * @return String
- */
- public String getElement()
+ public Iterator getTableRowsIterator()
{
- IBinding objElementBinding = getElementBinding();
- if (objElementBinding == null || objElementBinding.getObject() == null)
- return "tr";
- return objElementBinding.getString();
+ ITableModel objTableModel = getTableModelSource().getTableModel();
+ return objTableModel.getCurrentPageRows();
}
/**
@@ -228,6 +139,9 @@
super.renderComponent(writer, cycle);
cycle.setAttribute(ITableRowSource.TABLE_ROW_SOURCE_ATTRIBUTE, objOldValue);
+
+ // set the current row to null when the component is not active
+ m_objTableRow = null;
}
}
1.7 +40 -93 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableView.java
Index: TableView.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableView.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TableView.java 19 Jan 2004 21:34:25 -0000 1.6
+++ TableView.java 24 Jan 2004 15:41:30 -0000 1.7
@@ -74,6 +74,7 @@
import org.apache.tapestry.contrib.table.model.ITableDataModel;
import org.apache.tapestry.contrib.table.model.ITableModel;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
+import org.apache.tapestry.contrib.table.model.ITablePagingState;
import org.apache.tapestry.contrib.table.model.ITableSessionStateManager;
import org.apache.tapestry.contrib.table.model.ITableSessionStoreManager;
import org.apache.tapestry.contrib.table.model.common.BasicTableModelWrap;
@@ -132,84 +133,10 @@
* </ul>
* <p>
*
- * <table border=1 align="center">
- * <tr>
- * <th>Parameter</th>
- * <th>Type</th>
- * <th>Direction </th>
- * <th>Required</th>
- * <th>Default</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td>tableModel</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableModel}</td>
- * <td>in</td>
- * <td>yes</td>
- * <td> </td>
- * <td align="left">The TableModel to be used to render the table.
- * This binding is typically used only once at the beginning and then the
- * component stores the model in the session state.
- * <p>If you want the Table to read the model every time you can use
- * a session state manager such as
- * {@link org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager}
- * that will force it to get the TableModel from this binding every time.
- * If you do this, however, you will be responsible for saving the state of
- * the table yourself.
- * <p> You can also call the reset() method to force the Table to abandon
- * its old model and reload a new one.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStateManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}</td>
- * <td align="left">This is the session state manager that will control what part of the
- * table model will be saved in the session state.
- * It is then used to recreate the table model from
- * using what was saved in the session. By default, the
- * {@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}
- * is used, which just saves the entire model into the session.
- * This behaviour may not be appropriate when the data is a lot or it is not
- * {@link java.io.Serializable}.
- * <p> You can use one of the stock implementations of
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}
- * to determine the session state behaviour, or you can just define your own.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>tableSessionStoreManager</td>
- * <td>{@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}</td>
- * <td>in</td>
- * <td>no</td>
- * <td>null</td>
- * <td align="left">Determines how the session state (returned by the session state manager)
- * will be saved in the session. If this parameter is null, then the state
- * will be saved as a persistent property. If it is not null, then the methods
- * of the interface will be used to save and load the state.
- * </td>
- * </tr>
- *
- * <tr>
- * <td>element</td>
- * <td>String</td>
- * <td>in</td>
- * <td>no</td>
- * <td>"table"</td>
- * <td align="left">The tag that will be used to wrap the inner components.
- * If no binding is given, the tag that will be generated is 'table'. If you
- * would like to place the bounds of the table elsewhere, you can make the
- * element 'span' or another neutral tag and manually define the table.
- * </td>
- * </tr>
- *
- * </table>
+ * <p>
+ * Please see the Component Reference for details on how to use this component.
*
+ * [<a href="../../../../../../../ComponentReference/contrib.TableView.html">Component Reference</a>]
*
* @author mindbridge
* @version $Id$
@@ -222,9 +149,6 @@
private ITableSessionStateManager m_objDefaultSessionStateManager = null;
private ITableColumnModel m_objColumnModel = null;
- // Persistent properties
- private Serializable m_objSessionState;
-
// Transient objects
private ITableModel m_objTableModel;
private ITableModel m_objCachedTableModelValue;
@@ -265,7 +189,6 @@
*/
private void initialize()
{
- m_objSessionState = null;
m_objTableModel = null;
m_objCachedTableModelValue = null;
}
@@ -459,28 +382,27 @@
}
/**
+ * Ensures that the table state is saved before the render phase begins
+ * in case there are modifications for which {@link #fireObservedStateChange()}
+ * has not been invoked.
+ *
* @see org.apache.tapestry.event.PageRenderListener#pageBeginRender(org.apache.tapestry.event.PageEvent)
*/
public void pageBeginRender(PageEvent event)
{
+ // 'suspenders': save the table model if it has been already loaded.
+ // this means that if a change has been made explicitly in a listener,
+ // it will be saved. this is the last place before committing the changes
+ // where a save can occur
+ if (m_objTableModel != null)
+ saveSessionState();
}
/**
- * Ensures that the table state is saved at the end of the rewind phase
- * in case there are modifications for which {@link #fireObservedStateChange()}
- * has not been invoked.
- *
* @see org.apache.tapestry.event.PageRenderListener#pageEndRender(PageEvent)
*/
public void pageEndRender(PageEvent objEvent)
{
- // ignore if not rewinding
- if (!objEvent.getRequestCycle().isRewinding())
- return;
-
- // Save the session state of the table model
- // This is the moment after changes and right before committing the session
- saveSessionState();
}
/**
@@ -523,6 +445,30 @@
}
/**
+ * Make sure that the values stored in the model are useable and correct.
+ * The changes made here are not saved.
+ */
+ protected void validateValues()
+ {
+ ITableModel objModel = getTableModel();
+
+ // make sure current page is within the allowed range
+ ITablePagingState objPagingState = objModel.getPagingState();
+ int nCurrentPage = objPagingState.getCurrentPage();
+ int nPageCount = objModel.getPageCount();
+ if (nCurrentPage >= nPageCount) {
+ // the current page is greater than the page count. adjust.
+ nCurrentPage = nPageCount - 1;
+ objPagingState.setCurrentPage(nCurrentPage);
+ }
+ if (nCurrentPage < 0) {
+ // the current page is before the first page. adjust.
+ nCurrentPage = 0;
+ objPagingState.setCurrentPage(nCurrentPage);
+ }
+ }
+
+ /**
* Stores a pointer to this component in the Request Cycle while rendering
* so that wrapped components have access to it.
*
@@ -533,6 +479,7 @@
Object objOldValue = cycle.getAttribute(ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE);
cycle.setAttribute(ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE, this);
+ validateValues();
super.renderComponent(writer, cycle);
cycle.setAttribute(ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE, objOldValue);
1.4 +16 -6 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableColumns.jwc
Index: TableColumns.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableColumns.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TableColumns.jwc 7 Jan 2004 20:29:54 -0000 1.3
+++ TableColumns.jwc 24 Jan 2004 15:41:30 -0000 1.4
@@ -8,35 +8,45 @@
allow-body="yes" allow-informal-parameters="yes">
<description>
+ A low level Table component that renders the column headers in the table.
+ This component must be wrapped by TableView.
</description>
<parameter name="column"
type="org.apache.tapestry.contrib.table.model.ITableColumn"
required="no"
- direction="custom"/>
+ direction="custom">
+ <description>The column currently being rendered [out]</description>
+ </parameter>
<parameter name="element"
type="java.lang.String"
required="no"
direction="auto"
- default-value="'th'"/>
+ default-value="'th'">
+ <description>The tag to use to wrap the column headers.</description>
+ </parameter>
<parameter name="arrowUpAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>The image to use to describe a column sorted in an ascending order.</description>
+ </parameter>
<parameter name="arrowDownAsset"
type="org.apache.tapestry.IAsset"
required="no"
- direction="in"/>
+ direction="in">
+ <description>The image to use to describe a column sorted in a descending order.</description>
+ </parameter>
<component id="iterColumns" type="Foreach">
<binding name="source" expression="tableColumnIterator"/>
<binding name="value" expression="tableColumn"/>
</component>
- <component id="informal" type="InheritInformalAny">
+ <component id="informal" type="Any" inherit-informal-parameters="yes">
<binding name="element" expression="element"/>
</component>
1.3 +3 -3 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/ITablePagingState.java
Index: ITablePagingState.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/ITablePagingState.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ITablePagingState.java 19 Jan 2004 21:34:23 -0000 1.2
+++ ITablePagingState.java 24 Jan 2004 15:41:31 -0000 1.3
@@ -78,13 +78,13 @@
void setPageSize(int nPageSize);
/**
- * Method getCurrentPage.
+ * Gets the currently selected page. The page number is counted from 0.
* @return int the current active page
*/
int getCurrentPage();
/**
- * Method setCurrentPage.
+ * Sets the newly selected page. The page number is counted from 0.
* @param nPage the new active page
*/
void setCurrentPage(int nPage);
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org