tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject tapestry-5 git commit: TAP5-1862: DateField component: allow 'type' attribute to be specified
Date Mon, 06 Apr 2015 19:51:00 GMT
Repository: tapestry-5
Updated Branches:
  refs/heads/master 840533975 -> dcd31d68a


TAP5-1862: DateField component: allow 'type' attribute to be specified


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/dcd31d68
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/dcd31d68
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/dcd31d68

Branch: refs/heads/master
Commit: dcd31d68a7bf755fe0e5a8bf922646a4f86553f5
Parents: 8405339
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Apr 6 12:50:54 2015 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Apr 6 12:50:54 2015 -0700

----------------------------------------------------------------------
 .../tapestry5/corelib/components/DateField.java | 37 ++++++++++++++------
 1 file changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dcd31d68/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
index 2e47739..94a9a1f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
@@ -18,6 +18,7 @@ import org.apache.tapestry5.annotations.Import;
 import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.annotations.RequestParameter;
 import org.apache.tapestry5.corelib.base.AbstractField;
+import org.apache.tapestry5.dom.Element;
 import org.apache.tapestry5.ioc.Messages;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.annotations.Symbol;
@@ -35,11 +36,11 @@ import java.util.Locale;
 /**
  * A component used to collect a provided date from the user using a client-side JavaScript
calendar. Non-JavaScript
  * clients can simply type into a text field.
- *
+ * <p/>
  * One aspect here is that, because client-side JavaScript formatting and parsing is so limited,
we (currently)
  * use Ajax to send the user's input to the server for parsing (before raising the popup)
and formatting (after closing
  * the popup). Weird and inefficient, but easier than writing client-side JavaScript for
that purpose.
- *
+ * <p/>
  * Tapestry's DateField component is a wrapper around <a
  * href="http://webfx.eae.net/dhtml/datepicker/datepicker.html">WebFX DatePicker</a>.
  *
@@ -66,12 +67,22 @@ public class DateField extends AbstractField
      */
     @Parameter(required = true, allowNull = false, defaultPrefix = BindingConstants.LITERAL)
     private DateFormat format;
-    
+
+    /**
+     * Allows the type of field to be output; normally this is "text", but can be updated
to "date" or "datetime"
+     * as per the HTML 5 specification.
+     *
+     * @since 5.4
+     */
+    @Parameter(allowNull = false, defaultPrefix = BindingConstants.LITERAL, value = "text")
+    private String type;
+
     /**
      * When the <code>format</code> parameter isn't used, this parameter defines
whether the
      * <code>DateFormat</code> created by this component will be lenient or not.
      * The default value of this parameter is the value of the {@link SymbolConstants#LENIENT_DATE_FORMAT}
      * symbol.
+     *
      * @see DateFormat#setLenient(boolean)
      * @see SymbolConstants#LENIENT_DATE_FORMAT
      * @since 5.4
@@ -93,7 +104,7 @@ public class DateField extends AbstractField
     @Parameter(defaultPrefix = BindingConstants.VALIDATE)
     @SuppressWarnings("unchecked")
     private FieldValidator<Object> validate;
-    
+
     /**
      * Icon used for the date field trigger button. This was used in Tapestry 5.3 and earlier
and is now ignored.
      *
@@ -116,7 +127,7 @@ public class DateField extends AbstractField
 
     @Inject
     private DeprecationWarning deprecationWarning;
-    
+
     @Inject
     @Symbol(SymbolConstants.LENIENT_DATE_FORMAT)
     private boolean lenientDateFormatSymbolValue;
@@ -142,7 +153,7 @@ public class DateField extends AbstractField
             String pattern = simpleDateFormat.toPattern();
 
             String revised = pattern.replaceAll("([^y])yy$", "$1yyyy");
-            
+
             final SimpleDateFormat revisedDateFormat = new SimpleDateFormat(revised);
             revisedDateFormat.setLenient(lenient);
             return revisedDateFormat;
@@ -158,8 +169,9 @@ public class DateField extends AbstractField
     {
         return defaultProvider.defaultValidatorBinding("value", resources);
     }
-    
-    final boolean defaultLenient() {
+
+    final boolean defaultLenient()
+    {
         return lenientDateFormatSymbolValue;
     }
 
@@ -233,9 +245,9 @@ public class DateField extends AbstractField
             writer.attributes("class", "input-group");
         }
 
-        writer.element("input",
+        Element field = writer.element("input",
 
-                "type", hideTextField ? "hidden" : "text",
+                "type", type,
 
                 "class", cssClass,
 
@@ -245,6 +257,11 @@ public class DateField extends AbstractField
 
                 "value", value);
 
+        if (hideTextField)
+        {
+            field.attribute("class", "hide");
+        }
+
         writeDisabled(writer);
 
         putPropertyNameIntoBeanValidationContext("value");


Mime
View raw message