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/02/19 00:38:05 UTC
svn commit: r745692 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/corelib/components/
test/java/org/apache/tapestry5/integration/app2/pages/
test/java/org/apache/tapestry5/integration/pagelevel/
test/resources/org/apa...
Author: drobiazko
Date: Wed Feb 18 23:38:05 2009
New Revision: 745692
URL: http://svn.apache.org/viewvc?rev=745692&view=rev
Log:
TAP5-523: Submit component should be able to render an input field of type image
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/integration/app2/pages/TestPageForSubmit.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.tml
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=745692&r1=745691&r2=745692&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 Wed Feb 18 23:38:05 2009
@@ -62,6 +62,14 @@
*/
@Parameter
private Object[] context;
+
+ /**
+ * If provided, the component renders an input tag with type "image". Otherwise "submit".
+ *
+ * @since 5.1.0.0
+ */
+ @Parameter(defaultPrefix = BindingConstants.ASSET)
+ private Asset image;
@Environmental
@@ -115,9 +123,13 @@
// Save the element, to see if an id is later requested.
- element = writer.element("input", "type", "submit", "name", name);
+ String type = image==null?"submit":"image";
+
+ element = writer.element("input", "type", type, "name", name);
if (disabled) writer.attributes("disabled", "disabled");
+
+ if(image!=null) writer.attributes("src", image.toClientURL());
formSupport.store(this, new ProcessSubmission(name));
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.java?rev=745692&r1=745691&r2=745692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.java Wed Feb 18 23:38:05 2009
@@ -14,11 +14,15 @@
package org.apache.tapestry5.integration.app2.pages;
+import org.apache.tapestry5.Asset;
import org.apache.tapestry5.annotations.Component;
+import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Submit;
import org.apache.tapestry5.corelib.components.TextField;
+import org.apache.tapestry5.ioc.annotations.Inject;
public class TestPageForSubmit
{
@@ -45,6 +49,11 @@
@SuppressWarnings("unused")
@Component(parameters = "value=value")
private TextField t2;
+
+ @Property
+ @Inject
+ @Path("${tapestry.spacer-image}")
+ private Asset spacerImage;
@Persist
private String value;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java?rev=745692&r1=745691&r2=745692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/pagelevel/SubmitTest.java Wed Feb 18 23:38:05 2009
@@ -17,6 +17,7 @@
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.ioc.services.SymbolSource;
import org.apache.tapestry5.test.PageTester;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
@@ -37,6 +38,8 @@
public void submit_form()
{
Element submitButton = doc.getElementById("capitalize1");
+ assertEquals("submit", submitButton.getAttribute("type"));
+
fieldValues.put("t1", "hello");
doc = tester.clickSubmit(submitButton, fieldValues);
assertTrue(doc.toString().contains("Value is: HELLO"));
@@ -75,6 +78,23 @@
assertEquals(ex.getMessage(), "Could not locate an ancestor element of type 'form'.");
}
}
+
+ @Test
+ public void render_image_type()
+ {
+ Element submitButton = doc.getElementById("submitImage");
+
+ assertEquals("image", submitButton.getAttribute("type"));
+
+ SymbolSource service = tester.getService(SymbolSource.class);
+
+ String symbolValue = service.valueForSymbol("tapestry.spacer-image");
+
+ String iconName = symbolValue.substring(symbolValue.lastIndexOf("/"));
+
+ assertTrue(submitButton.getAttribute("src").contains(iconName));
+
+ }
@BeforeMethod
public void before()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.tml?rev=745692&r1=745691&r2=745692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app2/pages/TestPageForSubmit.tml Wed Feb 18 23:38:05 2009
@@ -8,7 +8,10 @@
<span t:id="capitalize2"/>
<input t:id="t2" t:type="TextField"/>
</form></p>
-<input type="submit" id="orphanedSubmit"/>
+<input type="submit" id="orphanedSubmit"/>
+<t:form t:id="form3">
+ <input id="submitImage" t:type="submit" image="prop:spacerImage"/>
+</t:form>
<p>
Value is: ${value}.
</p>