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 2007/02/14 00:18:14 UTC
svn commit: r507297 - in /tapestry/tapestry5/tapestry-core/trunk/src:
main/java/org/apache/tapestry/
main/java/org/apache/tapestry/corelib/components/
main/java/org/apache/tapestry/internal/
main/java/org/apache/tapestry/internal/structure/ main/resour...
Author: hlship
Date: Tue Feb 13 15:18:13 2007
New Revision: 507297
URL: http://svn.apache.org/viewvc?view=rev&rev=507297
Log:
Add support for Enum columns inside a Grid, using the same value-to-label rules used by EnumSelectModel.
Add a findBlock() method too ComponentResources.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/GridCell.html
tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/GridEnumDemo.html
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Urgency.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/GridEnumDemo.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/GridCell.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/ToDoItem.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/ToDoDatabaseImpl.java
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java Tue Feb 13 15:18:13 2007
@@ -127,12 +127,21 @@
* Returns a block from the component's template, referenced by its id.
*
* @param blockId
- * the id of the block
+ * the id of the block (case insensitive)
* @return the identified Block
* @throws BlockNotFoundException
* if no block with the given id exists
+ * @see #findBlock(String)
*/
Block getBlock(String blockId);
+ /**
+ * As with {@link #getBlock(String)}, but returns null if the block is not found.
+ *
+ * @param blockId
+ * the id of the block (case insensitive)
+ * @return the block, or null
+ */
+ Block findBlock(String blockId);
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java Tue Feb 13 15:18:13 2007
@@ -55,25 +55,10 @@
for (T value : values)
{
- String label = labelForValue(messages, prefix, value);
+ String label = TapestryUtils.getLabelForEnum(messages, prefix, value);
_options.add(new OptionModelImpl(label, false, value));
}
- }
-
- private String labelForValue(Messages messages, String prefix, Enum value)
- {
- String name = value.name();
-
- String key = prefix + "." + name;
-
- if (messages.contains(key))
- return messages.get(key);
-
- if (messages.contains(name))
- return messages.get(name);
-
- return TapestryUtils.toUserPresentable(name.toLowerCase());
}
/** Returns null. */
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/GridCell.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/GridCell.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/GridCell.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/GridCell.java Tue Feb 13 15:18:13 2007
@@ -17,8 +17,10 @@
import org.apache.tapestry.Block;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.Inject;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.beaneditor.PropertyModel;
+import org.apache.tapestry.internal.TapestryUtils;
public class GridCell
{
@@ -33,6 +35,9 @@
@Parameter(required = true)
private Object _row;
+ @Inject
+ private ComponentResources _gridCellResources;
+
Object beginRender(MarkupWriter writer)
{
Block override = _resources.getBlockParameter(_model.getId() + "Cell");
@@ -40,6 +45,11 @@
if (override != null)
return override;
+ Block builtin = _gridCellResources.findBlock(_model.getEditorType());
+
+ if (builtin != null)
+ return builtin;
+
Object value = _model.getConduit().get(_row);
if (value == null)
@@ -50,5 +60,24 @@
// Don't render anything else
return false;
+ }
+
+ /*
+ * When rendering a Block instead of a literal value, the template will start to render but its
+ * is effectively just some whitespace and we want to skip it entirely.
+ */
+ boolean beforeRenderTemplate()
+ {
+ return false;
+ }
+
+ public String getConvertedEnumValue()
+ {
+ Enum value = (Enum) _model.getConduit().get(_row);
+
+ if (value == null)
+ return null;
+
+ return TapestryUtils.getLabelForEnum(_resources.getMessages(), value);
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java Tue Feb 13 15:18:13 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -323,5 +323,35 @@
}
return depth;
+ }
+
+ /**
+ * @param messages
+ * the messages to search for the label
+ * @param prefix
+ * @param value
+ * to get a label for
+ * @return the label
+ */
+ public static String getLabelForEnum(Messages messages, String prefix, Enum value)
+ {
+ String name = value.name();
+
+ String key = prefix + "." + name;
+
+ if (messages.contains(key))
+ return messages.get(key);
+
+ if (messages.contains(name))
+ return messages.get(name);
+
+ return toUserPresentable(name.toLowerCase());
+ }
+
+ public static String getLabelForEnum(Messages messages, Enum value)
+ {
+ String prefix = IOCUtilities.toSimpleId(value.getClass().getName());
+
+ return getLabelForEnum(messages, prefix, value);
}
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java Tue Feb 13 15:18:13 2007
@@ -1047,15 +1047,20 @@
public Block getBlock(String id)
{
- notBlank(id, "id");
-
- Block result = InternalUtils.get(_blocks, id);
+ Block result = findBlock(id);
if (result == null)
throw new BlockNotFoundException(StructureMessages.blockNotFound(_completeId, id),
getLocation());
return result;
+ }
+
+ public Block findBlock(String id)
+ {
+ notBlank(id, "id");
+
+ return InternalUtils.get(_blocks, id);
}
public void addBlock(String blockId, Block block)
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java Tue Feb 13 15:18:13 2007
@@ -340,4 +340,9 @@
return null;
}
+ public Block findBlock(String blockId)
+ {
+ return _element.findBlock(blockId);
+ }
+
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/GridCell.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/GridCell.html?view=auto&rev=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/GridCell.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/GridCell.html Tue Feb 13 15:18:13 2007
@@ -0,0 +1,7 @@
+<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <t:block id="enum">
+ ${convertedEnumValue}
+ </t:block>
+
+</div>
\ No newline at end of file
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/GridEnumDemo.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/GridEnumDemo.html?view=auto&rev=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/GridEnumDemo.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/GridEnumDemo.html Tue Feb 13 15:18:13 2007
@@ -0,0 +1,10 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Grid Enum Demo</h1>
+
+ <table t:type="Grid" source="database.findAll()"/>
+
+ <p>
+ [<a t:type="ActionLink" t:id="reset">reset</a>]
+ </p>
+</html>
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html Tue Feb 13 15:18:13 2007
@@ -31,47 +31,47 @@
<a href="EnvironmentalDemo">Environmental Annotation Useage</a>
</li>
<li>
- <a href="Expansion">Expansion Page</a>
+ <a href="expansion">Expansion Page</a>
</li>
<li>
<a href="MissingPage">Missing Page</a> -- Used to test exception
reporting </li>
<li>
- <a href="BadTemplate">BadTemplate Page</a> -- More exception
- reporting </li>
+ <a href="BadTemplate">BadTemplate Page</a> -- More exception reporting </li>
<li>
- <a href="ActionPage">Action Page</a> -- tests fixture for
- ActionLink component </li>
+ <a href="ActionPage">Action Page</a> -- tests fixture for ActionLink
+ component </li>
<li>
- <a href="InstanceMixin">InstanceMixin</a> -- Mixin added to
- particular component instance </li>
+ <a href="InstanceMixin">InstanceMixin</a> -- Mixin added to particular
+ component instance </li>
<li>
- <a href="RenderPhaseOrder">RenderPhaseOrder</a> -- Order of
- operations when invoking render phase methods </li>
- <li><a href="SimpleForm">SimpleForm</a> -- first pass at writing Form
- and TextField components </li>
+ <a href="RenderPhaseOrder">RenderPhaseOrder</a> -- Order of operations
+ when invoking render phase methods </li>
+ <li><a href="SimpleForm">SimpleForm</a> -- first pass at writing Form and
+ TextField components </li>
<li>
<a href="NumberSelect">NumberSelect</a> -- passivate/activate page
context demo </li>
<li>
- <a href="Localization">Localization</a> -- accessing localized
- messages from the component catalog </li>
-
+ <a href="Localization">Localization</a> -- accessing localized messages
+ from the component catalog </li>
+ <li>
+ <a href="AssetDemo">AssetDemo</a> -- declaring an using Assets </li>
+
</ul>
</td>
<td>
- <ul><li>
- <a href="AssetDemo">AssetDemo</a> -- declaring an using Assets </li>
+ <ul>
<li>
<a href="ExpansionSubclass">ExpansionSubclass</a> -- components can
inherit templates from base classes </li>
<li>
- <a href="InjectComponentMismatch">InjectComponentMismatch</a> --
- check error reporting when @InjectComponent doesn't match the actual
- field type </li>
+ <a href="InjectComponentMismatch">InjectComponentMismatch</a> -- check
+ error reporting when @InjectComponent doesn't match the actual field
+ type </li>
<li>
- <a href="ParameterDefault">ParameterDefault</a> -- defaulter
- methods for component parameters </li>
+ <a href="ParameterDefault">ParameterDefault</a> -- defaulter methods for
+ component parameters </li>
<li>
<a href="ValidForm">ValidForm</a> -- server-side input validation</li>
<li>
@@ -80,32 +80,31 @@
<a href="PasswordFieldDemo">PasswordFieldDemo</a> -- test for the
PasswordField component </li>
<li>
- <a href="RenderComponentDemo">RenderComponentDemo</a> -- components
- that "nominate" other components to render </li>
+ <a href="RenderComponentDemo">RenderComponentDemo</a> -- components that
+ "nominate" other components to render </li>
<li>
- <a href="BlockDemo">BlockDemo</a> -- use of blocks to control
- rendering </li>
+ <a href="BlockDemo">BlockDemo</a> -- use of blocks to control rendering </li>
<li>
- <a href="ToDoListVolatile">ToDo List (Volatile)</a> -- Loops and
- Submit inside Form, volatile mode </li>
+ <a href="ToDoListVolatile">ToDo List (Volatile)</a> -- Loops and Submit
+ inside Form, volatile mode </li>
<li>
- <a href="ToDoList">ToDo List</a> -- Loops and Submit inside Form
- using a primary key encoder </li>
+ <a href="ToDoList">ToDo List</a> -- Loops and Submit inside Form using a
+ primary key encoder </li>
<li>
- <a href="FlashDemo">FlashDemo</a> -- demonstrate "flash" persistence
- </li>
+ <a href="FlashDemo">FlashDemo</a> -- demonstrate "flash" persistence </li>
<li>
- <a href="beaneditordemo">BeanEditor Demo</a> -- demonstrate the BeanEditor mega-component
- </li>
+ <a href="beaneditordemo">BeanEditor Demo</a> -- demonstrate the
+ BeanEditor mega-component </li>
<li>
- <a href="pageloadeddemo">PageLoaded Demo</a> -- shows that page lifecycle methods are invoked
- </li>
+ <a href="pageloadeddemo">PageLoaded Demo</a> -- shows that page
+ lifecycle methods are invoked </li>
<li>
- <a href="griddemo">Grid Demo</a> -- default Grid component
- </li>
+ <a href="griddemo">Grid Demo</a> -- default Grid component </li>
<li>
- <a href="nullgrid">Null Grid</a> -- handling of null source for Grid
- </li>
+ <a href="nullgrid">Null Grid</a> -- handling of null source for Grid </li>
+ <li>
+ <a href="gridenumdemo">Grid Enum Demo</a> -- handling of enum types in
+ the Grid </li>
</ul>
</td>
</tr>
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Tue Feb 13 15:18:13 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -675,19 +675,19 @@
clickAndWait("link=" + linkLabel);
clickAndWait("reset");
- assertValue("title", "Ditch Struts");
- assertValue("title_0", "Eliminate JSF");
- assertValue("title_1", "Conquer Rife");
-
- _selenium.type("title", "Ditch Struts - today");
- _selenium.type("title_0", "Eliminate JSF - immediately");
- _selenium.type("title_1", "Conquer Rife - post haste");
+ assertValue("title", "End World Hunger");
+ assertValue("title_0", "Develop Faster-Than-Light Travel");
+ assertValue("title_1", "Cure Common Cold");
+
+ _selenium.type("title", "End World Hunger - today");
+ _selenium.type("title_0", "Develop Faster-Than-Light Travel - immediately");
+ _selenium.type("title_1", "Cure Common Cold - post haste");
clickAndWait("//input[@value='Update ToDos']");
- assertValue("title", "Ditch Struts - today");
- assertValue("title_0", "Eliminate JSF - immediately");
- assertValue("title_1", "Conquer Rife - post haste");
+ assertValue("title", "End World Hunger - today");
+ assertValue("title_0", "Develop Faster-Than-Light Travel - immediately");
+ assertValue("title_1", "Cure Common Cold - post haste");
clickAndWait("addNew");
@@ -695,9 +695,9 @@
clickAndWait("//input[@value='Update ToDos']");
- assertValue("title", "Ditch Struts - today");
- assertValue("title_0", "Eliminate JSF - immediately");
- assertValue("title_1", "Conquer Rife - post haste");
+ assertValue("title", "End World Hunger - today");
+ assertValue("title_0", "Develop Faster-Than-Light Travel - immediately");
+ assertValue("title_1", "Cure Common Cold - post haste");
assertValue("title_2", "Conquer World");
}
@@ -820,6 +820,18 @@
clickAndWait("link=69");
assertText("//tr[22]/td[1]", "radioioAmbient");
+ }
+
+ @Test
+ public void grid_enum_display()
+ {
+ _selenium.open(BASE_URL);
+ clickAndWait("link=Grid Enum Demo");
+ clickAndWait("link=reset");
+
+ assertTextSeries("//tr[1]/td[%d]", 2, "End World Hunger", "Medium");
+ assertTextSeries("//tr[2]/td[%d]", 2, "Develop Faster-Than-Light Travel", "High");
+ assertTextSeries("//tr[3]/td[%d]", 2, "Cure Common Cold", "Low");
}
@Test
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/ToDoItem.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/ToDoItem.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/ToDoItem.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/ToDoItem.java Tue Feb 13 15:18:13 2007
@@ -26,6 +26,8 @@
private int _order;
+ private Urgency _urgency = Urgency.MEDIUM;
+
@Override
public String toString()
{
@@ -55,24 +57,34 @@
_id = id;
}
- public int getOrder()
+ public String getTitle()
{
- return _order;
+ return _title;
}
- public void setOrder(int order)
+ public void setTitle(String title)
{
- _order = order;
+ _title = title;
}
- public String getTitle()
+ public Urgency getUrgency()
{
- return _title;
+ return _urgency;
}
- public void setTitle(String title)
+ public void setUrgency(Urgency urgency)
{
- _title = title;
+ _urgency = urgency;
+ }
+
+ public int getOrder()
+ {
+ return _order;
+ }
+
+ public void setOrder(int order)
+ {
+ _order = order;
}
}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Urgency.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Urgency.java?view=auto&rev=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Urgency.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Urgency.java Tue Feb 13 15:18:13 2007
@@ -0,0 +1,19 @@
+// 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.data;
+
+public enum Urgency {
+ LOW, MEDIUM, HIGH
+}
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/GridEnumDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/GridEnumDemo.java?view=auto&rev=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/GridEnumDemo.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/GridEnumDemo.java Tue Feb 13 15:18:13 2007
@@ -0,0 +1,35 @@
+// 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;
+
+import org.apache.tapestry.annotations.Inject;
+import org.apache.tapestry.integration.app1.services.ToDoDatabase;
+
+/** Used to demonstrate the built-in support for enum types. */
+public class GridEnumDemo
+{
+ @Inject
+ private ToDoDatabase _database;
+
+ void onActionFromReset()
+ {
+ _database.reset();
+ }
+
+ public ToDoDatabase getDatabase()
+ {
+ return _database;
+ }
+}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/ToDoDatabaseImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/ToDoDatabaseImpl.java?view=diff&rev=507297&r1=507296&r2=507297
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/ToDoDatabaseImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/ToDoDatabaseImpl.java Tue Feb 13 15:18:13 2007
@@ -23,6 +23,7 @@
import java.util.Map;
import org.apache.tapestry.integration.app1.data.ToDoItem;
+import org.apache.tapestry.integration.app1.data.Urgency;
/**
* We clone everything that comes in or goes out. This does a reasonable job of simulating an
@@ -45,17 +46,18 @@
public void reset()
{
_items.clear();
-
- add("Ditch Struts", 1);
- add("Eliminate JSF", 2);
- add("Conquer Rife", 3);
+
+ add("End World Hunger", Urgency.MEDIUM, 1);
+ add("Develop Faster-Than-Light Travel", Urgency.HIGH, 2);
+ add("Cure Common Cold", Urgency.LOW, 3);
}
- private void add(String title, int order)
+ private void add(String title, Urgency urgency, int order)
{
ToDoItem item = new ToDoItem();
item.setTitle(title);
+ item.setUrgency(urgency);
item.setOrder(order);
add(item);