You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/12/13 20:05:05 UTC

svn commit: r1213870 - /tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java

Author: hlship
Date: Tue Dec 13 19:05:05 2011
New Revision: 1213870

URL: http://svn.apache.org/viewvc?rev=1213870&view=rev
Log:
TAP5-1787: TextField should be usable with HTML5 type values (such as "number", "email", etc.)

Modified:
    tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java

Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java?rev=1213870&r1=1213869&r2=1213870&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java (original)
+++ tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/TextField.java Tue Dec 13 19:05:05 2011
@@ -14,12 +14,15 @@
 
 package org.apache.tapestry5.corelib.components;
 
+import org.apache.tapestry5.BindingConstants;
 import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.corelib.base.AbstractTextField;
 
 /**
- * TextField component corresponds to <input type="text"> element. The value parameter will be editted. TextField
- * is generally used with string values, but other values are acceptible, as long as they can be freely converted back
+ * TextField component corresponds to {@code <input>} element. The value parameter will be edited (read when the containing
+ * {@link Form} is rendered, and updated when the form is submitted). TextField
+ * is generally used with string values, but other values are acceptable, as long as they can be freely converted back
  * and forth to strings.
  * <p/>
  * Includes the <code>size</code> attribute, if a {@link org.apache.tapestry5.beaneditor.Width} annotation is present on
@@ -29,12 +32,19 @@ import org.apache.tapestry5.corelib.base
  */
 public class TextField extends AbstractTextField
 {
+    /**
+     * Sets the type attribute of the {@code <input>} element. The default is "text", but this can be overriden
+     * when using <a href="http://www.w3.org/TR/html5/the-input-element.html">HTML5</a> types such as "number".
+     */
+    @Parameter(allowNull = false, value = "text", defaultPrefix = BindingConstants.LITERAL)
+    private String type;
+
     @Override
     protected void writeFieldTag(MarkupWriter writer, String value)
     {
         writer.element("input",
 
-                       "type", "text",
+                       "type", type,
 
                        "name", getControlName(),