tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mindbri...@apache.org
Subject cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/example example.application
Date Wed, 07 Jan 2004 01:13:00 GMT
mindbridge    2004/01/06 17:12:59

  Modified:    contrib/src/org/apache/tapestry/contrib/table/model/common
                        AbstractTableColumn.java
               contrib/src/org/apache/tapestry/contrib/table/components
                        TableFormRows.java TableFormPages.jwc
                        TableFormRows.jwc FormTable.jwc TableView.java
                        TableViewSessionStateManager.java TableUtils.java
               contrib/src/org/apache/tapestry/contrib/table/model/simple
                        SimpleTableColumn.java
               contrib/src/org/apache/tapestry/contrib Contrib.library
               contrib/src/org/apache/tapestry/contrib/table/model
                        IBasicTableModel.java
  Added:       contrib/src/org/apache/tapestry/contrib/table/components
                        TableStrings.properties
               contrib/src/org/apache/tapestry/contrib/table/model
                        IPrimaryKeyConvertor.java
  Removed:     contrib/src/org/apache/tapestry/contrib/table/example/minimal
                        Home.page Home.html Home.java
               contrib/src/org/apache/tapestry/contrib/table/components
                        TableView.properties
               contrib/src/org/apache/tapestry/contrib/table/example
                        example.application
  Log:
  Adding documentation and making minor fixes to the Table components
  
  Revision  Changes    Path
  1.4       +19 -5     jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java
  
  Index: AbstractTableColumn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractTableColumn.java	29 Dec 2003 00:13:52 -0000	1.3
  +++ AbstractTableColumn.java	7 Jan 2004 01:12:59 -0000	1.4
  @@ -78,6 +78,18 @@
    */
   public class AbstractTableColumn implements ITableColumn, Serializable
   {
  +    /**
  +     *  The suffix of the name of the Block that will be used as the column renderer
  +     *  for this column 
  +     */
  +    public final static String COLUMN_RENDERER_BLOCK_SUFFIX = "ColumnHeader";
  +
  +    /**
  +     *  The suffix of the name of the Block that will be used as the value renderer 
  +     *  for this column 
  +     */
  +    public final static String VALUE_RENDERER_BLOCK_SUFFIX = "ColumnValue";
  +    
   	private String m_strColumnName;
   	private boolean m_bSortable;
   	private Comparator m_objComparator;
  @@ -223,7 +235,8 @@
   
   	/**
   	 * Returns the valueRendererSource.
  -	 * @return ITableValueRendererSource
  +     * 
  +	 * @return the valueRendererSource of this column
   	 */
   	public ITableRendererSource getValueRendererSource()
   	{
  @@ -232,6 +245,7 @@
   
   	/**
   	 * Sets the valueRendererSource.
  +     * 
   	 * @param valueRendererSource The valueRendererSource to set
   	 */
   	public void setValueRendererSource(ITableRendererSource valueRendererSource)
  @@ -243,15 +257,15 @@
        *  Use the column name to get the column and renderer sources 
        *  from the provided component.
        *   
  -     *  @param objRendererSourceContainer the component from which to get the settings

  +     *  @param objSettingsContainer the component from which to get the settings 
        */
       public void loadSettings(IComponent objSettingsContainer)
       {
  -        IComponent objColumnRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName()
+ "ColumnRenderer");
  +        IComponent objColumnRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName()
+ COLUMN_RENDERER_BLOCK_SUFFIX);
           if (objColumnRendererSource != null && objColumnRendererSource instanceof
Block)
               setColumnRendererSource(new BlockTableRendererSource((Block) objColumnRendererSource));
   
  -        IComponent objValueRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName()
+ "ValueRenderer");
  +        IComponent objValueRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName()
+ VALUE_RENDERER_BLOCK_SUFFIX);
           if (objValueRendererSource != null && objValueRendererSource instanceof
Block)
               setValueRendererSource(new BlockTableRendererSource((Block) objValueRendererSource));
       }
  
  
  
  1.2       +59 -2     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableFormRows.java	6 Sep 2003 14:04:42 -0000	1.1
  +++ TableFormRows.java	7 Jan 2004 01:12:59 -0000	1.2
  @@ -55,6 +55,12 @@
   
   package org.apache.tapestry.contrib.table.components;
   
  +import java.util.Iterator;
  +import java.util.Map;
  +
  +import org.apache.tapestry.IRequestCycle;
  +import org.apache.tapestry.contrib.table.model.*;
  +
   
   /**
    * A low level Table component that generates the rows of the current page in the table.
  @@ -109,7 +115,58 @@
    * @version $Id$
    *
    */
  -public class TableFormRows extends TableRows
  +public abstract class TableFormRows extends TableRows
   {
  +    //public abstract IPrimaryKeyConvertor getConvertor();
  +    public abstract IPrimaryKeyConvertor getConvertorCache();
  +    public abstract Map getConvertedValues();
  +    
  +    public Iterator getConvertedTableRowsIterator()
  +    {
  +        final Iterator objTableRowsIterator = getTableRowsIterator(); 
  +        final IPrimaryKeyConvertor objConvertor = getConvertorCache();
  +        if (objConvertor == null)
  +            return objTableRowsIterator;
  +            
  +        return new Iterator()
  +        {
  +            public boolean hasNext()
  +            {
  +                return objTableRowsIterator.hasNext();
  +            }
  +
  +            public Object next()
  +            {
  +                Object objValue = objTableRowsIterator.next();
  +                Object objPrimaryKey = objConvertor.getPrimaryKey(objValue);
  +                Map mapConvertedValues = getConvertedValues(); 
  +                mapConvertedValues.put(objPrimaryKey, objValue);
  +                return objPrimaryKey;
  +            }
  +
  +            public void remove()
  +            {
  +                objTableRowsIterator.remove();
  +            }
  +        };
  +    }
  +    
  +    public void setConvertedTableRow(Object objConvertedTableRow)
  +    {
  +        Object objValue = objConvertedTableRow;
  +
  +        IPrimaryKeyConvertor objConvertor = getConvertorCache();
  +        if (objConvertor != null) {
  +            IRequestCycle objCycle = getPage().getRequestCycle();
  +            if (objCycle.isRewinding()) {
  +                objValue = objConvertor.getValue(objConvertedTableRow);  
  +            }
  +            else {
  +                Map mapConvertedValues = getConvertedValues(); 
  +                objValue = mapConvertedValues.get(objConvertedTableRow);
  +            }
  +        }
   
  +        setTableRow(objValue);
  +    }
   }
  
  
  
  1.2       +2 -3      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableFormPages.jwc	6 Sep 2003 14:04:42 -0000	1.1
  +++ TableFormPages.jwc	7 Jan 2004 01:12:59 -0000	1.2
  @@ -38,8 +38,7 @@
   	</component>
     
   	<component id="condOther" type="Conditional">
  -		<binding name="condition" expression="condCurrent"/>
  -		<static-binding name="invert">true</static-binding>
  +		<binding name="condition" expression="!condCurrent"/>
   	</component>
     
   	<component id="iterPage" type="Foreach">
  
  
  
  1.2       +13 -4     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableFormRows.jwc	6 Sep 2003 14:04:42 -0000	1.1
  +++ TableFormRows.jwc	7 Jan 2004 01:12:59 -0000	1.2
  @@ -21,10 +21,19 @@
   		direction="custom"
   		default-value='"tr"'/>
   
  +    <parameter name="convertor"
  +    	type="org.apache.tapestry.contrib.table.model.IPrimaryKeyConvertor"
  +    	required="no"
  +    	direction="auto"
  +    	default-value="null"/>
  +    
   	<component id="iterRows" type="ListEdit" inherit-informal-parameters="yes">
  -		<binding name="source" expression="tableRowsIterator"/>
  -		<binding name="value" expression="tableRow"/>
  +		<binding name="source" expression="convertedTableRowsIterator"/>
  +		<binding name="value" expression="convertedTableRow"/>
   		<binding name="element" expression="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="convertor"/>
  +      
   </component-specification>
  
  
  
  1.2       +11 -4     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormTable.jwc	29 Dec 2003 00:13:52 -0000	1.1
  +++ FormTable.jwc	7 Jan 2004 01:12:59 -0000	1.2
  @@ -32,7 +32,7 @@
           </description>
       </parameter>
       
  -    <parameter name="columns" type="java.lang.Object" required="no">
  +    <parameter name="columns" type="java.lang.Object" required="no" direction="auto"
default-value="null">
           <description>
               The table columns to be displayed. 
               The parameter must be an array, a list, or an Iterator of ITableColumn objects,
  @@ -114,7 +114,14 @@
   		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"
  +    />
  +    
   
   	<component id="tableElement" type="Any" inherit-informal-parameters="yes">
   		<static-binding name="element">table</static-binding>
  @@ -124,7 +131,6 @@
   		<binding name="condition" expression="tableModel.pageCount > 1"/>
   	</component>
   
  -
   	<component id="tableView" type="TableView">
   		<inherited-binding name="tableModel" parameter-name="tableModel"/>
   		<inherited-binding name="source" parameter-name="source"/>
  @@ -148,6 +154,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"/>
   	</component>
   
   	<component id="tableValues" type="TableValues">
  
  
  
  1.5       +21 -80    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TableView.java	29 Dec 2003 00:13:52 -0000	1.4
  +++ TableView.java	7 Jan 2004 01:12:59 -0000	1.5
  @@ -60,15 +60,14 @@
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.List;
  -import java.util.StringTokenizer;
   
   import org.apache.commons.collections.CollectionUtils;
   import org.apache.tapestry.ApplicationRuntimeException;
   import org.apache.tapestry.BaseComponent;
  +import org.apache.tapestry.IBinding;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.IMarkupWriter;
   import org.apache.tapestry.IRequestCycle;
  -import org.apache.tapestry.IResourceResolver;
   import org.apache.tapestry.contrib.table.model.IBasicTableModel;
   import org.apache.tapestry.contrib.table.model.ITableColumn;
   import org.apache.tapestry.contrib.table.model.ITableColumnModel;
  @@ -78,16 +77,13 @@
   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;
  -import org.apache.tapestry.contrib.table.model.ognl.ExpressionTableColumn;
   import org.apache.tapestry.contrib.table.model.simple.SimpleListTableDataModel;
  -import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn;
   import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumnModel;
   import org.apache.tapestry.contrib.table.model.simple.SimpleTableModel;
   import org.apache.tapestry.contrib.table.model.simple.SimpleTableState;
   import org.apache.tapestry.event.PageDetachListener;
   import org.apache.tapestry.event.PageEvent;
   import org.apache.tapestry.event.PageRenderListener;
  -import org.apache.tapestry.util.prop.OgnlUtils;
   
   /**
    * A low level Table component that wraps all other low level Table components.
  @@ -224,6 +220,7 @@
   {
       // Component properties
       private ITableSessionStateManager m_objDefaultSessionStateManager = null;
  +    private ITableColumnModel m_objColumnModel = null;
   
       // Persistent properties
       private Serializable m_objSessionState;
  @@ -236,6 +233,7 @@
       public abstract ITableModel getTableModelValue();
       public abstract Object getSource();
       public abstract Object getColumns();
  +    public abstract IBinding getColumnsBinding();
       public abstract ITableSessionStateManager getTableSessionStateManager();
       public abstract ITableSessionStoreManager getTableSessionStoreManager();
       public abstract IComponent getColumnSettingsContainer();
  @@ -313,7 +311,7 @@
               m_objTableModel = generateTableModel(null);
   
           if (m_objTableModel == null)
  -            throw new ApplicationRuntimeException(format("missing-table-model", this));
  +            throw new ApplicationRuntimeException(TableUtils.format("missing-table-model",
this));
   
           return m_objTableModel;
       }
  @@ -390,7 +388,7 @@
               for (int i = 0; i < nColumnsNumber; i++)
               {
                   if (!(arrColumnsList.get(i) instanceof ITableColumn))
  -                    throw new ApplicationRuntimeException(format("columns-only-please",
this));
  +                    throw new ApplicationRuntimeException(TableUtils.format("columns-only-please",
this));
               }
               //objColumns = arrColumnsList.toArray(new ITableColumn[nColumnsNumber]);
               return new SimpleTableColumnModel(arrColumnsList);
  @@ -403,7 +401,16 @@
   
           if (objColumns instanceof String)
           {
  -            return generateTableColumnModel((String) objColumns);
  +            String strColumns = (String) objColumns;
  +            if (getColumnsBinding().isInvariant()) {
  +                // if the binding is invariant, create the columns only once
  +                if (m_objColumnModel == null)
  +                    m_objColumnModel = generateTableColumnModel(strColumns);
  +                return m_objColumnModel;
  +            }
  +
  +            // if the binding is not invariant, create them every time
  +            return generateTableColumnModel(strColumns);
           }
   
           //throw new ApplicationRuntimeException("The columns binding must contain a list
of ITableColumn objects or a description string");
  @@ -419,79 +426,13 @@
        *  If the whole description string is prefixed with *, it represents
        *  columns to be included in a Form. 
        * 
  -     *  @param strDesc
  -     *  @return
  +     *  @param strDesc the description of the column model to be generated
  +     *  @return a table column model based on the provided description
        */
       protected ITableColumnModel generateTableColumnModel(String strDesc)
       {
  -        if (strDesc == null)
  -            return null;
  -
           IComponent objColumnSettingsContainer = getColumnSettingsContainer();
  -        List arrColumns = new ArrayList();
  -
  -        boolean bFormColumns = false;
  -        while (strDesc.startsWith("*"))
  -        {
  -            strDesc = strDesc.substring(1);
  -            bFormColumns = true;
  -        }
  -
  -        StringTokenizer objTokenizer = new StringTokenizer(strDesc, ",");
  -        while (objTokenizer.hasMoreTokens())
  -        {
  -            String strToken = objTokenizer.nextToken().trim();
  -
  -            if (strToken.startsWith("="))
  -            {
  -                String strColumnExpression = strToken.substring(1);
  -                IResourceResolver objResolver = getPage().getEngine().getResourceResolver();
  -
  -                Object objColumn =
  -                    OgnlUtils.get(strColumnExpression, objResolver, objColumnSettingsContainer);
  -                if (!(objColumn instanceof ITableColumn))
  -                    throw new ApplicationRuntimeException(
  -                        format("not-a-column", this, strColumnExpression));
  -
  -                arrColumns.add(objColumn);
  -                continue;
  -            }
  -
  -            boolean bSortable = true;
  -            if (strToken.startsWith("!"))
  -            {
  -                strToken = strToken.substring(1);
  -                bSortable = false;
  -            }
  -
  -            StringTokenizer objColumnTokenizer = new StringTokenizer(strToken, ":");
  -
  -            String strName = "";
  -            if (objColumnTokenizer.hasMoreTokens())
  -                strName = objColumnTokenizer.nextToken();
  -
  -            String strExpression = strName;
  -            if (objColumnTokenizer.hasMoreTokens())
  -                strExpression = objColumnTokenizer.nextToken();
  -
  -            String strDisplayName = strName;
  -            if (objColumnTokenizer.hasMoreTokens())
  -            {
  -                strDisplayName = strExpression;
  -                strExpression = objColumnTokenizer.nextToken();
  -            }
  -
  -            ExpressionTableColumn objColumn =
  -                new ExpressionTableColumn(strName, strDisplayName, strExpression, bSortable);
  -            if (bFormColumns)
  -                objColumn.setColumnRendererSource(SimpleTableColumn.FORM_COLUMN_RENDERER_SOURCE);
  -            if (objColumnSettingsContainer != null)
  -                objColumn.loadSettings(objColumnSettingsContainer);
  -
  -            arrColumns.add(objColumn);
  -        }
  -
  -        return new SimpleTableColumnModel(arrColumns);
  +        return TableUtils.generateTableColumnModel(strDesc, this, objColumnSettingsContainer);
       }
   
       /**
  @@ -526,10 +467,10 @@
   
       /**
        *  Ensures that the table state is saved at the end of the rewind phase 
  -     *  in case there are modifications for which {@link fireObservedStateChange} 
  +     *  in case there are modifications for which {@link #fireObservedStateChange()} 
        *  has not been invoked.
        * 
  -     *  @see org.apache.tapestry.event.PageRenderListener#pageBeginRender(PageEvent)
  +     *  @see org.apache.tapestry.event.PageRenderListener#pageEndRender(PageEvent)
        */
       public void pageEndRender(PageEvent objEvent)
       {
  
  
  
  1.2       +4 -3      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableViewSessionStateManager.java
  
  Index: TableViewSessionStateManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableViewSessionStateManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableViewSessionStateManager.java	29 Dec 2003 00:13:52 -0000	1.1
  +++ TableViewSessionStateManager.java	7 Jan 2004 01:12:59 -0000	1.2
  @@ -62,8 +62,9 @@
   import org.apache.tapestry.contrib.table.model.simple.SimpleTableState;
   
   /**
  - *  Acts like {@link FullSessionStateManager} if the model is provided via the
  - *  tableModel parameter; saves only the model state otherwise. 
  + *  Acts like {@link org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager}

  + *  if the model is provided via the tableModel parameter; 
  + *  saves only the model state otherwise. 
    * 
    *  @author mindbridge
    *  @version $Id$
  
  
  
  1.2       +105 -3    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableUtils.java
  
  Index: TableUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableUtils.java	29 Dec 2003 00:13:52 -0000	1.1
  +++ TableUtils.java	7 Jan 2004 01:12:59 -0000	1.2
  @@ -56,7 +56,20 @@
   package org.apache.tapestry.contrib.table.components;
   
   import java.text.MessageFormat;
  +import java.util.ArrayList;
  +import java.util.List;
   import java.util.ResourceBundle;
  +import java.util.StringTokenizer;
  +
  +import org.apache.tapestry.ApplicationRuntimeException;
  +import org.apache.tapestry.IComponent;
  +import org.apache.tapestry.IResourceResolver;
  +import org.apache.tapestry.contrib.table.model.ITableColumn;
  +import org.apache.tapestry.contrib.table.model.ITableColumnModel;
  +import org.apache.tapestry.contrib.table.model.ognl.ExpressionTableColumn;
  +import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn;
  +import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumnModel;
  +import org.apache.tapestry.util.prop.OgnlUtils;
   
   /**
    *  A placeholder for a static methods related to the Table component
  @@ -82,8 +95,12 @@
   
       public static String format(String key, Object[] args)
       {
  -        if (s_objStrings == null)
  -            s_objStrings = ResourceBundle.getBundle("org.apache.tapestry.contrib.table.components.TableStrings");
  +        if (s_objStrings == null) {
  +            synchronized (TableUtils.class) {
  +                if (s_objStrings == null)
  +                    s_objStrings = ResourceBundle.getBundle("org.apache.tapestry.contrib.table.components.TableStrings");
  +            }
  +        }
   
           String pattern = s_objStrings.getString(key);
   
  @@ -127,6 +144,91 @@
       public static String format(String key, Object arg1, Object arg2, Object arg3)
       {
           return format(key, new Object[] { arg1, arg2, arg3 });
  +    }
  +
  +    /**
  +     *  Generate a table column model out of the description string provided.
  +     *  Entries in the description string are separated by commas.
  +     *  Each column entry is of the format name, name:expression, 
  +     *  or name:displayName:expression.
  +     *  An entry prefixed with ! represents a non-sortable column.
  +     *  If the whole description string is prefixed with *, it represents
  +     *  columns to be included in a Form. 
  +     * 
  +     *  @param strDesc the description of the column model to be generated
  +     *  @param objComponent the component ordering the generation
  +     *  @param objColumnSettingsContainer the component containing the column settings
  +     *  @return a table column model based on the provided parameters
  +     */
  +    public static ITableColumnModel generateTableColumnModel(String strDesc, IComponent
objComponent, IComponent objColumnSettingsContainer)
  +    {
  +        if (strDesc == null)
  +            return null;
  +
  +        List arrColumns = new ArrayList();
  +
  +        boolean bFormColumns = false;
  +        while (strDesc.startsWith("*"))
  +        {
  +            strDesc = strDesc.substring(1);
  +            bFormColumns = true;
  +        }
  +
  +        StringTokenizer objTokenizer = new StringTokenizer(strDesc, ",");
  +        while (objTokenizer.hasMoreTokens())
  +        {
  +            String strToken = objTokenizer.nextToken().trim();
  +
  +            if (strToken.startsWith("="))
  +            {
  +                String strColumnExpression = strToken.substring(1);
  +                IResourceResolver objResolver = objColumnSettingsContainer.getPage().getEngine().getResourceResolver();
  +
  +                Object objColumn =
  +                    OgnlUtils.get(strColumnExpression, objResolver, objColumnSettingsContainer);
  +                if (!(objColumn instanceof ITableColumn))
  +                    throw new ApplicationRuntimeException(
  +                        format("not-a-column", objComponent, strColumnExpression));
  +
  +                arrColumns.add(objColumn);
  +                continue;
  +            }
  +
  +            boolean bSortable = true;
  +            if (strToken.startsWith("!"))
  +            {
  +                strToken = strToken.substring(1);
  +                bSortable = false;
  +            }
  +
  +            StringTokenizer objColumnTokenizer = new StringTokenizer(strToken, ":");
  +
  +            String strName = "";
  +            if (objColumnTokenizer.hasMoreTokens())
  +                strName = objColumnTokenizer.nextToken();
  +
  +            String strExpression = strName;
  +            if (objColumnTokenizer.hasMoreTokens())
  +                strExpression = objColumnTokenizer.nextToken();
  +
  +            String strDisplayName = strName;
  +            if (objColumnTokenizer.hasMoreTokens())
  +            {
  +                strDisplayName = strExpression;
  +                strExpression = objColumnTokenizer.nextToken();
  +            }
  +
  +            ExpressionTableColumn objColumn =
  +                new ExpressionTableColumn(strName, strDisplayName, strExpression, bSortable);
  +            if (bFormColumns)
  +                objColumn.setColumnRendererSource(SimpleTableColumn.FORM_COLUMN_RENDERER_SOURCE);
  +            if (objColumnSettingsContainer != null)
  +                objColumn.loadSettings(objColumnSettingsContainer);
  +
  +            arrColumns.add(objColumn);
  +        }
  +
  +        return new SimpleTableColumnModel(arrColumns);
       }
   
   }
  
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableStrings.properties
  
  Index: TableStrings.properties
  ===================================================================
  # $Id: TableStrings.properties,v 1.1 2004/01/07 01:12:59 mindbridge Exp $
  
  missing-table-model=Either the 'tableModel' parameter or both 'source' and 'columns' parameters
must be specified by component {0}
  columns-only-please=The 'columns' parameter of component {0} must contain a list of ITableColumn
objects only
  not-a-column=The expression '{1}' in the 'columns' parameter of component {0} does not evaluate
to an ITableColumn
  
  
  
  1.6       +2 -2      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleTableColumn.java
  
  Index: SimpleTableColumn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleTableColumn.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleTableColumn.java	29 Dec 2003 00:13:52 -0000	1.5
  +++ SimpleTableColumn.java	7 Jan 2004 01:12:59 -0000	1.6
  @@ -232,7 +232,7 @@
        *  Use the column name to get the display name, as well as 
        *  the column and renderer sources from the provided component.
        *   
  -     *  @param objRendererSourceContainer the component from which to get the settings

  +     *  @param objSettingsContainer the component from which to get the settings 
        */
       public void loadSettings(IComponent objSettingsContainer)
       {
  
  
  
  1.8       +2 -1      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/Contrib.library
  
  Index: Contrib.library
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/Contrib.library,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Contrib.library	10 Dec 2003 08:26:01 -0000	1.7
  +++ Contrib.library	7 Jan 2004 01:12:59 -0000	1.8
  @@ -31,6 +31,7 @@
     <component-type type="TableRows" specification-path="table/components/TableRows.jwc"/>
     <component-type type="TableValues" specification-path="table/components/TableValues.jwc"/>
     <component-type type="TableView" specification-path="table/components/TableView.jwc"/>
  +  <component-type type="FormTable" specification-path="table/components/FormTable.jwc"/>
     <component-type type="TableFormRows" specification-path="table/components/TableFormRows.jwc"/>
     <component-type type="TableFormPages" specification-path="table/components/TableFormPages.jwc"/>
   
  
  
  
  1.2       +9 -2      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/IBasicTableModel.java
  
  Index: IBasicTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/IBasicTableModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IBasicTableModel.java	29 Dec 2003 00:13:53 -0000	1.1
  +++ IBasicTableModel.java	7 Jan 2004 01:12:59 -0000	1.2
  @@ -58,8 +58,12 @@
   import java.util.Iterator;
   
   /**
  + * A simplified version of the table model that concerns itself only with
  + * providing the data on the current page. 
  + * 
    * @version $Id$
    * @author mindbridge
  + * @since 3.0
    */
   public interface IBasicTableModel
   {
  @@ -71,7 +75,10 @@
   
       /** 
        *  Returns the rows on the current page.
  -     *  @param sortColumn can be null if there is no sorting
  +     *  @param nFirst the index of the first item to be dispayed
  +     *  @param nPageSize the number of items to be displayed
  +     *  @param objSortColumn the column to sort by or null if there is no sorting
  +     *  @param bSortOrder determines the sorting order (ascending or descending)
        **/
       Iterator getCurrentPageRows(int nFirst, int nPageSize, ITableColumn objSortColumn,
boolean bSortOrder);
   }
  
  
  
  1.1                  jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/IPrimaryKeyConvertor.java
  
  Index: IPrimaryKeyConvertor.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation", "Tapestry" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" 
   *    or "Tapestry", nor may "Apache" or "Tapestry" appear in their 
   *    name, without prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.tapestry.contrib.table.model;
  
  /**
   * An interface for converting an object to its primary key and back. 
   * Typically used to determine how to store a given object as a hidden 
   * value when rendering a form.
   * 
   * @version $Id: IPrimaryKeyConvertor.java,v 1.1 2004/01/07 01:12:59 mindbridge Exp $
   * @author mb
   * @since 3.0
   */
  public interface IPrimaryKeyConvertor
  {
      /**
       * Gets the serializable primary key of the given value
       * 
       * @param objValue the value for which a primary key needs to be extracted
       * @return the serializable primary key of the value
       */
      Object getPrimaryKey(Object objValue);
      
      /**
       * Gets the value corresponding the given primary key 
       *  
       * @param objPrimaryKey the primary key for which a value needs to be generated
       * @return the generated value corresponding to the given primary key
       */
      Object getValue(Object objPrimaryKey); 
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message