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/03/09 21:00:26 UTC
svn commit: r635341 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/beaneditor/
main/java/org/apache/tapestry/corelib/components/
main/java/org/apache/tapestry/internal/beaneditor/ site/apt/ test/app1/
test/java/org/apac...
Author: hlship
Date: Sun Mar 9 13:00:21 2008
New Revision: 635341
URL: http://svn.apache.org/viewvc?rev=635341&view=rev
Log:
TAPESTRY-2241: Add new parameter "include" to BeanEditor, Grid, etc. to limit properties to a provided list, and rename existing "remove" parameter to "exclude"
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/BeanModel.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.xdoc
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.xdoc
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/Select.xdoc
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelUtils.java
tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BeanEditRemoveReorder.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/beaneditor/BeanModelUtilsTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/BeanModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/BeanModel.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/BeanModel.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/BeanModel.java Sun Mar 9 13:00:21 2008
@@ -118,17 +118,26 @@
* Removes the named properties from the model, if present. It is not considered an error to remove a property that
* does not exist.
*
- * @param propertyName the names of properties to be removed (case insensitive)
+ * @param propertyNames the names of properties to be removed (case insensitive)
* @return the model for further modifications
*/
- BeanModel remove(String... propertyName);
+ BeanModel exclude(String... propertyNames);
/**
* Re-orders the properties of the model into the specified order. Existing properties that are not indicated are
* retained, but ordered to the end of the list.
*
- * @param propertyName property names in order they should be displayed (case insensitive)
+ * @param propertyNames property names in order they should be displayed (case insensitive)
* @return the model for further modifications
*/
- BeanModel reorder(String... propertyName);
+ BeanModel reorder(String... propertyNames);
+
+ /**
+ * Re-orders the properties of the model into the specified order. Existing properties that are not indicated are
+ * <<removed>>.
+ *
+ * @param propertyNames the names of properties to be retained
+ * @return the model for further modifications
+ */
+ BeanModel include(String... propertyNames);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java Sun Mar 9 13:00:21 2008
@@ -16,8 +16,9 @@
import org.apache.tapestry.Binding;
import org.apache.tapestry.ComponentResources;
-import org.apache.tapestry.annotations.Property;
+import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.annotations.Property;
import org.apache.tapestry.annotations.SupportsInformalParameters;
import org.apache.tapestry.beaneditor.BeanModel;
import org.apache.tapestry.beaneditor.PropertyModel;
@@ -62,18 +63,27 @@
private BeanModel _model;
/**
+ * A comma-separated list of property names to be retained from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * Only these properties will be retained, and the properties will also be reordered. The names are
+ * case-insensitive.
+ */
+ @SuppressWarnings("unused")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _include;
+
+ /**
* 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;
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _exclude;
/**
* 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")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
private String _reorder;
/**
@@ -105,15 +115,13 @@
{
return _defaultProvider.defaultBinding("object", _resources);
}
-
+
void setupRender()
{
if (_model == null) _model = _modelSource.create(_object.getClass(), false, _overrides
.getContainerResources());
- if (_remove != null) BeanModelUtils.remove(_model, _remove);
-
- if (_reorder != null) BeanModelUtils.reorder(_model, _reorder);
+ BeanModelUtils.modify(_model, null, _include, _exclude, _reorder);
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.xdoc
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.xdoc?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.xdoc (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.xdoc Sun Mar 9 13:00:21 2008
@@ -127,12 +127,13 @@
<p>
You can accomplish the same thing by changing the order of the
- getter methods in the bean class. The default order in which properties are
- displayed is not alphabetical, it is the order of the getter methods.
+ getter methods in the bean class. The default order for properties is not alphabetical,
+ it is the order of the getter methods.
</p>
+
<p>
- You can also remove properties with the remove parameter, which is equivalent to the
+ You can also remove properties with the exclude parameter, which is equivalent to the
@NonVisual annotation.
</p>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java Sun Mar 9 13:00:21 2008
@@ -44,7 +44,7 @@
/**
* The text label for the submit button of the form, by default "Create/Update".
*/
- @Parameter(value = "message:submit-label", defaultPrefix = "literal")
+ @Parameter(value = "message:submit-label", defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
@Property
private String _submitLabel;
@@ -60,12 +60,21 @@
private Object _object;
/**
- * A comma-separated list of property names to be removed from the {@link BeanModel}. The names are
+ * A comma-separated list of property names to be retained from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * Only these properties will be retained, and the properties will also be reordered. The names are
* case-insensitive.
*/
@SuppressWarnings("unused")
- @Parameter(defaultPrefix = "literal")
- private String _remove;
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _include;
+
+ /**
+ * A comma-separated list of property names to be removed from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * The names are case-insensitive.
+ */
+ @SuppressWarnings("unused")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _exclude;
/**
* A comma-separated list of property names indicating the order in which the properties should be presented. The
@@ -73,7 +82,7 @@
* order.
*/
@SuppressWarnings("unused")
- @Parameter(defaultPrefix = "literal")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
private String _reorder;
/**
@@ -127,7 +136,7 @@
_model = _beanModelSource.create(beanType, true, _resources.getContainerResources());
}
- BeanModelUtils.modify(_model, null, _remove, _reorder);
+ BeanModelUtils.modify(_model, null, _include, _exclude, _reorder);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.xdoc
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.xdoc?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.xdoc (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.xdoc Sun Mar 9 13:00:21 2008
@@ -300,11 +300,12 @@
<p>
You can accomplish the same thing by changing the order of the
- getter methods in the bean class (that sets the default order).
+ getter methods in the bean class. The default order for properties is not alphabetical,
+ it is the order of the getter methods.
</p>
<p>
- You can also remove properties with the remove parameter, which is equivalent to the
+ You can also remove properties with the exclude parameter, which is equivalent to the
@NonVisual annotation.
</p>
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=635341&r1=635340&r2=635341&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 Sun Mar 9 13:00:21 2008
@@ -17,9 +17,10 @@
import org.apache.tapestry.Binding;
import org.apache.tapestry.ComponentAction;
import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.annotations.Environmental;
-import org.apache.tapestry.annotations.Property;
import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.annotations.Property;
import org.apache.tapestry.annotations.SupportsInformalParameters;
import org.apache.tapestry.beaneditor.BeanModel;
import org.apache.tapestry.corelib.internal.InternalMessages;
@@ -56,18 +57,27 @@
private Object _object;
/**
- * A comma-separated list of property names to be removed from the {@link BeanModel}. The names are
+ * A comma-separated list of property names to be retained from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * Only these properties will be retained, and the properties will also be reordered. The names are
* case-insensitive.
*/
- @Parameter(defaultPrefix = "literal")
- private String _remove;
+ @SuppressWarnings("unused")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _include;
+
+ /**
+ * A comma-separated list of property names to be removed from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * The names are case-insensitive.
+ */
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _exclude;
/**
* 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")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
private String _reorder;
/**
@@ -133,7 +143,7 @@
_model = _modelSource.create(type, true, _overrides.getContainerResources());
}
- BeanModelUtils.modify(_model, null, _remove, _reorder);
+ BeanModelUtils.modify(_model, null, _include, _exclude, _reorder);
// The only problem here is that if the bound property is backed by a persistent field, it
// is assigned (and stored to the session, and propagated around the cluster) first,
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=635341&r1=635340&r2=635341&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 Mar 9 13:00:21 2008
@@ -112,11 +112,21 @@
private String _add;
/**
+ * A comma-separated list of property names to be retained from the {@link org.apache.tapestry.beaneditor.BeanModel}.
+ * Only these properties will be retained, and the properties will also be reordered. The names are
+ * case-insensitive.
+ */
+ @SuppressWarnings("unused")
+ @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+ private String _include;
+
+
+ /**
* A comma-separated list of property names to be removed from the {@link org.apache.tapestry.beaneditor.BeanModel}.
* The names are case-insensitive.
*/
@Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
- private String _remove;
+ private String _exclude;
/**
* A comma-separated list of property names indicating the order in which the properties should be presented. The
@@ -369,7 +379,7 @@
if (availableRows == 0) return;
- BeanModelUtils.modify(_model, _add, _remove, _reorder);
+ BeanModelUtils.modify(_model, _add, _include, _exclude, _reorder);
int maxPage = ((availableRows - 1) / _rowsPerPage) + 1;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.xdoc
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.xdoc?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.xdoc (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.xdoc Sun Mar 9 13:00:21 2008
@@ -50,6 +50,29 @@
</subsection>
+<subsection name="SelectColor.java">
+
+<source><![CDATA[
+public class SelectColor
+{
+ private String _color;
+
+ @Validate("required")
+ public String getColor() { return _color; }
+
+ public void setColor(String color) { _color = color; }
+}]]></source>
+
+ <p>
+ Placing the @Validate annotation on the field indicates that it is required. This prevents the
+ select component from including a blank option for the field (though this can be overridden).
+ Without the @Validate, it would be possible for the user to select a blank value, and null would
+ be assigned to the color property of SelectColor. This might be appropriate for a search form, but
+ not for an edit form.
+ </p>
+
+</subsection>
+
</section>
<section name="Enum Example">
@@ -109,6 +132,7 @@
@Persist
private CardType _type;
+ @Validate("required")
public CardType getType() { return _type; }
public void setType(CardType type) { _type = type; }
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelImpl.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelImpl.java Sun Mar 9 13:00:21 2008
@@ -186,7 +186,7 @@
return CollectionFactory.newList(_propertyNames);
}
- public BeanModel remove(String... propertyNames)
+ public BeanModel exclude(String... propertyNames)
{
for (String propertyName : propertyNames)
{
@@ -206,12 +206,12 @@
return this;
}
- public BeanModel reorder(String... propertyName)
+ public BeanModel reorder(String... propertyNames)
{
List<String> remainingPropertyNames = newList(_propertyNames);
List<String> reorderedPropertyNames = newList();
- for (String name : propertyName)
+ for (String name : propertyNames)
{
PropertyModel model = get(name);
@@ -228,6 +228,33 @@
// Any unspecified names are ordered to the end. Don't want them? Remove them instead.
_propertyNames.addAll(remainingPropertyNames);
+
+ return this;
+ }
+
+ public BeanModel include(String... propertyNames)
+ {
+ List<String> reorderedPropertyNames = newList();
+ Map<String, PropertyModel> reduced = CollectionFactory.newCaseInsensitiveMap();
+
+
+ for (String name : propertyNames)
+ {
+
+ PropertyModel model = get(name);
+
+ String canonical = model.getPropertyName();
+
+ reorderedPropertyNames.add(canonical);
+ reduced.put(canonical, model);
+
+ }
+
+ _propertyNames.clear();
+ _propertyNames.addAll(reorderedPropertyNames);
+
+ _properties.clear();
+ _properties.putAll(reduced);
return this;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelUtils.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/BeanModelUtils.java Sun Mar 9 13:00:21 2008
@@ -28,15 +28,19 @@
*
* @param model to modifiy
* @param addPropertyNames comma seperated list of property names to add, or null
- * @param removePropertyNames comma seperated list of property names to remove, or null
+ * @param includePropertyNames comma seperated list of property names to include
+ * @param excludePropertyNames comma seperated list of property names to exclude, or null
* @param reorderPropertyNames comma seperated list of property names to reorder, or null
*/
- public static void modify(BeanModel model, String addPropertyNames, String removePropertyNames,
+ public static void modify(BeanModel model, String addPropertyNames, String includePropertyNames,
+ String excludePropertyNames,
String reorderPropertyNames)
{
if (addPropertyNames != null) add(model, addPropertyNames);
- if (removePropertyNames != null) remove(model, removePropertyNames);
+ if (includePropertyNames != null) include(model, includePropertyNames);
+
+ if (excludePropertyNames != null) exclude(model, excludePropertyNames);
if (reorderPropertyNames != null) reorder(model, reorderPropertyNames);
}
@@ -61,11 +65,19 @@
*
* @param model
* @param propertyNames comma-separated list of property names
- * @see BeanModel#remove(String...)
+ * @see BeanModel#exclude(String...)
+ */
+ public static void exclude(BeanModel model, String propertyNames)
+ {
+ model.exclude(split(propertyNames));
+ }
+
+ /**
+ * Selects a subset of the properties to keep, and reorders them.
*/
- public static void remove(BeanModel model, String propertyNames)
+ public static void include(BeanModel model, String propertyNames)
{
- model.remove(split(propertyNames));
+ model.include(split(propertyNames));
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt Sun Mar 9 13:00:21 2008
@@ -73,4 +73,11 @@
* ApplicationGlobals and RequestGlobals
The <store> methods on these two interfaces were renamed to be more explicit. These are not methods typically
- invoked from user code.
\ No newline at end of file
+ invoked from user code.
+
+* BeanModel
+
+ The <<<remove()>>> method of {{{../apidocs/org/apache/tapestry/beaneditor/BeanModel.html}BeanModel}} was renamed
+ to <<<exclude()>>>, and a new method, <<<include()>>> was added. The <<remove>> parameter of BeanEditForm,
+ BeanEditor, BeanDisplay and Grid were all renamed to <<exclude>> as well (and a new <<include>> parameter was added
+ to each).
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BeanEditRemoveReorder.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BeanEditRemoveReorder.tml?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BeanEditRemoveReorder.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BeanEditRemoveReorder.tml Sun Mar 9 13:00:21 2008
@@ -1,7 +1,7 @@
<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<h1>${pageTitle}</h1>
- <form t:id="registrationData" submitlabel="Register" remove="birthYear" reorder="lastname,firstname">
+ <form t:id="registrationData" submitlabel="Register" exclude="birthYear" reorder="lastname,firstname">
<t:parameter name="firstName">
<t:label for="firstName"/>
Modified: 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=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/AddedGridColumnsDemo.java Sun Mar 9 13:00:21 2008
@@ -46,7 +46,7 @@
{
_model = _source.create(Track.class, true, _resources);
- _model.remove("album", "artist", "genre", "playcount", "rating");
+ _model.exclude("album", "artist", "genre", "playcount", "rating");
_model.add("viewlink", null);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/beaneditor/BeanModelUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/beaneditor/BeanModelUtilsTest.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/beaneditor/BeanModelUtilsTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/beaneditor/BeanModelUtilsTest.java Sun Mar 9 13:00:21 2008
@@ -45,15 +45,15 @@
}
@Test
- public void remove()
+ public void exclude()
{
BeanModel model = mockBeanModel();
- expect(model.remove("fred", "barney")).andReturn(model);
+ expect(model.exclude("fred", "barney")).andReturn(model);
replay();
- BeanModelUtils.remove(model, "fred,barney");
+ BeanModelUtils.exclude(model, "fred,barney");
verify();
}
@@ -96,7 +96,7 @@
replay();
- BeanModelUtils.modify(model, null, null, null);
+ BeanModelUtils.modify(model, null, null, null, null);
verify();
}
@@ -111,13 +111,27 @@
expect(model.add("fred", null)).andReturn(fred);
expect(model.add("barney", null)).andReturn(barney);
- expect(model.remove("pebbles", "bambam")).andReturn(model);
+ expect(model.exclude("pebbles", "bambam")).andReturn(model);
expect(model.reorder("wilma", "betty")).andReturn(model);
replay();
- BeanModelUtils.modify(model, "fred,barney", "pebbles,bambam", "wilma,betty");
+ BeanModelUtils.modify(model, "fred,barney", null, "pebbles,bambam", "wilma,betty");
+
+ verify();
+ }
+
+ @Test
+ public void modify_include()
+ {
+ BeanModel model = mockBeanModel();
+
+ expect(model.include("fred", "wilma")).andReturn(model);
+
+ replay();
+
+ BeanModelUtils.modify(model, null, "fred,wilma", null, null);
verify();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java?rev=635341&r1=635340&r2=635341&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java Sun Mar 9 13:00:21 2008
@@ -104,6 +104,30 @@
}
@Test
+ public void include_properties()
+ {
+ ComponentResources resources = mockComponentResources();
+ Messages messages = mockMessages();
+
+ train_getMessages(resources, messages);
+ stub_contains(messages, false);
+
+ replay();
+
+ BeanModel model = _source.create(SimpleBean.class, true, resources);
+
+ assertSame(model.getBeanType(), SimpleBean.class);
+
+ model.include("lastname", "firstname");
+
+ // Based on order of the getter methods (no longer alphabetical)
+
+ assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "firstName"));
+
+ verify();
+ }
+
+ @Test
public void add_before()
{
ComponentResources resources = mockComponentResources();
@@ -137,7 +161,9 @@
verify();
}
- /** TAPESTRY-2202 */
+ /**
+ * TAPESTRY-2202
+ */
@Test
public void new_instance()
{
@@ -158,7 +184,7 @@
SimpleBean s2 = model.newInstance();
assertNotNull(s2);
- assertNotSame(s1, s2);
+ assertNotSame(s1, s2);
verify();
}
@@ -176,7 +202,7 @@
BeanModel model = _source.create(SimpleBean.class, true, resources);
- model.remove("firstname");
+ model.exclude("firstname");
assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age"));
@@ -568,7 +594,7 @@
}
@Test
- public void remove_property()
+ public void exclude_property()
{
ComponentResources resources = mockComponentResources();
Messages messages = mockMessages();
@@ -580,7 +606,7 @@
BeanModel model = _source.create(SimpleBean.class, true, resources);
- assertSame(model.remove("age"), model);
+ assertSame(model.exclude("age"), model);
assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName"));
@@ -588,7 +614,7 @@
}
@Test
- public void remove_unknown_property_is_noop()
+ public void exclude_unknown_property_is_noop()
{
ComponentResources resources = mockComponentResources();
Messages messages = mockMessages();
@@ -600,7 +626,7 @@
BeanModel model = _source.create(SimpleBean.class, true, resources);
- assertSame(model.remove("frobozz"), model);
+ assertSame(model.exclude("frobozz"), model);
assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));