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/01/04 21:04:45 UTC
svn commit: r492710 - in
/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry:
corelib/base/AbstractField.java corelib/base/AbstractTextField.java
services/TapestryModule.java
Author: hlship
Date: Thu Jan 4 12:04:45 2007
New Revision: 492710
URL: http://svn.apache.org/viewvc?view=rev&rev=492710
Log:
Only bind a field to a container property (matching the field's id) if such a property actually exists.
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?view=diff&rev=492710&r1=492709&r2=492710
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java Thu Jan 4 12:04:45 2007
@@ -34,6 +34,8 @@
import org.apache.tapestry.internal.bindings.LiteralBinding;
import org.apache.tapestry.internal.services.FormParameterLookup;
import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.services.PropertyAccess;
+import org.apache.tapestry.runtime.Component;
import org.apache.tapestry.services.Binding;
import org.apache.tapestry.services.BindingSource;
import org.apache.tapestry.services.FormSupport;
@@ -122,6 +124,12 @@
@Inject("service:tapestry.internal.FormParameterLookup")
private FormParameterLookup _paramLookup;
+ @Inject("infrastructure:BindingSource")
+ private BindingSource _bindingSource;
+
+ @Inject("infrastructure:PropertyAccess")
+ private PropertyAccess _propertyAccess;
+
final Binding defaultLabel()
{
Messages containerMessages = _resources.getContainer().getComponentResources()
@@ -185,17 +193,31 @@
processSubmission(_paramLookup, _elementName);
}
- @Inject("infrastructure:BindingSource")
- private BindingSource _bindingSource;
-
- /** Used by subclasses to create a default binding to a property of the container. */
+ /**
+ * Used by subclasses to create a default binding to a property of the container.
+ *
+ * @return a binding to the property, or null if the container does not have a corresponding
+ * property
+ */
protected final Binding createDefaultParameterBinding(String parameterName)
{
String componentId = _resources.getId();
- ComponentResources container = _resources.getContainerResources();
+ Component container = _resources.getContainer();
- return _bindingSource.newBinding("default " + parameterName, container, componentId);
+ // Only provide a default binding if the container actually contains the property.
+ // This sets up an error condition for when the value parameter is not bound, and
+ // the binding can't be deduced.
+
+ if (_propertyAccess.getAdapter(container).getPropertyAdapter(componentId) == null)
+ return null;
+
+ ComponentResources containerResources = _resources.getContainerResources();
+
+ return _bindingSource.newBinding(
+ "default " + parameterName,
+ containerResources,
+ componentId);
}
/**
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java?view=diff&rev=492710&r1=492709&r2=492710
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java Thu Jan 4 12:04:45 2007
@@ -89,7 +89,7 @@
/**
* The default value is a property of the container whose name matches the component's id. May
- * return null if the container does not have a matching property (not yet implemented).
+ * return null if the container does not have a matching property.
*/
final Binding defaultValue()
{
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=492710&r1=492709&r2=492710
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java Thu Jan 4 12:04:45 2007
@@ -128,6 +128,7 @@
import org.apache.tapestry.ioc.services.ChainBuilder;
import org.apache.tapestry.ioc.services.ClassFactory;
import org.apache.tapestry.ioc.services.PipelineBuilder;
+import org.apache.tapestry.ioc.services.PropertyAccess;
import org.apache.tapestry.ioc.services.PropertyShadowBuilder;
import org.apache.tapestry.ioc.services.StrategyBuilder;
import org.apache.tapestry.ioc.services.ThreadLocale;
@@ -432,7 +433,9 @@
public static void contributeInfrastructure(
Configuration<InfrastructureContribution> configuration, ServiceLocator locator,
@InjectService("tapestry.ioc.TypeCoercer")
- TypeCoercer typeCoercer)
+ TypeCoercer typeCoercer, @InjectService("tapestry.ioc.PropertyAccess")
+ PropertyAccess propertyAccess)
+
{
add(
configuration,
@@ -457,6 +460,7 @@
FieldValidatorSource.class);
configuration.add(new InfrastructureContribution("TypeCoercer", typeCoercer));
+ configuration.add(new InfrastructureContribution("PropertyAccess", propertyAccess));
}
/**