You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/09/17 04:32:23 UTC

svn commit: r576238 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/components/ test/app1/WEB-INF/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/pages/

Author: hlship
Date: Sun Sep 16 19:32:23 2007
New Revision: 576238

URL: http://svn.apache.org/viewvc?rev=576238&view=rev
Log:
TAPESTRY-1742: Support removal and reordering of BeanModel properties inside Grid and BeanEditForm components

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/GridRemoveReorderDemo.html
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridRemoveReorderDemo.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Grid.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java

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=576238&r1=576237&r2=576238&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 Sun Sep 16 19:32:23 2007
@@ -27,6 +27,7 @@
 import org.apache.tapestry.corelib.data.GridPagerPosition;
 import org.apache.tapestry.grid.GridDataSource;
 import org.apache.tapestry.grid.GridModelProvider;
+import org.apache.tapestry.internal.beaneditor.BeanModelUtils;
 import org.apache.tapestry.internal.bindings.AbstractBinding;
 import org.apache.tapestry.ioc.services.TypeCoercer;
 import org.apache.tapestry.services.BeanModelSource;
@@ -94,6 +95,21 @@
     private BeanModel _model;
 
     /**
+     * A comma-separated list of property names to be removed from the {@link BeanModel}. The names
+     * are case-insensitive.
+     */
+    @Parameter(defaultPrefix = "literal")
+    private String _remove;
+
+    /**
+     * A comma-separated list of property names indicating the order in which the properties should
+     * be presented. The names are case insensitive. Any properties not indicated in the list will
+     * be appended to the end of the display order.
+     */
+    @Parameter(defaultPrefix = "literal")
+    private String _reorder;
+
+    /**
      * A Block to render instead of the table (and pager, etc.) when the source is empty. The
      * default is simply the text "There is no data to display". This parameter is used to customize
      * that message, possibly including components to allow the user to create new objects.
@@ -182,6 +198,10 @@
     Object setupRender()
     {
         _dataSource = _typeCoercer.coerce(_source, GridDataSource.class);
+
+        if (_remove != null) BeanModelUtils.remove(_model, _remove);
+
+        if (_reorder != null) BeanModelUtils.reorder(_model, _reorder);
 
         // If there's no rows, display the empty block placeholder.
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/GridRemoveReorderDemo.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/GridRemoveReorderDemo.html?rev=576238&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/GridRemoveReorderDemo.html (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/GridRemoveReorderDemo.html Sun Sep 16 19:32:23 2007
@@ -0,0 +1,11 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    
+    <h1>Grid Remove/Reorder Demo</h1>
+    
+    <table t:type="Grid" source="tracks" row="track" remove="playCount" reorder="rating,title" >
+        <t:parameter name="ratingcell">
+            <t:outputRating rating="track.rating"/>
+        </t:parameter>
+    </table>
+    
+</html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html?rev=576238&r1=576237&r2=576238&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/Start.html Sun Sep 16 19:32:23 2007
@@ -18,12 +18,12 @@
           </li>
           <li>
             <a t:type="PageLink" page="ParameterConflict">
-              Template Overriden by Class Page
+              Template Overridden by Class Page
             </a>
           </li>
           <li>
             <a t:type="PageLink" page="EnvironmentalDemo">
-              Environmental Annotation Useage
+              Environmental Annotation Usage
             </a>
           </li>
           <li>
@@ -145,6 +145,12 @@
           <li>
             <a t:type="PageLink" page="gridenumdemo">Grid Enum Demo</a>
             -- handling of enum types in the Grid
+          </li>
+          <li>
+            <t:pageLink page="GridRemoveReorderDemo">
+              Grid Remove/Reorder Demo
+            </t:pageLink>
+            -- handling of remove and reorder parameters
           </li>
           <li>
             <a t:type="PageLink" page="protected">Protected Page</a>

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=576238&r1=576237&r2=576238&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 Sun Sep 16 19:32:23 2007
@@ -140,7 +140,7 @@
     {
         open(BASE_URL);
 
-        clickAndWait("link=Environmental Annotation Useage");
+        clickAndWait("link=Environmental Annotation Usage");
 
         assertSourcePresent("[<strong>A message provided by the RenderableProvider component.</strong>]");
     }
@@ -462,7 +462,7 @@
     {
         open(BASE_URL);
 
-        clickAndWait("link=Template Overriden by Class Page");
+        clickAndWait("link=Template Overridden by Class Page");
 
         assertTextPresent("Output: ClassValue");
     }
@@ -717,6 +717,15 @@
         clickAndWait("link=1");
 
         assertText("//tr[1]/td[1]", "(untitled hidden track)");
+    }
+
+    @Test
+    public void grid_remove_reorder()
+    {
+        open(BASE_URL);
+        clickAndWait("link=Grid Remove/Reorder Demo");
+
+        assertTextSeries("//th[%d]", 1, "Rating", "Title", "Album", "Artist", "Genre");
     }
 
     @Test

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridRemoveReorderDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridRemoveReorderDemo.java?rev=576238&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridRemoveReorderDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/GridRemoveReorderDemo.java Sun Sep 16 19:32:23 2007
@@ -0,0 +1,20 @@
+// Copyright 2007 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;
+
+public class GridRemoveReorderDemo extends GridDemo
+{
+
+}