tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r619528 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/resources/org/apache/tapestry/corelib/components/ site/apt/ site/apt/guide/ test/ap...
Date Thu, 07 Feb 2008 17:56:51 GMT
Author: hlship
Date: Thu Feb  7 09:56:32 2008
New Revision: 619528

URL: http://svn.apache.org/viewvc?rev=619528&view=rev
Log:
TAPESTRY-2081: It should be possible to override a Grid column header as easily as overriding
a Grid cell

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractPropertyOutput.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.xdoc
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridColumns.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/templates.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/validation.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/GridDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridDemo.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractPropertyOutput.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractPropertyOutput.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractPropertyOutput.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractPropertyOutput.java
Thu Feb  7 09:56:32 2008
@@ -39,7 +39,6 @@
  */
 public class AbstractPropertyOutput
 {
-
     /**
      * Model for property displayed by the cell.
      */

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
Thu Feb  7 09:56:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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.
@@ -82,8 +82,8 @@
     /**
      * Where to search for local overrides of property editing blocks as block parameters.
Further,
      * the container of the overrides is used as the source for overridden validation messages.
This
-     * is normally the component itself, but when the component is used within a BeanEditForm,
it
-     * will be the BeanEditForm's block parameter that will be searched.
+     * is normally the BeanEditor component itself, but when the component is used within
a BeanEditForm, it
+     * will be the BeanEditForm's resources that will be searched.
      */
     @Parameter(value = "componentResources")
     private ComponentResources _overrides;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java
Thu Feb  7 09:56:32 2008
@@ -23,7 +23,7 @@
 import org.apache.tapestry.beaneditor.PropertyModel;
 import org.apache.tapestry.corelib.data.GridPagerPosition;
 import org.apache.tapestry.grid.GridDataSource;
-import org.apache.tapestry.grid.GridModelProvider;
+import org.apache.tapestry.grid.GridModel;
 import org.apache.tapestry.internal.beaneditor.BeanModelUtils;
 import org.apache.tapestry.internal.bindings.AbstractBinding;
 import org.apache.tapestry.ioc.annotations.Inject;
@@ -34,16 +34,18 @@
  * A grid presents tabular data. It is a composite component, created in terms of several
sub-components. The
  * sub-components are statically wired to the Grid, as it provides access to the data and
other models that they need.
  * <p/>
- * A Grid may operate inside a {@link Form}. By overriding the cell renderers of properties,
the default output only
+ * A Grid may operate inside a {@link org.apache.tapestry.corelib.components.Form}. By overriding
the cell renderers of
+ * properties, the default output-only
  * behavior can be changed to produce a complex form with individual control for editing
properties of each row. This is
  * currently workable but less than ideal -- if the order of rows provided by the {@link
GridDataSource} changes between
  * render and form submission, then there's the possibility that data will be applied to
the wrong server-side objects.
  *
- * @see BeanModel
- * @see BeanModelSource
+ * @see org.apache.tapestry.beaneditor.BeanModel
+ * @see org.apache.tapestry.services.BeanModelSource
+ * @see org.apache.tapestry.grid.GridDataSource
  */
 @SupportsInformalParameters
-public class Grid implements GridModelProvider
+public class Grid implements GridModel
 {
     /**
      * The source of data for the Grid to display. This will usually be a List or array but
can also be an explicit
@@ -150,12 +152,13 @@
 
 
     @SuppressWarnings("unused")
-    @Component(parameters = {"sortColumnId=sortColumnId", "sortAscending=sortAscending",
"lean=inherit:lean"})
+    @Component(
+            parameters = {"lean=inherit:lean", "overrides=componentResources"})
     private GridColumns _columns;
 
     @SuppressWarnings("unused")
     @Component(
-            parameters = {"sortColumnId=sortColumnId", "sortAscending=sortAscending", "rowClass=rowClass",
"rowsPerPage=rowsPerPage", "currentPage=currentPage", "row=row", "volatile=inherit:volatile",
"lean=inherit:lean"})
+            parameters = {"rowClass=rowClass", "rowsPerPage=rowsPerPage", "currentPage=currentPage",
"row=row", "volatile=inherit:volatile", "lean=inherit:lean"})
     private GridRows _rows;
 
     @Component(parameters = {"source=dataSource", "rowsPerPage=rowsPerPage", "currentPage=currentPage"})
@@ -296,6 +299,10 @@
         _currentPage = currentPage;
     }
 
+    /**
+     * Returns the current row being rendered by the Grid. This property can be accessed
+     * as an alternative to binding the row parameter.
+     */
     public Object getRow()
     {
         return _row;
@@ -344,5 +351,18 @@
     public Object getPagerBottom()
     {
         return _pagerPosition.isMatchBottom() ? _pager : null;
+    }
+
+    public void updateSort(String columnId)
+    {
+        if (columnId.equals(_sortColumnId))
+        {
+            _sortAscending = !_sortAscending;
+            return;
+        }
+
+        _sortColumnId = columnId;
+        _sortAscending = true;
+
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.xdoc
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.xdoc?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.xdoc
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.xdoc
Thu Feb  7 09:56:32 2008
@@ -101,6 +101,13 @@
                 </p>
 
                 <p>
+                    The Grid component takes care of the &lt;td&gt; element, and
the provided block parameter
+                    provides the content
+                    <em>inside</em>
+                    the &lt;td&gt;.
+                </p>
+
+                <p>
                     For the block to know what is being rendered, we bind the row parameter
of the Grid
                     to the user property of the page. The Grid will keep updating this property
                     just before it renders each row (using its own internal renderers, or
the ones
@@ -108,8 +115,13 @@
                 </p>
 
                 <p>
-                    <strong>Note:</strong>
-                    Overriding of headers, the clickable links at the top of columns, is
not yet implemented.
+                    The header for a column may be overridden in the same way, using a parameter
name
+                    of
+                    <code><em>property</em>header
+                    </code>
+                    . The parameter block will provide the content
+                    inside the &lt;th&gt; element. The provided block is responsible
for
+                    providing any links or icons related to sorting.
                 </p>
 
             </subsection>
@@ -262,17 +274,16 @@
                     &lt;td&gt; elements,
                     it generates CSS class attributes for each element. You can then add
customized CSS rules, even
                     overriding the Tapestry defaults,
-                    to present the Grid as desired.
+                    to present the Grid as desired. This is often used to set the width of
a column to a fixed value.
                 </p>
 
                 <dl>
-                    <dt><em>propertyId</em>-header
+                    <dt>
+                        <em>propertyId</em>
                     </dt>
-                    <dd>Added to &lt;th&gt; elements to allow customization
of a particular column's header.</dd>
-
-                    <dt><em>propertyId</em>-cell
-                    </dt>
-                    <dd>Added to &lt;td&gt; elements to allow customization
of a particular column's data cells.</dd>
+                    <dd>Added to &lt;th&gt; elements to allow customization
of a particular column's header,
+                        and added to &lt;td&gt; elements to allow customization of
a particular column's data cells.
+                    </dd>
 
                     <dt>t-first</dt>
                     <dd>Added to the first &lt;th&gt; and the first &lt;tr&gt;
of the &lt;tbody&gt; (the data portion of
@@ -294,9 +305,8 @@
                 </dl>
 
                 <p>
-                    The added CSS classes can get quite verbose; the Grid's lean parameter
allows the first two CSS
-                    class attribute values
-                    (the two related to the property for a column) to be omitted. Even in
lean mode, the other
+                    The added CSS classes can get quite verbose; the Grid's lean parameter
allows the propertyId CSS
+                    class attribute value to be omitted. Even in lean mode, the other
                     CSS class attribute values are rendered.
                 </p>
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridColumns.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridColumns.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridColumns.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridColumns.java
Thu Feb  7 09:56:32 2008
@@ -15,12 +15,15 @@
 package org.apache.tapestry.corelib.components;
 
 import org.apache.tapestry.Asset;
+import org.apache.tapestry.Block;
+import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.annotations.Component;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.annotations.Path;
+import org.apache.tapestry.annotations.SupportsInformalParameters;
 import org.apache.tapestry.beaneditor.PropertyModel;
 import org.apache.tapestry.grid.GridConstants;
-import org.apache.tapestry.grid.GridModelProvider;
+import org.apache.tapestry.grid.GridModel;
 import org.apache.tapestry.internal.TapestryInternalUtils;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.annotations.Inject;
@@ -31,13 +34,14 @@
 /**
  * Renders out the column headers for the grid, including links (where appropriate) to control
column sorting.
  */
+@SupportsInformalParameters
 public class GridColumns
 {
     /**
      * The object that provides access to bean and data models, which is typically the enclosing
Grid component.
      */
     @Parameter(value = "componentResources.container")
-    private GridModelProvider _dataProvider;
+    private GridModel _gridModel;
 
     /**
      * If true, then the CSS class on each &lt;TH&gt; element will be omitted, which
can reduce the amount of output
@@ -48,18 +52,12 @@
     private boolean _lean;
 
     /**
-     * The column which is currently being sorted. This value is the column's {@link PropertyModel#getId()
id}, not its
-     * {@link PropertyModel#getPropertyName() name}. This parameter may be null, in which
case no column is being used
-     * for sorting.
+     * Where to look for informal parameter Blocks used to override column headers.  The
default is to look for such overrides
+     * in the GridColumns component itself, but this is usually overridden.
      */
-    @Parameter(required = true)
-    private String _sortColumnId;
+    @Parameter("componentResources")
+    private ComponentResources _overrides;
 
-    /**
-     * If true, then the sort is ascending (A - Z), if false then descending (Z - A).
-     */
-    @Parameter(required = true)
-    private boolean _sortAscending;
 
     @SuppressWarnings("unused")
     @Component(parameters = {"event=sort", "disabled=sortDisabled", "context=columnModel.id",
"class=sortLinkClass"})
@@ -80,6 +78,8 @@
     @Inject
     private Messages _messages;
 
+    @Inject
+    private Block _standardHeader;
 
     private int _columnIndex;
 
@@ -89,7 +89,7 @@
 
     void setupRender()
     {
-        _lastColumnIndex = _dataProvider.getDataModel().getPropertyNames().size() - 1;
+        _lastColumnIndex = _gridModel.getDataModel().getPropertyNames().size() - 1;
     }
 
     public boolean isSortDisabled()
@@ -100,7 +100,7 @@
     public String getSortLinkClass()
     {
         if (isActiveSortColumn())
-            return _sortAscending ? GridConstants.SORT_ASCENDING_CLASS : GridConstants.SORT_DESCENDING_CLASS;
+            return _gridModel.isSortAscending() ? GridConstants.SORT_ASCENDING_CLASS : GridConstants.SORT_DESCENDING_CLASS;
 
         return null;
     }
@@ -109,7 +109,7 @@
     {
         List<String> classes = CollectionFactory.newList();
 
-        if (!_lean) classes.add(_columnModel.getId() + "-header");
+        if (!_lean) classes.add(_columnModel.getId());
 
         String sort = getSortLinkClass();
 
@@ -124,39 +124,31 @@
 
     public boolean isActiveSortColumn()
     {
-        return _columnModel.getId().equals(_sortColumnId);
+        return _columnModel.getId().equals(_gridModel.getSortColumnId());
     }
 
     void onSort(String columnId)
     {
-        if (columnId.equals(_sortColumnId))
-        {
-            _sortAscending = !_sortAscending;
-        }
-        else
-        {
-            _sortColumnId = columnId;
-            _sortAscending = true;
-        }
+        _gridModel.updateSort(columnId);
     }
 
     public Asset getIcon()
     {
-        if (isActiveSortColumn()) return _sortAscending ? _ascendingAsset : _descendingAsset;
+        if (isActiveSortColumn()) return _gridModel.isSortAscending() ? _ascendingAsset :
_descendingAsset;
 
         return _sortableAsset;
     }
 
     public String getIconLabel()
     {
-        String key = isActiveSortColumn() ? (_sortAscending ? "ascending" : "descending")
: "sortable";
+        String key = isActiveSortColumn() ? (_gridModel.isSortAscending() ? "ascending" :
"descending") : "sortable";
 
         return _messages.get(key);
     }
 
     public List<String> getColumnNames()
     {
-        return _dataProvider.getDataModel().getPropertyNames();
+        return _gridModel.getDataModel().getPropertyNames();
     }
 
     public PropertyModel getColumnModel()
@@ -166,7 +158,7 @@
 
     public void setColumnName(String columnName)
     {
-        _columnModel = _dataProvider.getDataModel().get(columnName);
+        _columnModel = _gridModel.getDataModel().get(columnName);
     }
 
     /**
@@ -180,5 +172,14 @@
     public int getColumnIndex()
     {
         return _columnIndex;
+    }
+
+    public Block getBlockForColumn()
+    {
+        Block override = _overrides.getBlockParameter(_columnModel.getId() + "Header");
+
+        if (override != null) return override;
+
+        return _standardHeader;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java
Thu Feb  7 09:56:32 2008
@@ -20,7 +20,7 @@
 import org.apache.tapestry.beaneditor.PropertyModel;
 import org.apache.tapestry.grid.GridConstants;
 import org.apache.tapestry.grid.GridDataSource;
-import org.apache.tapestry.grid.GridModelProvider;
+import org.apache.tapestry.grid.GridModel;
 import org.apache.tapestry.internal.TapestryInternalUtils;
 import org.apache.tapestry.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry.services.FormSupport;
@@ -57,20 +57,6 @@
     }
 
     /**
-     * The column which is currently being sorted. This value is the column's {@link PropertyModel#getId()
id}, not its
-     * {@link PropertyModel#getPropertyName() name}. This parameter may be null, in which
case no column is being used
-     * for sorting.
-     */
-    @Parameter(required = true)
-    private String _sortColumnId;
-
-    /**
-     * If true, then the sort is ascending (A - Z), if false the descending (Z - A).
-     */
-    @Parameter(required = true)
-    private boolean _sortAscending;
-
-    /**
      * Parameter used to set the CSS class for each row (each &lt;tr&gt; element)
within the &lt;tbody&gt;). This is not
      * cached, so it will be recomputed for each row.
      */
@@ -81,7 +67,7 @@
      * Object that provides access to the bean and data models used to render the Grid.
      */
     @Parameter(value = "componentResources.container")
-    private GridModelProvider _provider;
+    private GridModel _gridModel;
 
     /**
      * Number of rows displayed on each page. Long result sets are split across multiple
pages.
@@ -154,14 +140,15 @@
 
         if (!_lean)
         {
-            String id = _provider.getDataModel().get(_propertyName).getId();
+            String id = _gridModel.getDataModel().get(_propertyName).getId();
 
-            classes.add(id + "-cell");
+            classes.add(id);
         }
 
-        if (_columnModel.getId().equals(_sortColumnId))
+        if (_columnModel.getId().equals(_gridModel.getSortColumnId()))
         {
-            String sortClassName = _sortAscending ? GridConstants.SORT_ASCENDING_CLASS :
GridConstants.SORT_DESCENDING_CLASS;
+            String sortClassName = _gridModel.isSortAscending() ? GridConstants.SORT_ASCENDING_CLASS
: GridConstants.SORT_DESCENDING_CLASS;
+
             classes.add(sortClassName);
         }
 
@@ -170,7 +157,7 @@
 
     void setupRender()
     {
-        GridDataSource dataSource = _provider.getDataSource();
+        GridDataSource dataSource = _gridModel.getDataSource();
 
         int availableRows = dataSource.getAvailableRows();
 
@@ -193,7 +180,7 @@
      */
     void setupForRow(int rowIndex)
     {
-        _row = _provider.getDataSource().getRowValue(rowIndex);
+        _row = _gridModel.getDataSource().getRowValue(rowIndex);
 
     }
 
@@ -217,7 +204,7 @@
 
     public List<String> getPropertyNames()
     {
-        return _provider.getDataModel().getPropertyNames();
+        return _gridModel.getDataModel().getPropertyNames();
     }
 
     public String getPropertyName()
@@ -229,7 +216,7 @@
     {
         _propertyName = propertyName;
 
-        _columnModel = _provider.getDataModel().get(propertyName);
+        _columnModel = _gridModel.getDataModel().get(propertyName);
     }
 
     public Object getRow()

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
Thu Feb  7 09:56:32 2008
@@ -71,12 +71,12 @@
     private Object _object;
 
     /**
-     * Where to search for local overrides of property editing blocks as block parameters.
Further, the container of the
-     * overrides is used as the source for overridden validation messages. This is normally
the component itself, but
-     * when the component is used within a BeanEditForm, it will be the BeanEditForm's block
parameter that will be
+     * Where to search for local overrides of property editing blocks as block parameters.
+     * This is normally the containing component of the PropertyEditor, but
+     * when the component is used within a BeanEditor, it will be the BeanEditForm's block
parameters that will be
      * searched.
      */
-    @Parameter(value = "componentResources")
+    @Parameter(value = "componentResources.containerResources")
     private ComponentResources _overrides;
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
Thu Feb  7 09:56:32 2008
@@ -2,12 +2,15 @@
     <tr>
         <th t:type="Loop" source="columnNames" value="columnName" volatile="true" class="prop:headerClass"
             index="columnIndex">
-            <a t:id="sort">${columnModel.label}</a>
-            <t:if test="columnModel.sortable">
-                <a t:id="sort2">
-                    <img src="${icon}" id="${columnModel.id}:sort" class="t-sort-icon"
alt="${iconLabel}"/>
-                </a>
-            </t:if>
+            <t:delegate to="blockForColumn"/>
+            <t:block id="standardHeader">
+                <a t:id="sort">${columnModel.label}</a>
+                <t:if test="columnModel.sortable">
+                    <a t:id="sort2">
+                        <img src="${icon}" id="${columnModel.id}:sort" class="t-sort-icon"
alt="${iconLabel}"/>
+                    </a>
+                </t:if>
+            </t:block>
         </th>
     </tr>
 </thead>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt Thu Feb  7 09:56:32
2008
@@ -238,10 +238,6 @@
   For example:  <<<validate:required,minLength=5>>> would presumably enforce
that a field
   requires a value, with at least five characters.
   
-  TODO: More ability to escape or quote constraint values. Ability to reference methods
-  or properties of the container to perform some of the validation.  Links to
-  proper discussion of validation, once the code and documentation is ready.
-  
 Translate Bindings
 
   The "translate:" binding prefix is also related to input validator. It is the name
@@ -257,7 +253,7 @@
   Some components support <informal parameters>, additional parameters beyond the formally
defined parameters.
   Informal parameters will be rendered into the output as additional attributes on the tag
rendered by
   the component.  Generally speaking, components that have a 1:1 relationship with a particular
HTML tag
-  (such as {{{../../apidocs/org/apache/tapestry/corelib/components/TextField.html}TextField}}
and 
+  (such as {{{../ref/org/apache/tapestry/corelib/components/TextField.html}TextField}} and

   \<input\> will support informal parameters.
   
   Informal parameters are often used to set the CSS class of an element, or to specify client-side
event handlers.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/templates.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/templates.apt?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/templates.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/templates.apt Thu Feb  7 09:56:32
2008
@@ -25,7 +25,7 @@
   might be <<<src/main/java/org/example/myapp/components/MyComponent.java>>>.
   The corresponding template will be <<<src/main/resources/org/example/myapp/components/MyComponent.tml>>>.
   
-  Likewise, the Java class for a component might be <<<src/main/java/org/example/myapp/pages/MyPage.java>>>
and
+  Likewise, the Java class for a page might be <<<src/main/java/org/example/myapp/pages/MyPage.java>>>
and
   the corresponding template will be <<<src/main/resources/org/example/myapp/pages/MyPage.tml>>>.
   
   The template and the compiled class will be packaged together in the WEB-INF/classes folder
of the application WAR.
@@ -224,7 +224,7 @@
   Expansions are allowed inside text, and inside attributes of ordinary elements, and component
elements.  For example:
   
 +---+
-  <img src="${request.contextPath}/images/catalog/product_${productId}"/>
+  <img src="${request.contextPath}/images/catalog/product_${productId}.png"/>
 +---+
 
   In this hypothetical example, the component class is providing a request property and a
productId property, and these are being

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/validation.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/validation.apt?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/validation.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/validation.apt Thu Feb  7 09:56:32
2008
@@ -17,11 +17,11 @@
 Form component
 
   The core of Tapestry's form support is the
-  {{{../../apidocs/org/apache/tapestry/corelib/components/Form.html}Form}} component.  The
Form component encloses (wraps around) all the
+  {{{../ref/org/apache/tapestry/corelib/components/Form.html}Form}} component.  The Form
component encloses (wraps around) all the
   other <field components>  such as
-  {{{../../apidocs/org/apache/tapestry/corelib/components/TextField.html}TextField}},
-  {{{../../apidocs/org/apache/tapestry/corelib/components/TextArea.html}TextArea}},
-  {{{../../apidocs/org/apache/tapestry/corelib/components/Checkbox.html}Checkbox}}, etc.
+  {{{../ref/org/apache/tapestry/corelib/components/TextField.html}TextField}},
+  {{{../ref/org/apache/tapestry/corelib/components/TextArea.html}TextArea}},
+  {{{../ref/org/apache/tapestry/corelib/components/Checkbox.html}Checkbox}}, etc.
   
   The Form component generates a number of {{{event.html}component events}} that
   you may provide event handler methods for.
@@ -135,7 +135,7 @@
 	Because of the the fact that a form submission is <two> requests (the submission itself,
then a re-render of the page),
 	it is necessary to make the value stored in the _userName field persist between the two
requests. This would be necessary
 	for the _password field as well, except that the 
-	{{{../../apidocs/org/apache/tapestry/corelib/components/PasswordField.html}PasswordField}}
component never renders a value.
+	{{{../ref/org/apache/tapestry/corelib/components/PasswordField.html}PasswordField}} component
never renders a value.
 	
 	Note that the onSuccess() method is not public; event handler methods can have any visibility,
even private.  Package private
 	(that is, no modifier) is the typical use, as it allows the component to be tested, from
a test case class in the same package.
@@ -180,11 +180,11 @@
   responsibility, not yours).
   
   The 
-  {{{../../apidocs/org/apache/tapestry/corelib/components/Errors.html}Errors}} component
must be placed inside a Form, it outputs
+  {{{../ref/org/apache/tapestry/corelib/components/Errors.html}Errors}} component must be
placed inside a Form, it outputs
   all of the errors for all the fields within the Form as a single list. It uses some simple
styling to make the result more presentable.
   
   Each field component, such as the TextField, is paired with a
-  {{{../../apidocs/org/apache/tapestry/corelib/components/Label.html}Label}} component. 
The Label will render out
+  {{{../ref/org/apache/tapestry/corelib/components/Label.html}Label}} component.  The Label
will render out
   a \<label\> element connected to the field. This is very important for useability,
especially for users with
   visual disabilities. It also means you can click on the label text to move the cursor to
the corresponding field.
   

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt Thu Feb  7 09:56:32 2008
@@ -30,7 +30,7 @@
   * New Unless component (like an If component, but inverted).
 
   * Support for "password" and "longtext" data types (for use with the BeanEditor), and a
new
-    {{{../apidocs/org/apache/tapestry/corelib/components/TextOutput.html}TextOutput}} component.
+    {{{ref/org/apache/tapestry/corelib/components/TextOutput.html}TextOutput}} component.
 
   * The new "var:" binding prefix allows for temporary, untyped storage
     of render-time values without having to define a new component property.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/GridDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/GridDemo.tml?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/GridDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/GridDemo.tml Thu Feb  7 09:56:32
2008
@@ -2,7 +2,10 @@
 
     <h1>Grid Demo</h1>
 
-    <table t:type="Grid" source="tracks" row="track">
+    <table t:id="grid" source="tracks" row="track">
+        <t:parameter name="ratingheader">
+            <t:actionlink t:id="sortRating">Sort Rating</t:actionlink>
+        </t:parameter>
         <t:parameter name="ratingcell">
             <t:outputRating rating="track.rating"/>
         </t:parameter>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml Thu Feb  7 09:56:32
2008
@@ -2,7 +2,7 @@
 
     <h1>Lean Grid Demo</h1>
 
-    <table t:type="Grid" source="tracks" row="track" lean="true">
+    <table t:id="grid" source="tracks" row="track" lean="true">
         <t:parameter name="ratingcell">
             <t:outputRating rating="track.rating"/>
         </t:parameter>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Thu Feb  7 09:56:32 2008
@@ -594,7 +594,9 @@
     {
         start("Grid Demo");
 
-        assertTextSeries("//th[%d]", 1, "Title", "Album", "Artist", "Genre", "Play Count",
"Rating");
+        // "Sort Rating" via the header cell override (TAPESTRY-2081)
+
+        assertTextSeries("//th[%d]", 1, "Title", "Album", "Artist", "Genre", "Play Count",
"Sort Rating");
 
         // Strange: I thought tr[1] was the header row ???
 
@@ -624,33 +626,33 @@
 
         // Sort ascending (and we're on the last page, with the highest ratings).
 
-        clickAndWait("link=Rating");
-
-        // The lack of a leading slash indicates that the path was optimized, see TAPESTRY-1502
+        clickAndWait("link=Sort Rating");
 
-        assertText("//img[@id='rating:sort']/@src", "assets/tapestry/corelib/components/sort-asc.png");
-        assertText("//img[@id='rating:sort']/@alt", "[Asc]");
 
         assertTextSeries("//tr[22]/td[%d]", 1, "Mona Lisa Overdrive", "Labyrinth", "Juno
Reactor", "Dance", "31",
                          "*****");
 
         // Toggle to sort descending
 
-        clickAndWait("link=Rating");
-
-        assertText("//img[@id='rating:sort']/@src", "assets/tapestry/corelib/components/sort-desc.png");
-        assertText("//img[@id='rating:sort']/@alt", "[Desc]");
+        clickAndWait("link=Sort Rating");
 
         assertTextSeries("//tr[1]/td[%d]", 1, "Hey Blondie", "Out from Out Where");
 
         clickAndWait("link=Title");
 
+        // The lack of a leading slash indicates that the path was optimized, see TAPESTRY-1502
+
         assertText("//img[@id='title:sort']/@src", "assets/tapestry/corelib/components/sort-asc.png");
         assertText("//img[@id='title:sort']/@alt", "[Asc]");
 
         clickAndWait("link=1");
 
         assertText("//tr[1]/td[1]", "(untitled hidden track)");
+
+        clickAndWait("link=Title");
+
+        assertText("//img[@id='title:sort']/@src", "assets/tapestry/corelib/components/sort-desc.png");
+        assertText("//img[@id='title:sort']/@alt", "[Desc]");
     }
 
     @Test

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridDemo.java?rev=619528&r1=619527&r2=619528&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridDemo.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridDemo.java
Thu Feb  7 09:56:32 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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.
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.integration.app1.pages;
 
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.corelib.components.Grid;
 import org.apache.tapestry.integration.app1.data.Track;
 import org.apache.tapestry.integration.app1.services.MusicLibrary;
 import org.apache.tapestry.ioc.annotations.Inject;
@@ -27,6 +29,9 @@
 
     private Track _track;
 
+    @Component
+    private Grid _grid;
+
     public Track getTrack()
     {
         return _track;
@@ -41,4 +46,7 @@
     {
         return _library.getTracks();
     }
+
+    void onActionFromSortRating() { _grid.updateSort("rating"); }
+
 }



Mime
View raw message