You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by dr...@apache.org on 2009/09/06 19:56:50 UTC
svn commit: r811844 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/corelib/components/ test/app1/
test/java/org/apache/tapestry5/corelib/components/
test/java/org/apache/tapestry5/integration/ test/java/org/apache/tape...
Author: drobiazko
Date: Sun Sep 6 17:56:49 2009
New Revision: 811844
URL: http://svn.apache.org/viewvc?rev=811844&view=rev
Log:
TAP5-711: Submit component: using image parameter brakes "Selected" events
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ImageSubmitDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java (with props)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java?rev=811844&r1=811843&r2=811844&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Submit.java Sun Sep 6 17:56:49 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/trunk/tapestry-core/src/test/app1/ImageSubmitDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ImageSubmitDemo.tml?rev=811844&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ImageSubmitDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ImageSubmitDemo.tml Sun Sep 6 17:56:49 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/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java?rev=811844&r1=811843&r2=811844&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/SubmitTest.java Sun Sep 6 17:56:49 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/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=811844&r1=811843&r2=811844&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Sun Sep 6 17:56:49 2009
@@ -3155,4 +3155,18 @@
assertAttribute(String.format("//script[@src='%s']/@src", "some_additional_scripts.js"), "some_additional_scripts.js");
assertTextPresent("Event 'provideAdditionalMarkup' handled.");
}
+
+ @Test
+ public void image_submit_triggers_selected_event()
+ {
+ start("Submit with an Image Demo");
+
+ type("value", "barney gumble");
+
+ clickAndWait("//input[@type='image']");
+
+ assertText("outputvalue", "barney gumble");
+
+ assertText("eventfired", "true");
+ }
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java?rev=811844&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java Sun Sep 6 17:56:49 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/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ImageSubmitDemo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=811844&r1=811843&r2=811844&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java Sun Sep 6 17:56:49 2009
@@ -388,7 +388,8 @@
"Use of calendar properties inside BeanEditor and BeanDisplay"),
new Item("TriggerDemo", "Trigger Demo",
- "Use of Trigger component")
+ "Use of Trigger component"),
+ new Item("ImageSubmitDemo", "Submit with an Image Demo", "Make sure that submit with the image parameter set triggers the 'selected' event.")
);