click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r799845 - in /incubator/click/trunk/click: documentation/docs/ extras/src/org/apache/click/extras/control/ extras/test/org/apache/click/extras/control/
Date Sat, 01 Aug 2009 11:42:03 GMT
Author: sabob
Date: Sat Aug  1 11:42:03 2009
New Revision: 799845

URL: http://svn.apache.org/viewvc?rev=799845&view=rev
Log:
fixed DateField help property rendered twice. CLK-574

Added:
    incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest$MyDateField.properties
Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
    incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest.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=799845&r1=799844&r2=799845&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Sat Aug  1 11:42:03
2009
@@ -408,6 +408,11 @@
           [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-557">557</a>].
       </li>
       <li class="change">
+          Fixed DateField not to render help property twice.
+          This issue was raised by Finn Bock
+          [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-574">574</a>].
+      </li>
+      <li class="change">
           Update Velocity library to version 1.6.2.
       </li>
       <li class="change">

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java?rev=799845&r1=799844&r2=799845&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
Sat Aug  1 11:42:03 2009
@@ -177,6 +177,9 @@
      */
     protected String style = "default";
 
+    /** Indicates whether the help property should be rendered or not. */
+    private boolean renderHelp = true;
+
     // ----------------------------------------------------------- Constructors
 
     /**
@@ -695,6 +698,21 @@
         this.style = style;
     }
 
+    /**
+     * Return the field help text.
+     *
+     * @see org.apache.click.control.Field#getHelp()
+     *
+     * @return the help text of the Field
+     */
+    public String getHelp() {
+        // Conditionally render help property, otherwise return null.
+        if (renderHelp) {
+            return super.getHelp();
+        }
+        return null;
+    }
+
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -752,24 +770,25 @@
      * @param buffer the specified buffer to render the control's output to
      */
     public void render(HtmlStringBuffer buffer) {
-        String help = getHelp();
-        // Nullify help to ensure it is not rendered by super impl.
-        if (help != null) {
-            setHelp(null);
-        }
 
         // Set default title
         if (getTitle() == null) {
             setTitle(getMessage("date-title", formatPattern));
         }
 
+        // Ensure help is not rendered by super implementation
+        renderHelp = false;
+
         super.render(buffer);
 
+        renderHelp = true;
+
         if (isShowCalendar()) {
             renderCalendarButton(buffer);
         }
 
-
+        // Render help
+        String help = getHelp();
         if (help != null) {
             buffer.append(help);
         }

Added: incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest$MyDateField.properties
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest%24MyDateField.properties?rev=799845&view=auto
==============================================================================
--- incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest$MyDateField.properties
(added)
+++ incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest$MyDateField.properties
Sat Aug  1 11:42:03 2009
@@ -0,0 +1,3 @@
+date.help=Help Me!
+date.title=The title
+date.label=Enter the date
\ No newline at end of file

Modified: incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest.java?rev=799845&r1=799844&r2=799845&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest.java
(original)
+++ incubator/click/trunk/click/extras/test/org/apache/click/extras/control/DateFieldTest.java
Sat Aug  1 11:42:03 2009
@@ -23,6 +23,7 @@
 import org.apache.click.MockContext;
 import junit.framework.TestCase;
 import org.apache.click.servlet.MockRequest;
+import org.apache.commons.lang.StringUtils;
 
 /**
  * Provides DateField JUnit TestCase.
@@ -125,4 +126,25 @@
         assertEquals("d/M/yy", calendarField.getFormatPattern());
         assertEquals("d/M/yy", calendarField.getCalendarPattern());
     }
+
+    /**
+     * Check that help text is not rendered twice.
+     *
+     * CLK-574
+     */
+    public void testRenderHelp() {
+        MockContext.initContext();
+
+        DateField dateField = new MyDateField("date");
+
+        int matches = StringUtils.countMatches(dateField.toString(), "Help Me!");
+
+        assertEquals(1, matches);
+    }
+
+    public class MyDateField extends DateField {
+        public MyDateField(String name) {
+            super(name);
+        }
+    }
 }



Mime
View raw message