Author: hlship
Date: Sat Sep 13 13:23:01 2008
New Revision: 695023
URL: http://svn.apache.org/viewvc?rev=695023&view=rev
Log:
TAPESTRY-2460: Nested BeanEditors (where the block parameter for a property to
one BeanEditor contains another BeanEditor) results in a StackOverflowException
Modified:
tapestry/tapestry5/trunk/quickstart/quickstart.iml
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
Modified: tapestry/tapestry5/trunk/quickstart/quickstart.iml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/quickstart/quickstart.iml?rev=695023&r1=695022&r2=695023&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/quickstart/quickstart.iml (original)
+++ tapestry/tapestry5/trunk/quickstart/quickstart.iml Sat Sep 13 13:23:01 2008
@@ -4,11 +4,6 @@
<output url="file://$MODULE_DIR$/target/classes" />
<exclude-output />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/main/resources"
isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
- <excludeFolder url="file://$MODULE_DIR$/target/site" />
- </content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntryProperties />
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java?rev=695023&r1=695022&r2=695023&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
Sat Sep 13 13:23:01 2008
@@ -14,8 +14,10 @@
package org.apache.tapestry5.corelib.components;
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.*;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ComponentAction;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.PropertyOverrides;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
@@ -30,10 +32,12 @@
import org.apache.tapestry5.services.Environment;
import org.apache.tapestry5.services.FormSupport;
+import java.lang.annotation.Annotation;
+
/**
* A component that generates a user interface for editing the properties of a
bean. This is the central component of
- * the [EMAIL PROTECTED] BeanEditForm}, and utilizes a [EMAIL PROTECTED]
PropertyEditor} for much of its functionality.
- * This component places a [EMAIL PROTECTED] BeanEditContext} into the
environment.
+ * the [EMAIL PROTECTED] BeanEditForm}, and utilizes a [EMAIL PROTECTED]
PropertyEditor} for much of its functionality. This component places
+ * a [EMAIL PROTECTED] BeanEditContext} into the environment.
*/
@SupportsInformalParameters
public class BeanEditor
@@ -62,7 +66,7 @@
{
component.cleanupEnvironment();
}
-
+
@Override
public String toString()
{
@@ -145,26 +149,31 @@
@Property
private String propertyName;
+ /**
+ * To support nested BeanEditors, we need to cache the object value inside
[EMAIL PROTECTED] #doPrepare()}. See TAPESTRY-2460.
+ */
+ private Object cachedObject;
+
// Needed for testing as well
public Object getObject()
{
- return object;
+ return cachedObject;
}
void setupRender()
{
formSupport.storeAndExecute(this, new Prepare());
}
-
+
void cleanupRender()
{
formSupport.storeAndExecute(this, CLEANUP_ENVIRONMENT);
}
/**
- * Used to initialize the model if necessary, to instantiate the object
being edited if necessary,
- * and to push the BeanEditContext into the environment.
+ * Used to initialize the model if necessary, to instantiate the object
being edited if necessary, and to push the
+ * BeanEditContext into the environment.
*/
void doPrepare()
{
@@ -195,19 +204,22 @@
}
}
- BeanEditContext context = new BeanEditContext()
+ BeanEditContext context = new BeanEditContext()
{
public Class<?> getBeanClass()
{
return model.getBeanType();
}
- public <T extends Annotation> T getAnnotation(Class<T> type)
+ public <T extends Annotation> T getAnnotation(Class<T> type)
{
return getBeanClass().getAnnotation(type);
}
};
-
+
+
+ cachedObject = object;
+
environment.push(BeanEditContext.class, context);
}
@@ -217,7 +229,8 @@
}
// For testing
- void inject(ComponentResources resources, PropertyOverrides overrides,
BeanModelSource source, Environment environment)
+ void inject(ComponentResources resources, PropertyOverrides overrides,
BeanModelSource source,
+ Environment environment)
{
this.resources = resources;
this.overrides = overrides;