You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/05/27 08:13:45 UTC

svn commit: r779019 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java

Author: sabob
Date: Wed May 27 06:13:44 2009
New Revision: 779019

URL: http://svn.apache.org/viewvc?rev=779019&view=rev
Log:
renamed getParameters to getParameterValues and improved getParameterValues to check if parameters are available

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java?rev=779019&r1=779018&r2=779019&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java (original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/SubmitLink.java Wed May 27 06:13:44 2009
@@ -274,22 +274,26 @@
      * @return the link request parameter value
      */
     public String getParameter(String name) {
-        Object value = getParameters().get(name);
+        if (hasParameters()) {
+            Object value = getParameters().get(name);
 
-        if (value instanceof String) {
-            return (String) value;
-        }
+            if (value instanceof String) {
+                return (String) value;
+            }
 
-        if (value instanceof String[]) {
-            String[] array = (String[]) value;
-            if (array.length >= 1) {
-                return array[0];
-            } else {
-                return null;
+            if (value instanceof String[]) {
+                String[] array = (String[]) value;
+                if (array.length >= 1) {
+                    return array[0];
+                } else {
+                    return null;
+                }
             }
-        }
 
-        return (value == null ? null : value.toString());
+            return (value == null ? null : value.toString());
+        } else {
+            return null;
+        }
     }
 
     /**
@@ -300,25 +304,32 @@
      * @return the link request parameter values
      */
     public String[] getParameterValues(String name) {
-        Object values = getParameters().get(name);
-        if (values instanceof String) {
-            return new String[] { values.toString() };
-        }
-        if (values instanceof String[]) {
-            return (String[]) values;
+        if (hasParameters()) {
+            Object values = getParameters().get(name);
+            if (values instanceof String) {
+                return new String[] { values.toString() };
+            }
+            if (values instanceof String[]) {
+                return (String[]) values;
+            } else {
+                return null;
+            }
         } else {
             return null;
         }
     }
 
     /**
+     * Set the link parameter with the given parameter name and values. If the
+     * values are null, the parameter will be removed from the {@link #parameters}.
+     *
      * @see org.apache.click.control.AbstractLink#setParameter(java.lang.String, java.lang.String)
      *
      * @param name the attribute name
      * @param values the attribute values
      * @throws IllegalArgumentException if name parameter is null
      */
-    public void setParameters(String name, String[] values) {
+    public void setParameterValues(String name, String[] values) {
         if (name == null) {
             throw new IllegalArgumentException("Null name parameter");
         }