Author: drobiazko
Date: Thu Nov 19 21:29:12 2009
New Revision: 882304
URL: http://svn.apache.org/viewvc?rev=882304&view=rev
Log:
TAP5-711: Submit component: using image parameter brakes "Selected" events
Added:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/app1/ImageSubmitDemo.tml
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
(with props)
Modified:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
Modified:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java?rev=882304&r1=882303&r2=882304&view=diff
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
(original)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
Thu Nov 19 21:29:12 2009
@@ -146,7 +146,7 @@
{
if (disabled) return;
- String value = request.getParameter(elementName);
+ String value = request.getParameter(image == null ? elementName :
elementName + ".x");
if (value == null) return;
@@ -166,21 +166,6 @@
else heartbeat.defer(sendNotification);
}
- // For testing:
-
- void setDefer(boolean defer)
- {
- this.defer = defer;
- }
-
- void setup(ComponentResources resources, FormSupport formSupport,
Heartbeat heartbeat, RenderSupport renderSupport)
- {
- this.resources = resources;
- this.formSupport = formSupport;
- this.heartbeat = heartbeat;
- this.renderSupport = renderSupport;
- }
-
/**
* Returns the component's client id. This must be called after the
component has rendered. The id is allocated
* lazily (first time this method is invoked).
Added:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/app1/ImageSubmitDemo.tml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/app1/ImageSubmitDemo.tml?rev=882304&view=auto
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/app1/ImageSubmitDemo.tml
(added)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/app1/ImageSubmitDemo.tml
Thu Nov 19 21:29:12 2009
@@ -0,0 +1,22 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <h1>Submit with an image</h1>
+
+ <t:if test="value">
+ <p>You entered
+ <span id="outputvalue">${value}</span>
+ </p>
+ <p>"selected" event was fired: <span
id="eventfired">${eventfired}</span>
+ </p>
+ </t:if>
+
+
+ <t:form>
+ <t:errors/>
+ <t:textfield t:id="value"/>
+ <br/>
+ <t:submit t:id="mySubmit" t:image="context:images/tapestry_banner.gif"
/>
+ </t:form>
+
+</t:border>
\ No newline at end of file
Modified:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java?rev=882304&r1=882303&r2=882304&view=diff
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
(original)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
Thu Nov 19 21:29:12 2009
@@ -14,14 +14,19 @@
package org.apache.tapestry5.corelib.components;
+import static org.easymock.EasyMock.isA;
+
+import org.apache.tapestry5.Asset;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.corelib.internal.FormSupportImpl;
import org.apache.tapestry5.internal.services.HeartbeatImpl;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
+import org.apache.tapestry5.ioc.test.TestBase;
import org.apache.tapestry5.services.FormSupport;
import org.apache.tapestry5.services.Heartbeat;
import org.apache.tapestry5.services.Request;
+import org.easymock.EasyMock;
import org.testng.annotations.Test;
public class SubmitTest extends InternalBaseTestCase
@@ -59,7 +64,7 @@
Submit submit = new Submit(request);
- submit.setup(resources, support, null, null);
+ TestBase.set(submit, "resources", resources, "formSupport", support);
submit.processSubmission(elementName);
@@ -92,8 +97,7 @@
Submit submit = new Submit(request);
- submit.setup(resources, support, heartbeat, null);
- submit.setDefer(false);
+ TestBase.set(submit, "resources", resources, "formSupport", support,
"heartbeat", heartbeat, "defer", false);
submit.processSubmission(elementName);
@@ -107,4 +111,53 @@
verify();
}
+
+ @Test
+ public void test_imagesubmit_event_fired()
+ {
+ Request request = mockRequest();
+ final ComponentResources resources = mockComponentResources();
+ FormSupport formSupport = mockFormSupport();
+ Asset image = mockAsset();
+
+ String elementName = "myname";
+
+ train_getParameter(request, elementName + ".x", "15");
+
+ formSupport.defer(isA(Runnable.class));
+
+ replay();
+
+ Submit submit = new Submit(request);
+
+ TestBase.set(submit, "resources", resources, "formSupport",
formSupport, "image", image);
+
+ submit.processSubmission(elementName);
+
+ verify();
+ }
+
+ @Test
+ public void test_submit_event_fired()
+ {
+ Request request = mockRequest();
+ final ComponentResources resources = mockComponentResources();
+ FormSupport formSupport = mockFormSupport();
+
+ String elementName = "myname";
+
+ train_getParameter(request, elementName, "login");
+
+ formSupport.defer(isA(Runnable.class));
+
+ replay();
+
+ Submit submit = new Submit(request);
+
+ TestBase.set(submit, "resources", resources, "formSupport",
formSupport);
+
+ submit.processSubmission(elementName);
+
+ verify();
+ }
}
Modified:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=882304&r1=882303&r2=882304&view=diff
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
(original)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
Thu Nov 19 21:29:12 2009
@@ -2932,4 +2932,21 @@
assertText("prop.middle.bottom", "bound value");
assertText("literal.middle.bottom", "some text");
}
+
+ /**
+ * TAP5-711
+ */
+ @Test
+ public void image_submit_triggers_selected_event()
+ {
+ start("Submit with an Image Demo");
+
+ type("value", "barney gumble");
+
+ clickAndWait("//inp...@type='image']");
+
+ assertText("outputvalue", "barney gumble");
+
+ assertText("eventfired", "true");
+ }
}
\ No newline at end of file
Added:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java?rev=882304&view=auto
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
(added)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
Thu Nov 19 21:29:12 2009
@@ -0,0 +1,42 @@
+// Copyright 2009 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.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.PersistenceConstants;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.beaneditor.Validate;
+
+public class ImageSubmitDemo
+{
+ @Property
+ @Validate("required")
+ @Persist(PersistenceConstants.FLASH)
+ private String value;
+
+ @Property
+ @Persist(PersistenceConstants.FLASH)
+ private boolean eventfired;
+
+ void onSelectedFromMySubmit()
+ {
+ eventfired = true;
+ }
+
+ Object onSuccess()
+ {
+ return this;
+ }
+}
Propchange:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=882304&r1=882303&r2=882304&view=diff
==============================================================================
---
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
(original)
+++
tapestry/tapestry5/branches/5.1.0.x-dev/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
Thu Nov 19 21:29:12 2009
@@ -347,7 +347,10 @@
"Nice exception message for common problem of form fields
outside forms"),
new Item("SubmitWithContext", "Submit With Context",
- "Providing a context for Submit component")
+ "Providing a context for Submit component"),
+
+ new Item("ImageSubmitDemo", "Submit with an Image Demo", "Make
sure that submit with the image parameter set triggers the 'selected' event.")
+
);
static