click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r929087 - in /click/trunk/click/extras/src/org/apache/click/extras/control: CreditCardField.java DateField.java EmailField.java PickList.java RegexField.java
Date Tue, 30 Mar 2010 11:23:55 GMT
Author: sabob
Date: Tue Mar 30 11:23:54 2010
New Revision: 929087

URL: http://svn.apache.org/viewvc?rev=929087&view=rev
Log:
migrated html imports to head elements

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/CreditCardField.java
    click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
    click/trunk/click/extras/src/org/apache/click/extras/control/EmailField.java
    click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java
    click/trunk/click/extras/src/org/apache/click/extras/control/RegexField.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/CreditCardField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/CreditCardField.java?rev=929087&r1=929086&r2=929087&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/CreditCardField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/CreditCardField.java Tue
Mar 30 11:23:54 2010
@@ -291,8 +291,8 @@ public class CreditCardField extends Tex
 
     /**
      * Return the CreditCardField HTML head imports statements for the following
-     * resources:
-     * <p/>
+     * resource:
+     *
      * <ul>
      * <li><tt>click/extras-control.js</tt></li>
      * </ul>

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java?rev=929087&r1=929086&r2=929087&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/DateField.java Tue Mar 30
11:23:54 2010
@@ -448,6 +448,7 @@ public class DateField extends TextField
      * @param name of the control
      * @throws IllegalArgumentException if the name is null
      */
+    @Override
     public void setName(String name) {
         super.setName(name);
         setAttribute("id", getName() + "_field");
@@ -474,6 +475,7 @@ public class DateField extends TextField
      *
      * @param value the DateField value
      */
+    @Override
     public void setValue(String value) {
         if (value != null && value.length() > 0) {
             try {
@@ -498,6 +500,7 @@ public class DateField extends TextField
      *
      * @return the Date object representation of the Field value
      */
+    @Override
     public Object getValueObject() {
         return getDate();
     }
@@ -507,6 +510,7 @@ public class DateField extends TextField
      *
      * @param object the object value to set
      */
+    @Override
     public void setValueObject(Object object) {
         if (object != null) {
             if (Date.class.isAssignableFrom(object.getClass())) {
@@ -531,17 +535,6 @@ public class DateField extends TextField
     }
 
     /**
-     * This method returns null.
-     *
-     * @see #getHeadElements()
-     *
-     * @return the HTML head import statements for the control
-     */
-    public String getHtmlImports() {
-        return null;
-    }
-
-    /**
      * Return the DateField HTML head imports statements for the following
      * resources:
      *
@@ -559,6 +552,7 @@ public class DateField extends TextField
      *
      * @return the HTML head import statements for the control
      */
+    @Override
     public List getHeadElements() {
         // CLK-309. Skip imports if dateField is disabled, readonly or calendar
         // should not be displayed.
@@ -708,6 +702,7 @@ public class DateField extends TextField
      *
      * @return the help text of the Field
      */
+    @Override
     public String getHelp() {
         // Conditionally render help property, otherwise return null.
         if (renderHelp) {
@@ -740,6 +735,7 @@ public class DateField extends TextField
      * </ul>
      * </blockquote>
      */
+    @Override
     public void validate() {
         if (formatPattern == null) {
             String msg = "dateFormat attribute is null for field: " + getName();
@@ -772,6 +768,7 @@ public class DateField extends TextField
      *
      * @param buffer the specified buffer to render the control's output to
      */
+    @Override
     public void render(HtmlStringBuffer buffer) {
 
         // Set default title

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/EmailField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/EmailField.java?rev=929087&r1=929086&r2=929087&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/EmailField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/EmailField.java Tue Mar 30
11:23:54 2010
@@ -178,8 +178,8 @@ public class EmailField extends TextFiel
 
     /**
      * Return the EmailField HTML head imports statements for the following
-     * resources:
-     * <p/>
+     * resource:
+     *
      * <ul>
      * <li><tt>click/extras-control.js</tt></li>
      * </ul>

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java?rev=929087&r1=929086&r2=929087&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java Tue Mar 30
11:23:54 2010
@@ -25,9 +25,11 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import org.apache.click.Context;
 
 import org.apache.click.control.Field;
 import org.apache.click.control.Option;
+import org.apache.click.element.JsImport;
 import org.apache.click.util.ClickUtils;
 import org.apache.click.util.Format;
 import org.apache.click.util.HtmlStringBuffer;
@@ -113,10 +115,6 @@ public class PickList extends Field {
 
     // Constants --------------------------------------------------------------
 
-    /** The PickList imports statement. */
-    public static final String HTML_IMPORTS =
-        "<script type=\"text/javascript\" src=\"{0}/click/extras-control{1}.js\"></script>\n";
-
     /**
      * The field validation JavaScript function template.
      * The function template arguments are: <ul>
@@ -378,20 +376,27 @@ public class PickList extends Field {
     }
 
     /**
-     * Return the PickList HTML head imports statements for the following
-     * resources:
+     * Return the PickList HTML HEAD elements for the following resource:
      * <p/>
      * <ul>
      * <li><tt>click/extras-control.js</tt></li>
      * </ul>
      *
-     * @see org.apache.click.Control#getHtmlImports()
+     * @see org.apache.click.Control#getHeadElements()
      *
-     * @return the HTML head import statements for the control
+     * @return the HTML HEAD elements for the control
      */
     @Override
-    public String getHtmlImports() {
-        return ClickUtils.createHtmlImport(HTML_IMPORTS, getContext());
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            Context context = getContext();
+            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);
+
+            headElements.add(new JsImport("/click/extras-control.js", versionIndicator));
+        }
+        return headElements;
     }
 
     /**

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/RegexField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/RegexField.java?rev=929087&r1=929086&r2=929087&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/RegexField.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/RegexField.java Tue Mar 30
11:23:54 2010
@@ -19,9 +19,12 @@
 package org.apache.click.extras.control;
 
 import java.text.MessageFormat;
+import java.util.List;
 import java.util.regex.Pattern;
+import org.apache.click.Context;
 
 import org.apache.click.control.TextField;
+import org.apache.click.element.JsImport;
 import org.apache.click.util.ClickUtils;
 
 /**
@@ -83,7 +86,7 @@ public class RegexField extends TextFiel
 
     private static final long serialVersionUID = 1L;
 
-    // -------------------------------------------------------------- Constants
+    // Constants --------------------------------------------------------------
 
     /**
      * The field validation JavaScript function template.
@@ -110,11 +113,7 @@ public class RegexField extends TextFiel
         + "   '}'\n"
         + "'}'\n";
 
-    /** The RegexField imports statement. */
-    public static final String HTML_IMPORTS =
-        "<script type=\"text/javascript\" src=\"{0}/click/extras-control{1}.js\"></script>\n";
-
-    // ----------------------------------------------------- Instance Variables
+    // Instance Variables -----------------------------------------------------
 
     /**
      * The field pattern based on regular expression.
@@ -122,7 +121,7 @@ public class RegexField extends TextFiel
      */
     protected String pattern;
 
-    // ----------------------------------------------------------- Constructors
+    // Constructors -----------------------------------------------------------
 
     /**
      * Construct the RegexField with the given name.
@@ -197,7 +196,7 @@ public class RegexField extends TextFiel
         super();
     }
 
-    // ------------------------------------------------------ Public Attributes
+    // Public Attributes ------------------------------------------------------
 
     /**
      * Sets the field pattern as regular expression.
@@ -220,18 +219,26 @@ public class RegexField extends TextFiel
     }
 
     /**
-     * Return the RegexField HTML head imports statements for the following
-     * resources:
+     * Return the RegexField HTML HEAD elements for the following resource:
      * <ul>
      * <li><tt>click/extras-control.js</tt></li>
      * </ul>
      *
-     * @see org.apache.click.Control#getHtmlImports()
+     * @see org.apache.click.Control#getHeadElements()
      *
-     * @return the HTML head import statements for the control
+     * @return the HTML HEAD elements for the control
      */
-    public String getHtmlImports() {
-        return ClickUtils.createHtmlImport(HTML_IMPORTS, getContext());
+    @Override
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            Context context = getContext();
+            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);
+
+            headElements.add(new JsImport("/click/extras-control.js", versionIndicator));
+        }
+        return headElements;
     }
 
     /**
@@ -243,6 +250,7 @@ public class RegexField extends TextFiel
      *
      * @return the field JavaScript client side validation function
      */
+    @Override
     public String getValidationJavaScript() {
         Object[] args = new Object[9];
         args[0] = getId();
@@ -260,7 +268,7 @@ public class RegexField extends TextFiel
         return MessageFormat.format(VALIDATE_REGEXFIELD_FUNCTION, args);
     }
 
-    // --------------------------------------------------------- Public Methods
+    // Public Methods ---------------------------------------------------------
 
     /**
      * Validate the RegexField request submission.
@@ -287,6 +295,7 @@ public class RegexField extends TextFiel
      * @throws java.util.regex.PatternSyntaxException if the pattern has a
      *      syntax error
      */
+    @Override
     public void validate() {
         super.validate();
 
@@ -300,7 +309,7 @@ public class RegexField extends TextFiel
         }
     }
 
-    // ------------------------------------------------------ Private Methods
+    // Private Methods ------------------------------------------------------
 
     /**
      * Escape the JavaScript string.



Mime
View raw message