mindbridge    2005/08/14 07:11:09

  Modified:    contrib/src/java/org/apache/tapestry/contrib/table/components
                        TableFormRows.java TableRows.java FormTable.jwc
                        TableRows.jwc TableFormRows.jwc
                        TableColumnModelSourceImpl.java Table.jwc
                        Table.html TableView.java Table.java
               contrib/src/java/org/apache/tapestry/contrib/table/model/simple
                        SimpleTableModel.java
  Added:       contrib/src/java/org/apache/tapestry/contrib/table/model
                        IFullTableModel.java
  Log:
  Making Table automatically form aware -- using more fully the abilities of For
  
  Revision  Changes    Path
  1.5       +1 -1      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableFormRows.java
  
  Index: TableFormRows.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/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        5 Jan 2005 23:17:12 -0000       1.4
  +++ TableFormRows.java        14 Aug 2005 14:11:08 -0000      1.5
  @@ -18,7 +18,7 @@
   import java.util.Map;
   
   import org.apache.tapestry.IRequestCycle;
  -import org.apache.tapestry.contrib.table.model.*;
  +import org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor;
   
   
   /**
  
  
  
  1.6       +40 -0     
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableRows.java
  
  Index: TableRows.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableRows.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableRows.java    5 Jan 2005 23:17:12 -0000       1.5
  +++ TableRows.java    14 Aug 2005 14:11:08 -0000      1.6
  @@ -19,6 +19,7 @@
   import org.apache.tapestry.IBinding;
   import org.apache.tapestry.IMarkupWriter;
   import org.apache.tapestry.IRequestCycle;
  +import org.apache.tapestry.contrib.table.model.IFullTableModel;
   import org.apache.tapestry.contrib.table.model.ITableModel;
   import org.apache.tapestry.contrib.table.model.ITableRowSource;
   
  @@ -44,8 +45,12 @@
   public abstract class TableRows extends AbstractTableViewComponent 
implements ITableRowSource
   {
   
  +     // Parameters
  +     public abstract Object getFullSourceParameter();
  +     
       // Transient
       private Object m_objTableRow = null;
  +    private int m_nTableIndex;
   
       /**
        * Returns the currently rendered table row.
  @@ -74,6 +79,32 @@
       }
   
       /**
  +     * Returns the index of the currently rendered table row.
  +     * You can call this method to obtain the index of the current row.
  +     *  
  +     * @return int the current table index
  +     */
  +    public int getTableIndex()
  +    {
  +        return m_nTableIndex;
  +    }
  +
  +    /**
  +     * Sets the index of the currently rendered table row. 
  +     * This method is for internal use only.
  +     * 
  +     * @param tableIndex The index of the current table row
  +     */
  +    public void setTableIndex(int tableIndex)
  +    {
  +        m_nTableIndex = tableIndex;
  +
  +        IBinding objIndexBinding = getBinding("index");
  +        if (objIndexBinding != null)
  +            objIndexBinding.setObject(new Integer(tableIndex));
  +    }
  +
  +    /**
        * Get the list of all table rows to be displayed on this page.
        * 
        * @return an iterator of all table rows
  @@ -84,6 +115,14 @@
           return objTableModel.getCurrentPageRows();
       }
   
  +    public Object getFullSource()
  +    {
  +        ITableModel objTableModel = getTableModelSource().getTableModel();
  +     if (objTableModel instanceof IFullTableModel)
  +             return ((IFullTableModel) objTableModel).getRows();
  +     return getFullSourceParameter();
  +    }
  +    
       /**
        * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, 
IRequestCycle)
        */
  @@ -100,4 +139,5 @@
           m_objTableRow = null;
       }
   
  +    
   }
  
  
  
  1.8       +29 -76    
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/FormTable.jwc
  
  Index: FormTable.jwc
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/FormTable.jwc,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FormTable.jwc     7 Jul 2005 23:00:39 -0000       1.7
  +++ FormTable.jwc     14 Aug 2005 14:11:08 -0000      1.8
  @@ -16,11 +16,11 @@
   -->
   
   <!DOCTYPE component-specification PUBLIC 
  -  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  -  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
  +    "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
  +    "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
        
   <component-specification 
class="org.apache.tapestry.contrib.table.components.FormTable" 
  -     allow-body="yes" allow-informal-parameters="yes">
  +     allow-body="yes" allow-informal-parameters="yes" deprecated="yes">
   
       <description>
           The main Table component that is implemented using the lower-level 
  @@ -29,10 +29,7 @@
           to declare Blocks defining the column appearances.
       </description>
       
  -    <parameter name="tableModel" 
  -        type="org.apache.tapestry.contrib.table.model.ITableModel" 
  -        property-name="tableModelValue"
  -        required="no">
  +    <parameter name="tableModel" property="tableModelValue">
           <description>
               The model describing the data to be presented by the Table 
component.
               This parameter is optional, but either the 'tableModel' or both
  @@ -40,7 +37,7 @@
           </description>
       </parameter>
       
  -    <parameter name="source" type="java.lang.Object" required="no">
  +    <parameter name="source">
           <description>
               The data to be displayed by the component. This parameter is 
available as
               an alternative to 'tableModel' and must be used in combination 
with the
  @@ -50,7 +47,7 @@
           </description>
       </parameter>
       
  -    <parameter name="columns" type="java.lang.Object" required="no" 
direction="auto" default-value="null">
  +    <parameter name="columns">
           <description>
               The table columns to be displayed. 
               The parameter must be an array, a list, or an Iterator of 
ITableColumn objects,
  @@ -58,36 +55,28 @@
           </description>
       </parameter>
       
  -     <parameter name="pageSize" 
  -             type="int" 
  -             required="no">
  +     <parameter name="pageSize">
           <description>
               The number of records displayed per page when source/columns are 
used.
               The page size is 10 by default.
           </description>
       </parameter>
     
  -     <parameter name="initialPage" 
  -             type="int" 
  -             required="no">
  +     <parameter name="initialPage">
           <description>
               The initial page to be displayed.
               This is the first page by default.
           </description>
       </parameter>
     
  -     <parameter name="initialSortColumn" 
  -             type="java.lang.String" 
  -             required="no">
  +     <parameter name="initialSortColumn">
           <description>
               The id of the column to initially sort the table by.
               The column is set to null by default, i.e. there is no sorting.
           </description>
       </parameter>
     
  -     <parameter name="initialSortOrder" 
  -             type="boolean" 
  -             required="no">
  +     <parameter name="initialSortOrder">
           <description>
               The order of the initial sorting.
               Set this parameter to 'false' to sort in an ascending order
  @@ -95,24 +84,20 @@
           </description>
       </parameter>
     
  -    <parameter name="tableSessionStateManager" 
  -        
type="org.apache.tapestry.contrib.table.model.ITableSessionStateManager" 
  -        required="no">
  +    <parameter name="tableSessionStateManager">
           <description>
               The manager that controls what part of the table model will be 
stored in 
               the session.
           </description>
       </parameter>
       
  -    <parameter name="tableSessionStoreManager" 
  -        
type="org.apache.tapestry.contrib.table.model.ITableSessionStoreManager" 
  -        required="no">
  +    <parameter name="tableSessionStoreManager">
           <description>
               The manager that controls where the session data will be stored.
           </description>
       </parameter>
       
  -    <parameter name="persist" default-value="'session'"> 
  +    <parameter name="persist" default-value="session"> 
           <description>
               Defines how the table state (paging and sorting) will be 
persisted
               if no tableSessionStoreManager is defined.
  @@ -121,20 +106,13 @@
           </description>
       </parameter>
       
  -    <parameter name="columnSettingsContainer"
  -        type="org.apache.tapestry.IComponent"
  -        required="no"
  -        default-value="container">
  +    <parameter name="columnSettingsContainer" 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">
  +    <parameter name="convertor" 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 
  @@ -142,93 +120,68 @@
           </description>
       </parameter>
   
  -     <parameter name="pagesDisplayed" 
  -             type="int" 
  -             required="no">
  +     <parameter name="pagesDisplayed">
           <description>
               The maximum number of pages that will be displayed in the list 
of table pages.
               By default, only seven of the pages around the current one are 
shown.
           </description>
       </parameter>
     
  -     <parameter name="column" 
  -             type="org.apache.tapestry.contrib.table.model.ITableColumn" 
  -             required="no">
  +     <parameter name="column">
           <description>
               The column that is being rendered. This value is updated when 
both 
               the column headers and column values are rendered.
           </description>
       </parameter>
   
  -     <parameter name="row" 
  -             type="java.lang.Object" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="row">
           <description>
               The row that is being rendered. This value is null when 
               the column headers are rendered.
           </description>
       </parameter>
   
  -     <parameter name="arrowUpAsset" 
  -             type="org.apache.tapestry.IAsset" 
  -             required="no"
  -             direction="in">
  +     <parameter name="arrowUpAsset">
           <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">
  +     <parameter name="arrowDownAsset">
           <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">
  +     <parameter name="pagesClass">
           <description>The CSS class of the table pages</description>
       </parameter>
     
  -     <parameter name="columnsClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="columnsClass">
           <description>The CSS class of the table columns</description>
       </parameter>
     
  -     <parameter name="rowsClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="rowsClass">
           <description>The CSS class of the table rows</description>
       </parameter>
     
  -     <parameter name="valuesClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="valuesClass">
           <description>The CSS class of the table values</description>
       </parameter>
       
   
        <component id="tableElement" type="Any" 
inherit-informal-parameters="yes">
  -             <static-binding name="element">table</static-binding>
  +             <binding name="element">table</binding>
        </component>
   
        <component id="condPages" type="If">
  -             <binding name="condition" expression="tableModel.pageCount > 
1"/>
  +             <binding name="condition" value="tableModel.pageCount > 1"/>
        </component>
   
        <component id="tableView" type="TableView">
                <inherited-binding name="tableModel" 
parameter-name="tableModel"/>
                <inherited-binding name="source" parameter-name="source"/>
  -             <binding name="columns" expression="formColumns"/>
  +             <binding name="columns" value="ognl: formColumns"/>
                <inherited-binding name="pageSize" parameter-name="pageSize"/>
                <inherited-binding name="initialPage" 
parameter-name="initialPage"/>
                <inherited-binding name="initialSortColumn" 
parameter-name="initialSortColumn"/>
  @@ -237,7 +190,7 @@
                <inherited-binding name="tableSessionStoreManager" 
parameter-name="tableSessionStoreManager"/>
                <inherited-binding name="persist" parameter-name="persist"/>
                <inherited-binding name="columnSettingsContainer" 
parameter-name="columnSettingsContainer"/>
  -             <static-binding name="element">div</static-binding>
  +             <binding name="element">div</binding>
        </component>
   
        <component id="tablePages" type="TableFormPages">
  @@ -255,7 +208,7 @@
        <component id="tableRows" type="TableFormRows">
                <inherited-binding name="row" parameter-name="row"/>
                <inherited-binding name="class" parameter-name="rowsClass"/>
  -        <binding name="convertor" expression="convertor"/>
  +             <inherited-binding name="convertor" parameter-name="convertor"/>
        </component>
   
        <component id="tableValues" type="TableValues">
  
  
  
  1.6       +74 -13    
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableRows.jwc
  
  Index: TableRows.jwc
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableRows.jwc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableRows.jwc     7 Jul 2005 23:00:39 -0000       1.5
  +++ TableRows.jwc     14 Aug 2005 14:11:08 -0000      1.6
  @@ -16,8 +16,8 @@
   -->
   
   <!DOCTYPE component-specification PUBLIC 
  -  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  -  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
  +  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
  +  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
        
   <component-specification 
class="org.apache.tapestry.contrib.table.components.TableRows" 
        allow-body="yes" allow-informal-parameters="yes">
  @@ -27,24 +27,85 @@
           This component must be wrapped by TableView. 
        </description>
     
  -     <parameter name="row" 
  -             type="java.lang.Object" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="row" property="rowParameter">
           <description>The current row being rendered.</description>
       </parameter>
   
  -     <parameter name="element" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="auto"
  -     default-value="'tr'">
  +     <parameter name="index" property="indexParameter">
  +             <description>
  +                 If provided, the parameter is updated with the index of the 
loop on each iteration.
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="element" default-value="'tr'">
           <description>The tag to use to wrap the rows in, 'tr' by 
default.</description>
       </parameter>
   
  +     <parameter name="keyExpression">
  +     <description>
  +                 Only active in a form. An OGNL expression that returns the 
primary key of the iterated value. 
  +                 The primary keys are stored in hidden fields during 
rendering and are loaded from the form
  +                 during a rewind to ensure that the iterations remain the 
same.
  +                 This is a simpler, but a less efficient alternative of the 
'converter' parameter.
  +                 If needed, please use in conjuction with 'fullSource' to 
reference objects 
  +                 not currently present in 'source'.
  +                 Also, use the 'defaultValue' parameter to define the object 
to be returned if
  +                 a value corresponding to a particular primary key cannot be 
found.
  +             </description>
  +     </parameter>
  +    
  +     <parameter name="fullSource" property="fullSourceParameter">
  +             <description>
  +                 Only active in a form and in combination with the 
'keyExpression' parameter. 
  +                 If an object corresponding to a primary key stored in the 
form cannot be
  +                 found in the 'source' parameter, then the objects provided 
by this parameter 
  +                 are searched for a match next. 
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="defaultValue" default-value="null">
  +             <description>
  +                 Only active in a form. The value to be used when no match 
for a given primary key is found. 
  +             </description>
  +     </parameter>
  +
  +     <parameter name="converter" default-value="null">
  +             <description>
  +                 Only active in a form. Defines how the items iterated upon 
  +                 will be stored in the form as hidden values and how the 
stored information will be 
  +                 converted back to objects. 
  +                 This interface allows only the primary key of the items to 
be stored, 
  +                 rather than the whole item.
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="primaryKeys">
  +             <description>
  +                     Only active in a form. If provided, the parameter is 
automatically updated 
  +                 before a rewind with the list of primary keys stored in the 
form. 
  +                 The parameter is updated right before the iterations begin 
in a rewind and 
  +                 could be used to preload the relevant objects in a provided 
'converter'.
  +             </description>
  +     </parameter>
  +    
  +    <parameter name="volatile"> 
  +        <description>
  +                     Only active in a form. Determines whether to avoid 
creating hidden fields within a form.
  +                     Using this parameter may make the form structure 
different during render and rewind, 
  +                     and cause exceptions as a result. Please use with 
caution.
  +        </description>
  +    </parameter>
  +    
        <component id="iterRows" type="For">
  -             <binding name="source" expression="tableRowsIterator"/>
  -             <binding name="value" expression="tableRow"/>
  +             <binding name="source" value="tableRowsIterator"/>
  +             <binding name="value" value="tableRow"/>
  +             <binding name="index" value="tableIndex"/>
  +             <binding name="fullSource" value="fullSource"/>
  +             <inherited-binding name="keyExpression" 
parameter-name="keyExpression"/>
  +             <inherited-binding name="defaultValue" 
parameter-name="defaultValue"/>
  +             <inherited-binding name="converter" parameter-name="converter"/>
  +             <inherited-binding name="primaryKeys" 
parameter-name="primaryKeys"/>
  +             <inherited-binding name="volatile" parameter-name="volatile"/>
        </component>
     
        <component id="informal" type="Any" inherit-informal-parameters="yes">
  
  
  
  1.6       +10 -20    
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableFormRows.jwc
  
  Index: TableFormRows.jwc
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableFormRows.jwc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableFormRows.jwc 9 Jan 2005 19:57:00 -0000       1.5
  +++ TableFormRows.jwc 14 Aug 2005 14:11:08 -0000      1.6
  @@ -16,11 +16,11 @@
   -->
   
   <!DOCTYPE component-specification PUBLIC 
  -  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  -  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
  +  "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
  +  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
        
   <component-specification 
class="org.apache.tapestry.contrib.table.components.TableFormRows" 
  -     allow-body="yes" allow-informal-parameters="yes">
  +     allow-body="yes" allow-informal-parameters="yes" deprecated="yes">
        
        <description>
           A version of the TableRows designed for operation in a form. 
  @@ -30,18 +30,11 @@
           This component must be wrapped by TableView. 
        </description>
     
  -     <parameter name="row" 
  -             type="java.lang.Object" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="row">
           <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">
  +    <parameter name="convertor" 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 
  @@ -49,20 +42,17 @@
           </description>
       </parameter>
       
  -     <parameter name="element" 
  -             type="java.lang.String" 
  -             required="no"
  -             default-value='"tr"'>
  +     <parameter name="element" 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="source" value="convertedTableRowsIterator"/>
  +             <binding name="value" value="convertedTableRow"/>
           <inherited-binding name="element" parameter-name="element"/>
        </component>
   
  -    <property-specification name="convertedValues" type="java.util.Map" 
initial-value="new java.util.HashMap()"/>
  -    <property-specification name="convertorCache" 
type="org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor" 
initial-value="null"/>
  +    <property name="convertedValues" initial-value="new 
java.util.HashMap()"/>
  +    <property name="convertorCache" initial-value="null"/>
         
   </component-specification>
  
  
  
  1.5       +1 -0      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableColumnModelSourceImpl.java
  
  Index: TableColumnModelSourceImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableColumnModelSourceImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TableColumnModelSourceImpl.java   25 Jun 2005 04:55:23 -0000      1.4
  +++ TableColumnModelSourceImpl.java   14 Aug 2005 14:11:08 -0000      1.5
  @@ -69,6 +69,7 @@
   
           List arrColumns = new ArrayList();
   
  +        strDesc = strDesc.trim();
           boolean bFormColumns = false;
           while (strDesc.startsWith("*"))
           {
  
  
  
  1.8       +103 -68   
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.jwc
  
  Index: Table.jwc
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.jwc,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Table.jwc 7 Jul 2005 23:00:39 -0000       1.7
  +++ Table.jwc 14 Aug 2005 14:11:08 -0000      1.8
  @@ -16,8 +16,8 @@
   -->
   
   <!DOCTYPE component-specification PUBLIC 
  -  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  -  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
  +    "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
  +    "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
        
   <component-specification 
class="org.apache.tapestry.contrib.table.components.Table" 
        allow-body="yes" allow-informal-parameters="yes">
  @@ -29,10 +29,7 @@
           to declare Blocks defining the column appearances.
       </description>
       
  -    <parameter name="tableModel" 
  -        type="org.apache.tapestry.contrib.table.model.ITableModel" 
  -        property-name="tableModelValue"
  -        required="no">
  +    <parameter name="tableModel" property="tableModelValue">
           <description>
               The model describing the data to be presented by the Table 
component.
               This parameter is optional, but either the 'tableModel' or both
  @@ -40,7 +37,7 @@
           </description>
       </parameter>
       
  -    <parameter name="source" type="java.lang.Object" required="no">
  +    <parameter name="source">
           <description>
               The data to be displayed by the component. This parameter is 
available as
               an alternative to 'tableModel' and must be used in combination 
with the
  @@ -50,7 +47,7 @@
           </description>
       </parameter>
       
  -    <parameter name="columns" type="java.lang.Object" required="no">
  +    <parameter name="columns">
           <description>
               The table columns to be displayed. 
               The parameter must be an array, a list, or an Iterator of 
ITableColumn objects,
  @@ -58,36 +55,28 @@
           </description>
       </parameter>
       
  -     <parameter name="pageSize" 
  -             type="int" 
  -             required="no">
  +     <parameter name="pageSize">
           <description>
               The number of records displayed per page when source/columns are 
used.
               The page size is 10 by default.
           </description>
       </parameter>
     
  -     <parameter name="initialPage" 
  -             type="int" 
  -             required="no">
  +     <parameter name="initialPage">
           <description>
               The initial page to be displayed.
               This is the first page by default.
           </description>
       </parameter>
     
  -     <parameter name="initialSortColumn" 
  -             type="java.lang.String" 
  -             required="no">
  +     <parameter name="initialSortColumn">
           <description>
               The id of the column to initially sort the table by.
               The column is set to null by default, i.e. there is no sorting.
           </description>
       </parameter>
     
  -     <parameter name="initialSortOrder" 
  -             type="boolean" 
  -             required="no">
  +     <parameter name="initialSortOrder">
           <description>
               The order of the initial sorting.
               Set this parameter to 'false' to sort in an ascending order
  @@ -95,24 +84,20 @@
           </description>
       </parameter>
     
  -    <parameter name="tableSessionStateManager" 
  -        
type="org.apache.tapestry.contrib.table.model.ITableSessionStateManager" 
  -        required="no">
  +    <parameter name="tableSessionStateManager">
           <description>
               The manager that controls what part of the table model will be 
stored in 
               the session.
           </description>
       </parameter>
       
  -    <parameter name="tableSessionStoreManager" 
  -        
type="org.apache.tapestry.contrib.table.model.ITableSessionStoreManager" 
  -        required="no">
  +    <parameter name="tableSessionStoreManager">
           <description>
               The manager that controls where the session data will be stored.
           </description>
       </parameter>
       
  -    <parameter name="persist" default-value="'session'"> 
  +    <parameter name="persist" default-value="literal:session"> 
           <description>
               Defines how the table state (paging and sorting) will be 
persisted
               if no tableSessionStoreManager is defined.
  @@ -121,98 +106,136 @@
           </description>
       </parameter>
       
  -    <parameter name="columnSettingsContainer"
  -        type="org.apache.tapestry.IComponent"
  -        required="no"
  -        default-value="container">
  +    <parameter name="columnSettingsContainer" default-value="container">
           <description>
               The component where Block and messages are pulled from when 
using source/columns.
           </description>
       </parameter>
   
  -     <parameter name="pagesDisplayed" 
  -             type="int" 
  -             required="no">
  +     <parameter name="pagesDisplayed">
           <description>
               The maximum number of pages that will be displayed in the list 
of table pages.
               By default, only seven of the pages around the current one are 
shown.
           </description>
       </parameter>
     
  -     <parameter name="column" 
  -             type="org.apache.tapestry.contrib.table.model.ITableColumn" 
  -             required="no">
  +     <parameter name="column">
           <description>
               The column that is being rendered. This value is updated when 
both 
               the column headers and column values are rendered.
           </description>
       </parameter>
   
  -     <parameter name="row" 
  -             type="java.lang.Object" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="row">
           <description>
               The row that is being rendered. This value is null when 
               the column headers are rendered.
           </description>
       </parameter>
   
  -     <parameter name="arrowUpAsset" 
  -             type="org.apache.tapestry.IAsset" 
  -             required="no"
  -             direction="in">
  +     <parameter name="index" property="indexParameter">
  +             <description>
  +                 If provided, the parameter is updated with the index of the 
loop on each iteration.
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="keyExpression">
  +     <description>
  +                 Only active in a form. An OGNL expression that returns the 
primary key of the iterated value. 
  +                 The primary keys are stored in hidden fields during 
rendering and are loaded from the form
  +                 during a rewind to ensure that the iterations remain the 
same.
  +                 This is a simpler, but a less efficient alternative of the 
'converter' parameter.
  +                 If needed, please use in conjuction with 'fullSource' to 
reference objects 
  +                 not currently present in 'source'.
  +                 Also, use the 'defaultValue' parameter to define the object 
to be returned if
  +                 a value corresponding to a particular primary key cannot be 
found.
  +             </description>
  +     </parameter>
  +    
  +     <parameter name="fullSource" property="fullSourceParameter">
  +             <description>
  +                 Only active in a form and in combination with the 
'keyExpression' parameter. 
  +                 If an object corresponding to a primary key stored in the 
form cannot be
  +                 found in the 'source' parameter, then the objects provided 
by this parameter 
  +                 are searched for a match next. 
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="defaultValue" default-value="null">
  +             <description>
  +                 Only active in a form. The value to be used when no match 
for a given primary key is found. 
  +             </description>
  +     </parameter>
  +
  +     <parameter name="converter" default-value="null">
  +             <description>
  +                 Only active in a form. Defines how the items iterated upon 
  +                 will be stored in the form as hidden values and how the 
stored information will be 
  +                 converted back to objects. 
  +                 This interface allows only the primary key of the items to 
be stored, 
  +                 rather than the whole item.
  +             </description>
  +     </parameter>
  +  
  +     <parameter name="primaryKeys">
  +             <description>
  +                     Only active in a form. If provided, the parameter is 
automatically updated 
  +                 before a rewind with the list of primary keys stored in the 
form. 
  +                 The parameter is updated right before the iterations begin 
in a rewind and 
  +                 could be used to preload the relevant objects in a provided 
'converter'.
  +             </description>
  +     </parameter>
  +    
  +    <parameter name="volatile"> 
  +        <description>
  +                     Only active in a form. Determines whether to avoid 
creating hidden fields within a form.
  +                     Using this parameter may make the form structure 
different during render and rewind, 
  +                     and cause exceptions as a result. Please use with 
caution.
  +        </description>
  +    </parameter>
  +    
  +     <parameter name="arrowUpAsset">
           <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">
  +     <parameter name="arrowDownAsset">
           <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">
  +     <parameter name="pagesClass">
           <description>The CSS class of the table pages</description>
       </parameter>
     
  -     <parameter name="columnsClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="columnsClass">
           <description>The CSS class of the table columns</description>
       </parameter>
     
  -     <parameter name="rowsClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="rowsClass">
           <description>The CSS class of the table rows</description>
       </parameter>
     
  -     <parameter name="valuesClass" 
  -             type="java.lang.String" 
  -             required="no"
  -             direction="custom">
  +     <parameter name="valuesClass">
           <description>The CSS class of the table values</description>
       </parameter>
     
   
        <component id="tableElement" type="Any" 
inherit-informal-parameters="yes">
  -             <static-binding name="element">table</static-binding>
  +             <binding name="element">literal:table</binding>
        </component>
   
        <component id="condPages" type="If">
  -             <binding name="condition" expression="tableModel.pageCount > 
1"/>
  +             <binding name="condition" value="tableModel.pageCount > 1"/>
  +     </component>
  +
  +     <component id="ifNormalPages" type="If">
  +             <binding name="condition" value="showNormalPages"/>
        </component>
   
  +     <component id="elseFormPages" type="Else"/>
   
        <component id="tableView" type="TableView">
                <inherited-binding name="tableModel" 
parameter-name="tableModel"/>
  @@ -226,7 +249,7 @@
                <inherited-binding name="tableSessionStoreManager" 
parameter-name="tableSessionStoreManager"/>
                <inherited-binding name="persist" parameter-name="persist"/>
                <inherited-binding name="columnSettingsContainer" 
parameter-name="columnSettingsContainer"/>
  -             <static-binding name="element">div</static-binding>
  +             <binding name="element">literal:div</binding>
        </component>
   
        <component id="tablePages" type="TablePages">
  @@ -234,6 +257,11 @@
                <inherited-binding name="class" parameter-name="pagesClass"/>
        </component>
   
  +     <component id="tableFormPages" type="TableFormPages">
  +             <inherited-binding name="pagesDisplayed" 
parameter-name="pagesDisplayed"/>
  +             <inherited-binding name="class" parameter-name="pagesClass"/>
  +     </component>
  +    
        <component id="tableColumns" type="TableColumns">
                <inherited-binding name="column" parameter-name="column"/>
                <inherited-binding name="class" parameter-name="columnsClass"/>
  @@ -243,6 +271,13 @@
   
        <component id="tableRows" type="TableRows">
                <inherited-binding name="row" parameter-name="row"/>
  +             <inherited-binding name="index" parameter-name="index"/>
  +             <inherited-binding name="keyExpression" 
parameter-name="keyExpression"/>
  +             <inherited-binding name="fullSource" 
parameter-name="fullSource"/>
  +             <inherited-binding name="defaultValue" 
parameter-name="defaultValue"/>
  +             <inherited-binding name="converter" parameter-name="converter"/>
  +             <inherited-binding name="primaryKeys" 
parameter-name="primaryKeys"/>
  +             <inherited-binding name="volatile" parameter-name="volatile"/>
                <inherited-binding name="class" parameter-name="rowsClass"/>
        </component>
   
  
  
  
  1.3       +8 -1      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.html
  
  Index: Table.html
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.html,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Table.html        25 Aug 2004 19:43:30 -0000      1.2
  +++ Table.html        14 Aug 2005 14:11:08 -0000      1.3
  @@ -17,7 +17,14 @@
   <span jwcid="$content$">
   
   <span jwcid="tableView">
  -     <span jwcid="condPages"><span jwcid="tablePages"/></span>
  +     <span jwcid="condPages">
  +             <span jwcid="ifNormalPages">
  +             <span jwcid="tablePages"/>
  +        </span>
  +        <span jwcid="elseFormPages">
  +             <span jwcid="tableFormPages"/>
  +        </span>
  +    </span>
        <table jwcid="tableElement">
                <tr><span jwcid="tableColumns"/></tr>
                <tr jwcid="tableRows"><td jwcid="tableValues"/></tr>
  
  
  
  1.12      +2 -1      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java
  
  Index: TableView.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TableView.java    7 Jul 2005 23:00:39 -0000       1.11
  +++ TableView.java    14 Aug 2005 14:11:08 -0000      1.12
  @@ -204,7 +204,8 @@
           if (m_objTableModel == null)
           {
               Serializable objState = loadSessionState();
  -            m_objTableModel = 
getTableSessionStateManager().recreateTableModel(objState);
  +            ITableSessionStateManager objStateManager = 
getTableSessionStateManager();
  +            m_objTableModel = objStateManager.recreateTableModel(objState);
           }
   
           // if the session state does not help, get the model from the binding
  
  
  
  1.7       +13 -0     
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/components/Table.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Table.java        6 Feb 2005 15:08:51 -0000       1.6
  +++ Table.java        14 Aug 2005 14:11:08 -0000      1.7
  @@ -15,6 +15,8 @@
   package org.apache.tapestry.contrib.table.components;
   
   import org.apache.tapestry.BaseComponent;
  +import org.apache.tapestry.IForm;
  +import org.apache.tapestry.TapestryUtils;
   import org.apache.tapestry.contrib.table.model.ITableColumn;
   import org.apache.tapestry.contrib.table.model.ITableModel;
   import org.apache.tapestry.contrib.table.model.ITableModelSource;
  @@ -29,6 +31,8 @@
    */
   public abstract class Table extends BaseComponent implements 
ITableModelSource
   {
  +     public abstract boolean getVolatile();
  +     
       /**
        * @see 
org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
        */
  @@ -104,4 +108,13 @@
       {
           return (TableValues) getComponent("tableValues");
       }
  +    
  +    public boolean getShowNormalPages()
  +    {
  +     if (getVolatile())
  +             return true;
  +     
  +     IForm form = (IForm) 
getPage().getRequestCycle().getAttribute(TapestryUtils.FORM_ATTRIBUTE);
  +     return (form == null);
  +    }
   }
  \ No newline at end of file
  
  
  
  1.6       +8 -1      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/model/simple/SimpleTableModel.java
  
  Index: SimpleTableModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/model/simple/SimpleTableModel.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleTableModel.java     25 Jun 2005 04:57:07 -0000      1.5
  +++ SimpleTableModel.java     14 Aug 2005 14:11:09 -0000      1.6
  @@ -19,6 +19,7 @@
   import java.util.Iterator;
   
   import org.apache.tapestry.contrib.table.model.CTableDataModelEvent;
  +import org.apache.tapestry.contrib.table.model.IFullTableModel;
   import org.apache.tapestry.contrib.table.model.ITableColumn;
   import org.apache.tapestry.contrib.table.model.ITableColumnModel;
   import org.apache.tapestry.contrib.table.model.ITableDataModel;
  @@ -33,7 +34,8 @@
    *
    * @author mindbridge
    */
  -public class SimpleTableModel extends AbstractTableModel implements 
ITableDataModelListener
  +public class SimpleTableModel extends AbstractTableModel 
  +     implements IFullTableModel, ITableDataModelListener
   {
        private static final long serialVersionUID = 1L;
        
  @@ -178,4 +180,9 @@
           m_arrRows = null;
       }
   
  +     public Iterator getRows() {
  +             updateRows();
  +             return new ArrayIterator(m_arrRows);
  +     }
  +
   }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/table/model/IFullTableModel.java
  
  Index: IFullTableModel.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.table.model;
  
  import java.util.Iterator;
  
  /**
   * An extension of ITableModel that provides the ability to get the full
   * list of row objects, rather than just the displayed ones.
   * 
   * @author mb
   */
  public interface IFullTableModel extends ITableModel {
        /**
         * Iterates over all of the rows in the model
         * @return Iterator the iterator for access to the data
         */
        Iterator getRows();
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to