click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r735836 - in /incubator/click/trunk/click: documentation/docs/ framework/src/org/apache/click/control/ framework/test/org/apache/click/control/ framework/test/org/apache/click/util/ mock/src/org/apache/click/servlet/
Date Mon, 19 Jan 2009 21:43:42 GMT
Author: sabob
Date: Mon Jan 19 13:43:42 2009
New Revision: 735836

URL: http://svn.apache.org/viewvc?rev=735836&view=rev
Log:
fixed HiddenField to work with Timestamp, Time and java.sql.Date. CLK-484

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/framework/src/org/apache/click/control/HiddenField.java
    incubator/click/trunk/click/framework/test/org/apache/click/control/AbstractLinkTest.java
    incubator/click/trunk/click/framework/test/org/apache/click/control/HiddenFieldTest.java
    incubator/click/trunk/click/framework/test/org/apache/click/util/User.java
    incubator/click/trunk/click/mock/src/org/apache/click/servlet/MockRequest.java

Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Mon Jan 19 13:43:42
2009
@@ -115,6 +115,14 @@
         Added csv mime type. This issue was raised by Alvin Townsend.
       </li>
       <li class="change">
+        Fixed URL rendering to encode ampersand characeters.
+        [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-483">483</a>].
+      </li>
+      <li class="change">
+        Fixed HiddenField to work with java.sql.Timestamp, java.sql.Time and java.sql.Date.
+        [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-484">484</a>].
+      </li>
+      <li class="change">
         Fixed WebappLoader to reload Velocity global macro's
         [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-467">467</a>].
       </li>

Modified: incubator/click/trunk/click/framework/src/org/apache/click/control/HiddenField.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/control/HiddenField.java?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/control/HiddenField.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/control/HiddenField.java Mon
Jan 19 13:43:42 2009
@@ -20,6 +20,8 @@
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.Date;
 
 import org.apache.click.util.ClickUtils;
@@ -288,6 +290,18 @@
             } else if (valueClass == Short.class) {
                 setValueObject(Short.valueOf(aValue));
 
+            } else if (valueClass == Timestamp.class) {
+                long time = Long.parseLong(aValue);
+                setValueObject(new Timestamp(time));
+
+            } else if (valueClass == java.sql.Date.class) {
+                long time = Long.parseLong(aValue);
+                setValueObject(new java.sql.Date(time));
+
+            } else if (valueClass == Time.class) {
+                long time = Long.parseLong(aValue);
+                setValueObject(new Time(time));
+
             } else if (Date.class.isAssignableFrom(valueClass)) {
                 long time = Long.parseLong(aValue);
                 setValueObject(new Date(time));

Modified: incubator/click/trunk/click/framework/test/org/apache/click/control/AbstractLinkTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/control/AbstractLinkTest.java?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/control/AbstractLinkTest.java
(original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/control/AbstractLinkTest.java
Mon Jan 19 13:43:42 2009
@@ -44,4 +44,18 @@
         // Check that the value <script> is not rendered
         assertTrue(link.toString().indexOf(value) < 0);
     }
+
+    /**
+     * Check that Ampersands are url encoded -> '&amp;'.
+     *
+     * CLK-483.
+     */
+    public void testAmpersandEncoding() {
+        MockContext.initContext();
+
+        ActionLink link = new ActionLink("name");
+        link.setParameter("param1", "value1");
+
+        assertTrue(link.toString().indexOf("&amp;") > 0);
+    }
 }

Modified: incubator/click/trunk/click/framework/test/org/apache/click/control/HiddenFieldTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/control/HiddenFieldTest.java?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/control/HiddenFieldTest.java
(original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/control/HiddenFieldTest.java
Mon Jan 19 13:43:42 2009
@@ -18,8 +18,12 @@
  */
 package org.apache.click.control;
 
+import java.sql.Timestamp;
+import java.util.Date;
 import junit.framework.TestCase;
 import org.apache.click.MockContext;
+import org.apache.click.servlet.MockRequest;
+import org.apache.click.util.User;
 
 /**
  * Test HiddenField behavior.
@@ -44,4 +48,39 @@
         // Check that the value <script> is not rendered
         assertTrue(field.toString().indexOf(value) < 0);
     }
+
+    /**
+     * Check that timestamp copies to and from a HiddenField.
+     *
+     * CLK-484.
+     */
+    public void testTimestampCopy() {
+        MockContext context = MockContext.initContext();
+        MockRequest request = context.getMockRequest();
+        request.setParameter("timestamp", String.valueOf(new Date().getTime()));
+
+        // set up the form for copyTo
+        Form form = new Form("sample");
+
+        HiddenField hiddenField = new HiddenField("timestamp", Timestamp.class);
+        form.add(hiddenField);
+
+        hiddenField.bindRequestValue();
+
+        User user = new User();
+
+        form.copyTo(user, true);
+        assertEquals(hiddenField.getValueObject(), user.getTimestamp());
+
+        // set up the form for copyFrom
+        form = new Form("sample");
+        hiddenField = new HiddenField("timestamp", Timestamp.class);
+        form.add(hiddenField);
+
+        user = new User();
+        user.setTimestamp(new Timestamp(new Date().getTime()));
+        form.copyFrom(user);
+
+        assertEquals(user.getTimestamp(), hiddenField.getValueObject());
+    }
 }

Modified: incubator/click/trunk/click/framework/test/org/apache/click/util/User.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/util/User.java?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/util/User.java (original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/util/User.java Mon Jan 19
13:43:42 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.click.util;
 
+import java.sql.Timestamp;
+
 /**
  * User value object.
  */
@@ -26,6 +28,7 @@
     private String name;
     private Address address;
     private String telephone;
+    private Timestamp timestamp;
     
     public Address getAddress() {
         return address;
@@ -51,4 +54,10 @@
     public void setTelephone(String telephone) {
         this.telephone = telephone;
     }
+    public Timestamp getTimestamp() {
+        return timestamp;
+    }
+    public void setTimestamp(Timestamp timestamp) {
+        this.timestamp = timestamp;
+    }
 }

Modified: incubator/click/trunk/click/mock/src/org/apache/click/servlet/MockRequest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/mock/src/org/apache/click/servlet/MockRequest.java?rev=735836&r1=735835&r2=735836&view=diff
==============================================================================
--- incubator/click/trunk/click/mock/src/org/apache/click/servlet/MockRequest.java (original)
+++ incubator/click/trunk/click/mock/src/org/apache/click/servlet/MockRequest.java Mon Jan
19 13:43:42 2009
@@ -638,7 +638,7 @@
                     buf.append('=');
                     buf.append(URLEncoder.encode(value, "UTF-8"));
                     if (iterator.hasNext()) {
-                        buf.append('&');
+                        buf.append("&amp;");
                     }
                 }
             } catch (UnsupportedEncodingException e) {



Mime
View raw message