You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/05/10 18:55:33 UTC
cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/form FormSupportImpl.java
hlship 2005/05/10 09:55:33
Modified: framework/src/test/org/apache/tapestry/form MockForm.java
TestFormSupport.java
framework/src/java/org/apache/tapestry/form
FormSupportImpl.java
Log:
Invoke clear() on the validation delegate when rewinding (processing a form submission) since (in the Portlet world), it is likely the delegate is persisting between requests.
Revision Changes Path
1.5 +15 -1 jakarta-tapestry/framework/src/test/org/apache/tapestry/form/MockForm.java
Index: MockForm.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/form/MockForm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MockForm.java 9 May 2005 14:45:15 -0000 1.4
+++ MockForm.java 10 May 2005 16:55:32 -0000 1.5
@@ -51,12 +51,26 @@
private List _deferredRunnable = new ArrayList();
+ private IValidationDelegate _delegate;
+
public MockForm()
{
+ this(null, null);
}
public MockForm(Location location)
{
+ this(null, location);
+ }
+
+ public MockForm(IValidationDelegate delegate)
+ {
+ this(delegate, null);
+ }
+
+ public MockForm(IValidationDelegate delegate, Location location)
+ {
+ _delegate = delegate;
_location = location;
}
@@ -90,7 +104,7 @@
public IValidationDelegate getDelegate()
{
- return null;
+ return _delegate;
}
public void setEncodingType(String encodingType)
1.5 +40 -8 jakarta-tapestry/framework/src/test/org/apache/tapestry/form/TestFormSupport.java
Index: TestFormSupport.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/form/TestFormSupport.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestFormSupport.java 9 May 2005 14:45:15 -0000 1.4
+++ TestFormSupport.java 10 May 2005 16:55:32 -0000 1.5
@@ -26,6 +26,7 @@
import org.apache.tapestry.StaleLinkException;
import org.apache.tapestry.TapestryUtils;
import org.apache.tapestry.engine.ILink;
+import org.apache.tapestry.valid.IValidationDelegate;
import org.easymock.MockControl;
/**
@@ -89,6 +90,11 @@
return component;
}
+ private IValidationDelegate newDelegate()
+ {
+ return (IValidationDelegate) newMock(IValidationDelegate.class);
+ }
+
private IMarkupWriter newWriter()
{
return (IMarkupWriter) newMock(IMarkupWriter.class);
@@ -179,7 +185,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm();
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -190,6 +198,8 @@
verifyControls();
+ delegate.clear();
+
trainCycleForRewind(cyclec, cycle, "barney,wilma,barney$0", null);
final IFormComponent barney1 = newFormComponent("barney", "barney");
@@ -653,8 +663,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
+ IValidationDelegate delegate = newDelegate();
- MockForm form = new MockForm();
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -665,6 +676,8 @@
verifyControls();
+ delegate.clear();
+
trainCycleForRewind(cyclec, cycle, "action$0", "action");
final IFormComponent component = newFormComponent("action", "action$0");
@@ -688,7 +701,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm();
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -701,6 +716,8 @@
Location l = newLocation();
+ delegate.clear();
+
// So, the scenario here is that component "pebbles" was inside
// some kind of conditional that evaluated to true during the render,
// but is now false on the rewind.
@@ -742,7 +759,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm();
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -755,6 +774,8 @@
Location l = newLocation();
+ delegate.clear();
+
// So, the scenario here is that component "barney" was inside
// some kind of loop that executed once on the render, but twice
// on the rewind (i.e., an additional object was added in between).
@@ -797,7 +818,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm(l);
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate, l);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -808,6 +831,8 @@
verifyControls();
+ delegate.clear();
+
// So, the scenario here is that component "barney" was inside
// some kind of loop that executed twice on the render, but only once
// on the rewind (i.e., the object was deleted in between).
@@ -1008,7 +1033,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm();
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -1019,6 +1046,8 @@
verifyControls();
+ delegate.clear();
+
trainCycleForRewind(cyclec, cycle, "barney", null);
final IFormComponent component = newFormComponent("barney", "barney");
@@ -1041,7 +1070,9 @@
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
- MockForm form = new MockForm();
+ IValidationDelegate delegate = newDelegate();
+
+ MockForm form = new MockForm(delegate);
cycle.isRewound(form);
cyclec.setReturnValue(true);
@@ -1052,6 +1083,8 @@
verifyControls();
+ delegate.clear();
+
trainCycleForRewind(cyclec, cycle, "", null);
writer.print("DEFERRED");
@@ -1065,7 +1098,6 @@
{
fs.addDeferredRunnable(new Runnable()
{
-
public void run()
{
writer.print("DEFERRED");
1.5 +2 -0 jakarta-tapestry/framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
Index: FormSupportImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/form/FormSupportImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FormSupportImpl.java 9 May 2005 14:45:15 -0000 1.4
+++ FormSupportImpl.java 10 May 2005 16:55:32 -0000 1.5
@@ -482,6 +482,8 @@
{
reinitializeIdAllocatorForRewind();
+ _form.getDelegate().clear();
+
_form.renderBody(_writer, _cycle);
int expected = _allocatedIds.size();
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org