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 2008/01/03 20:31:00 UTC

svn commit: r608605 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/components/ test/app1/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/integration/app1/pages/

Author: hlship
Date: Thu Jan  3 11:30:56 2008
New Revision: 608605

URL: http://svn.apache.org/viewvc?rev=608605&view=rev
Log:
TAPESTRY-1880: DateField component should support editting of time as well as date

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DateFieldDemo.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java?rev=608605&r1=608604&r2=608605&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java Thu Jan  3 11:30:56 2008
@@ -56,6 +56,14 @@
     @SuppressWarnings("unchecked")
     private FieldValidator<Object> _validate = NOOP_VALIDATOR;
 
+
+    /**
+     * If true, then the client-side calendar will show the time as well as the date.  You will probably
+     * need to bind the format parameter as well when this is true, say to <code>%m/%d/%y %H:%M</code>.
+     */
+    @Parameter
+    private boolean _editTime;
+
     // We will eventually make the skins & themes more configurable.
 
     @Inject
@@ -187,6 +195,9 @@
         setup.put("inputField", clientId);
         setup.put("ifFormat", _format);
         setup.put("button", triggerId);
+
+
+        if (_editTime) setup.put("showsTime", true);
 
         // Let subclasses do more.
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml?rev=608605&r1=608604&r2=608605&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml Thu Jan  3 11:30:56 2008
@@ -1,33 +1,41 @@
 <html t:type="Border"
-  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 
-  <h1>DateField Demo</h1>
+    <h1>DateField Demo</h1>
 
-  <t:form>
-    <t:errors />
+    <t:form>
+        <t:errors/>
 
-    <div class="t-beaneditor">
+        <div class="t-beaneditor">
 
-      <div class="t-beaneditor-row">
-        <t:label for="birthday" />
-        <t:datefield t:id="birthday" />
-      </div>
+            <div class="t-beaneditor-row">
+                <t:label for="birthday"/>
+                <t:datefield t:id="birthday"/>
+            </div>
 
+            <div class="t-beaneditor-row">
+                <t:label for="asteroidImpact"/>
+                <t:datefield t:id="asteroidImpact" editTime="true" format="%m/%d/%Y %H:%M"/>
+            </div>
 
-      <div class="t-beaneditor-row">
-        <input type="submit" value="Go" />
-      </div>
 
-    </div>
-  </t:form>
+            <div class="t-beaneditor-row">
+                <input type="submit" value="Go"/>
+            </div>
 
-  <t:if test="birthday">
-    <hr />
-    <p>
-      Birthday:
-      [<t:output value="birthday" format="dateFormat" />]
-    </p>
-  </t:if>
+        </div>
+    </t:form>
+
+    <t:if test="birthday">
+        <hr/>
+        <p>
+            Birthday: [<t:output value="birthday" format="dateFormat"/>]
+        </p>
+
+        <p>
+            Impact: [${asteroidImpactFormatted}]
+        </p>
+    </t:if>
 
 
 </html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=608605&r1=608604&r2=608605&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Jan  3 11:30:56 2008
@@ -1113,12 +1113,15 @@
         start("DateField Demo");
 
         type("birthday", "12/24/66");
+        type("asteroidImpact", "05/28/2046 10:44");
 
         clickAndWait(SUBMIT);
 
-        assertTextPresent("[12/24/1966]");
+        assertTextPresent("Birthday: [12/24/1966]");
+        assertTextPresent("Impact: [05/28/2046 10:44]");
 
         assertFieldValue("birthday", "12/24/66");
+        assertFieldValue("asteroidImpact", "05/28/2046 10:44");
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DateFieldDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DateFieldDemo.java?rev=608605&r1=608604&r2=608605&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DateFieldDemo.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DateFieldDemo.java Thu Jan  3 11:30:56 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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.
@@ -26,6 +26,9 @@
     @Persist
     private Date _birthday;
 
+    @Persist
+    private Date _asteroidImpact;
+
     @Validate("required")
     public Date getBirthday()
     {
@@ -40,5 +43,21 @@
     public DateFormat getDateFormat()
     {
         return new SimpleDateFormat("MM/dd/yyyy");
+    }
+
+    @Validate("required")
+    public Date getAsteroidImpact()
+    {
+        return _asteroidImpact;
+    }
+
+    public void setAsteroidImpact(Date asteroidImpact)
+    {
+        _asteroidImpact = asteroidImpact;
+    }
+
+    public String getAsteroidImpactFormatted()
+    {
+        return new SimpleDateFormat("MM/dd/yyyy hh:mm").format(_asteroidImpact);
     }
 }