You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/09 01:05:21 UTC

svn commit: r610236 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/components/ main/resources/org/apache/tapestry/corelib/components/ test/app1/ test/java/org/apache/tapestry/integration/ test/java/org/apache/ta...

Author: hlship
Date: Tue Jan  8 16:05:19 2008
New Revision: 610236

URL: http://svn.apache.org/viewvc?rev=610236&view=rev
Log:
TAPESTRY-2021: It should be possible to turn off the generation of CSS classes for table headers and table cells inside a Grid

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/LeanGridDemo.java
Modified:
    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/GridColumns.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/GridRows.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties

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=610236&r1=610235&r2=610236&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 Tue Jan  8 16:05:19 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.
@@ -122,6 +122,15 @@
     @Parameter(value = "block:empty")
     private Block _empty;
 
+
+    /**
+     * If true, then the CSS class on each <TD> and <TH> cell will be omitted, which can reduce
+     * the amount of output from the component overall by a considerable amount. Leave this as false, the
+     * default, when you are leveraging the CSS to customize the look and feel of particular columns.
+     */
+    @Parameter
+    private boolean _lean;
+
     @Inject
     private ComponentResources _resources;
 
@@ -144,18 +153,15 @@
     private String _rowClass;
 
     @SuppressWarnings("unused")
-    @Component(parameters =
-            {"sortColumnId=sortColumnId", "sortAscending=sortAscending"})
+    @Component(parameters = {"sortColumnId=sortColumnId", "sortAscending=sortAscending", "lean=inherit:lean"})
     private GridColumns _columns;
 
     @SuppressWarnings("unused")
-    @Component(parameters =
-            {"rowClass=rowClass", "rowsPerPage=rowsPerPage", "currentPage=currentPage", "row=row",
-                    "volatile=inherit:volatile"})
+    @Component(
+            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"})
+    @Component(parameters = {"source=dataSource", "rowsPerPage=rowsPerPage", "currentPage=currentPage"})
     private GridPager _pager;
 
     @SuppressWarnings("unused")
@@ -192,8 +198,7 @@
 
                 Class rowType = _dataSource.getRowType();
 
-                if (rowType == null)
-                    throw new RuntimeException("xxx -- no source to determine list type from");
+                if (rowType == null) throw new RuntimeException("xxx -- no source to determine list type from");
 
                 // Properties do not have to be read/write
 

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=610236&r1=610235&r2=610236&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 Tue Jan  8 16:05:19 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.
@@ -38,7 +38,13 @@
     @Parameter(value = "componentResources.container")
     private GridModelProvider _dataProvider;
 
-    private PropertyModel _columnModel;
+    /**
+     * If true, then the CSS class on each <TH> cell will be omitted, which can reduce
+     * the amount of output from the component overall by a considerable amount. Leave this as false, the
+     * default, when you are leveraging the CSS to customize the look and feel of particular columns.
+     */
+    @Parameter
+    private boolean _lean;
 
     /**
      * The column which is currently being sorted. This value is the column's
@@ -55,8 +61,7 @@
     private boolean _sortAscending;
 
     @SuppressWarnings("unused")
-    @Component(parameters =
-            {"disabled=sortDisabled", "context=columnModel.id", "class=sortLinkClass"})
+    @Component(parameters = {"disabled=sortDisabled", "context=columnModel.id", "class=sortLinkClass"})
     private ActionLink _sort, _sort2;
 
     @Inject
@@ -74,6 +79,8 @@
     @Inject
     private Messages _messages;
 
+    private PropertyModel _columnModel;
+
     public boolean isSortDisabled()
     {
         return !_columnModel.isSortable();
@@ -81,12 +88,18 @@
 
     public String getSortLinkClass()
     {
-        if (isActiveSortColumn())
-            return _sortAscending ? "t-sort-column-ascending" : "t-sort-column-descending";
+        if (isActiveSortColumn()) return _sortAscending ? "t-sort-column-ascending" : "t-sort-column-descending";
 
         return null;
     }
 
+    public String getHeaderClass()
+    {
+        if (_lean) return null;
+
+        return _columnModel.getId() + "-header";
+    }
+
     public boolean isActiveSortColumn()
     {
         return _columnModel.getId().equals(_sortColumnId);
@@ -119,8 +132,7 @@
 
     public String getIconLabel()
     {
-        String key = isActiveSortColumn() ? (_sortAscending ? "ascending" : "descending")
-                     : "sortable";
+        String key = isActiveSortColumn() ? (_sortAscending ? "ascending" : "descending") : "sortable";
 
         return _messages.get(key);
     }
@@ -138,10 +150,5 @@
     public void setColumnName(String columnName)
     {
         _columnModel = _dataProvider.getDataModel().get(columnName);
-    }
-
-    public String getCellClass()
-    {
-        return _columnModel.getId() + "-header";
     }
 }

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=610236&r1=610235&r2=610236&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 Tue Jan  8 16:05:19 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.
@@ -31,8 +31,6 @@
  * {@linkplain FormSupport#store(Object, ComponentAction) as ComponentActions}). This is not ideal
  * ... in a situation where the data set can shift between the form render and the form submission,
  * this can cause unexpected results, including applying changes to the wrong objects.
- *
- * @jira TAPESTRY-1650 Tracking issue for Ajax support
  */
 public class GridRows
 {
@@ -86,6 +84,14 @@
     private Object _row;
 
     /**
+     * If true, then the CSS class on each <TD> cell will be omitted, which can reduce
+     * the amount of output from the component overall by a considerable amount. Leave this as false, the
+     * default, when you are leveraging the CSS to customize the look and feel of particular columns.
+     */
+    @Parameter
+    private boolean _lean;
+
+    /**
      * If true and the Loop is enclosed by a Form, then the normal state saving logic is turned off.
      * Defaults to false, enabling state saving logic within Forms.
      */
@@ -113,6 +119,8 @@
 
     public String getCellClass()
     {
+        if (_lean) return null;
+
         String id = _provider.getDataModel().get(_propertyName).getId();
 
         return id + "-cell";

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=610236&r1=610235&r2=610236&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 Tue Jan  8 16:05:19 2008
@@ -1,7 +1,7 @@
 <thead xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <tr>
-        <th t:type="Loop" source="columnNames" value="columnName" volatile="true" class="${columnModel.id}-header">
-           <a t:id="sort">${columnModel.label}</a>
+        <th t:type="Loop" source="columnNames" value="columnName" volatile="true" class="prop:headerClass">
+            <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}"/>

Added: 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=610236&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LeanGridDemo.tml Tue Jan  8 16:05:19 2008
@@ -0,0 +1,11 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+    <h1>Lean Grid Demo</h1>
+
+    <table t:type="Grid" source="tracks" row="track" lean="true">
+        <t:parameter name="ratingcell">
+            <t:outputRating rating="track.rating"/>
+        </t:parameter>
+    </table>
+
+</html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml?rev=610236&r1=610235&r2=610236&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml Tue Jan  8 16:05:19 2008
@@ -312,6 +312,11 @@
             -- use of the var: binding prefix
         </li>
 
+        <li>
+            <t:pagelink page="leangriddemo">Lean Grid Demo</t:pagelink>
+            -- Grid component with lean parameter turned on, to eliminate CSS class attributes in TD and TH elements
+        </li>
+
     </ul>
 
 </html>

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=610236&r1=610235&r2=610236&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 Tue Jan  8 16:05:19 2008
@@ -590,6 +590,7 @@
         assertTextPresent("[pageLoaded() was invoked.]");
     }
 
+
     /**
      * Basic Grid rendering, with a column render override. Also tests sorting.
      */
@@ -1340,6 +1341,21 @@
         start("Var Binding Demo");
 
         assertTextSeries("//li[%d]", 1, "1", "2", "3");
+    }
+
+    /**
+     * TAPESTRY-2021
+     */
+    @Test
+    public void lean_grid()
+    {
+        start("Lean Grid Demo");
+
+        assertTextSeries("//th[%d]", 1, "Title", "Album", "Artist", "Genre", "Play Count", "Rating");
+
+        // Selenium makes it pretty hard to check for a missing class.
+
+        // assertText("//th[1]/@class", "");
     }
 
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/LeanGridDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/LeanGridDemo.java?rev=610236&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/LeanGridDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/LeanGridDemo.java Tue Jan  8 16:05:19 2008
@@ -0,0 +1,20 @@
+// Copyright 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.
+// 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.integration.app1.pages;
+
+import org.apache.tapestry.integration.app1.pages.GridDemo;
+
+public class LeanGridDemo extends GridDemo
+{
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties?rev=610236&r1=610235&r2=610236&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties Tue Jan  8 16:05:19 2008
@@ -1,4 +1,4 @@
-# Copyright 2005, 2006, 2007 The Apache Software Foundation
+# Copyright 2005, 2006, 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.
@@ -21,9 +21,7 @@
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
 log4j.appender.A1.layout.ConversionPattern= %d{HH:mm:ss,SSS} [%p] %c{1} %m%n
 
-# log4j.category.org.apache.tapestry.services.TapestryModule.ComponentInstantiatorSource=debug
-
-log4j.category.org.apache.tapestry.integration.app1.pages=debug
+# log4j.category.org.apache.tapestry.integration.app1.pages=debug