Author: hlship
Date: Thu Jan 24 09:56:09 2008
New Revision: 614943
URL: http://svn.apache.org/viewvc?rev=614943&view=rev
Log:
TAPESTRY-1416: Add support for programatically adding new columns to a Grid
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/AddedGridColumnsDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java
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/Grid.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/default.css
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/app.properties
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/Start.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=614943&r1=614942&r2=614943&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 Jan 24 09:56:09 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.
@@ -17,6 +17,7 @@
import org.apache.tapestry.Block;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.PropertyConduit;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.beaneditor.PropertyModel;
import org.apache.tapestry.ioc.Messages;
@@ -26,13 +27,13 @@
import org.apache.tapestry.services.PropertyOutputContext;
/**
- * Base class for components that output a property value using a [EMAIL
PROTECTED] PropertyModel}. There's a
- * relationship between such a component and its container, as the container
may provide messages in
- * its message catalog needed by the [EMAIL PROTECTED] Block}s that render the
values. In addition, the
- * component may be passed Block parameters that are output overrides for
specified properties.
+ * Base class for components that output a property value using a [EMAIL
PROTECTED] PropertyModel}. There's a relationship between
+ * such a component and its container, as the container may provide messages
in its message catalog needed by the [EMAIL PROTECTED]
+ * Block}s that render the values. In addition, the component may be passed
Block parameters that are output overrides
+ * for specified properties.
* <p/>
- * Subclasses will implement a <code>beginRender()</code> method that invokes
- * [EMAIL PROTECTED] #renderPropertyValue(MarkupWriter, String)}.
+ * Subclasses will implement a <code>beginRender()</code> method that invokes
[EMAIL PROTECTED] #renderPropertyValue(MarkupWriter,
+ * String)}.
*
* @see BeanBlockSource
*/
@@ -46,15 +47,15 @@
private PropertyModel _model;
/**
- * Resources used to search for block parameter overrides (this is
normally the enclosing Grid
- * component's resources).
+ * Resources used to search for block parameter overrides (this is
normally the enclosing Grid component's
+ * resources).
*/
@Parameter(required = true)
private ComponentResources _overrides;
/**
- * Identifies the object being rendered. The component will extract a
property from the object
- * and render its value (or delegate to a [EMAIL PROTECTED] Block} that
will do so).
+ * Identifies the object being rendered. The component will extract a
property from the object and render its value
+ * (or delegate to a [EMAIL PROTECTED] Block} that will do so).
*/
@Parameter(required = true)
private Object _object;
@@ -73,9 +74,8 @@
}
/**
- * Invoked from subclasses to do the rendering. The subclass controls the
naming convention for
- * locating an overriding Block parameter (it is the name of the property
possibly suffixed with
- * a value).
+ * Invoked from subclasses to do the rendering. The subclass controls the
naming convention for locating an
+ * overriding Block parameter (it is the name of the property possibly
suffixed with a value).
*/
protected Object renderPropertyValue(MarkupWriter writer, String
overrideBlockId)
{
@@ -133,7 +133,9 @@
private Object readPropertyForObject()
{
- return _model.getConduit().get(_object);
+ PropertyConduit conduit = _model.getConduit();
+
+ return conduit == null ? null : conduit.get(_object);
}
private Messages getOverrideMessages()
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=614943&r1=614942&r2=614943&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 Jan 24 09:56:09 2008
@@ -66,7 +66,7 @@
* Defines where the pager (used to navigate within the "pages" of
results) should be displayed: "top", "bottom",
* "both" or "none".
*/
- @Parameter(value = "bottom", defaultPrefix = "literal")
+ @Parameter(value = "top", defaultPrefix = "literal")
private GridPagerPosition _pagerPosition;
@Persist
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/default.css
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/default.css?rev=614943&r1=614942&r2=614943&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/default.css
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/default.css
Thu Jan 24 09:56:09 2008
@@ -42,6 +42,10 @@
margin-left: 4px;
}
+IMG.t-sort-icon {
+ margin-left: 4px;
+}
+
DIV.t-exception-message {
font-style: italic;
font-size: 12pt;
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/AddedGridColumnsDemo.tml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/AddedGridColumnsDemo.tml?rev=614943&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/AddedGridColumnsDemo.tml
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/AddedGridColumnsDemo.tml
Thu Jan 24 09:56:09 2008
@@ -0,0 +1,12 @@
+<html t:type="Border"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Added Columns Grid Demo</h1>
+
+ <table t:id="grid">
+ <t:parameter name="viewlinkcell">
+ <t:actionlink t:id="view" context="track.title">view</t:actionlink>
+ </t:parameter>
+ </table>
+
+
+</html>
\ No newline at end of file
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/app.properties
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/app.properties?rev=614943&r1=614942&r2=614943&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/app.properties
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/app.properties
Thu Jan 24 09:56:09 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.
@@ -12,4 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-app-catalog-status=Application Catalog Working
\ No newline at end of file
+app-catalog-status=Application Catalog Working
+
+viewlink-label=View
\ No newline at end of file
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=614943&r1=614942&r2=614943&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 Jan 24 09:56:09 2008
@@ -1479,4 +1479,19 @@
"org.apache.tapestry.ioc.internal.util.TapestryException",
"java.lang.NumberFormatException");
}
+
+ /**
+ * TAPESTRY-1416
+ */
+
+ @Test
+ public void adding_new_columns_to_grid_programattically()
+ {
+ start("Added Grid Columns Demo", "Title Length");
+
+ assertTextSeries("//th[%d]", 1, "Title", "View", "Title Length",
"Dummy");
+
+ // The rendered becomes just a blank string.
+ assertTextSeries("//tr[1]/td[%d]", 1, "7", "view", "1", "");
+ }
}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java?rev=614943&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java
Thu Jan 24 09:56:09 2008
@@ -0,0 +1,79 @@
+// 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.ComponentResources;
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.beaneditor.BeanModel;
+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;
+import org.apache.tapestry.services.BeanModelSource;
+
+import java.util.List;
+
+public class AddedGridColumnsDemo
+{
+ @Component(parameters = {"source=tracks", "row=track", "model=model"})
+ private Grid _grid;
+
+ @Inject
+ private MusicLibrary _library;
+
+ private Track _track;
+
+ @Inject
+ private BeanModelSource _source;
+
+ private final BeanModel _model;
+
+ @Inject
+ private ComponentResources _resources;
+
+ {
+ _model = _source.create(Track.class, true, _resources);
+
+ _model.remove("album", "artist", "genre", "playcount", "rating");
+
+ _model.add("viewlink", null);
+
+ _model.add("title.length()").label("Title Length");
+
+ // This is to test the case where there's no property conduit or
override block.
+
+ _model.add("dummy", null);
+ }
+
+ public Track getTrack()
+ {
+ return _track;
+ }
+
+ public void setTrack(Track track)
+ {
+ _track = track;
+ }
+
+ public List<Track> getTracks()
+ {
+ return _library.getTracks();
+ }
+
+ public BeanModel getModel()
+ {
+ return _model;
+ }
+}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java?rev=614943&r1=614942&r2=614943&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
Thu Jan 24 09:56:09 2008
@@ -206,7 +206,9 @@
new Item("OverrideValidationDecorator", "Override Validation
Decorator",
"override the default validation decorator"),
- new Item("ExceptionEventDemo", "Exception Event Demo", "handling
component event exceptions"));
+ new Item("ExceptionEventDemo", "Exception Event Demo", "handling
component event exceptions"),
+
+ new Item("AddedGridColumnsDemo", "Added Grid Columns Demo",
"programatically adding grid columns"));
static
{