Revision: 941
          http://stripes.svn.sourceforge.net/stripes/?rev=941&view=rev
Author:   bengunter
Date:     2008-06-20 06:07:30 -0700 (Fri, 20 Jun 2008)

Log Message:
-----------
Fixed STS-585. The fix for STS-475 changed setMaxlength(..) so that it does not 
call set("maxlength", ..) itself so subclasses must do so to make sure the 
maxlength attribute gets written. I added getEffectiveMaxlength() that returns 
the appropriate value based on specified attributes and validation metadata.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/tag/InputPasswordTag.java
    trunk/stripes/src/net/sourceforge/stripes/tag/InputTextTag.java

Modified: trunk/stripes/src/net/sourceforge/stripes/tag/InputPasswordTag.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/InputPasswordTag.java 
2008-06-19 20:36:39 UTC (rev 940)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/InputPasswordTag.java 
2008-06-20 13:07:30 UTC (rev 941)
@@ -61,6 +61,7 @@
                 getAttributes().put("value", format(getValue()));
             }
 
+            set("maxlength", getEffectiveMaxlength());
             writeSingletonTag(getPageContext().getOut(), "input");
 
             // Restore the original state before we mucked with it

Modified: trunk/stripes/src/net/sourceforge/stripes/tag/InputTextTag.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/InputTextTag.java     
2008-06-19 20:36:39 UTC (rev 940)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/InputTextTag.java     
2008-06-20 13:07:30 UTC (rev 941)
@@ -17,6 +17,9 @@
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.BodyTag;
 
+import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.exception.StripesJspException;
+import net.sourceforge.stripes.validation.Validate;
 import net.sourceforge.stripes.validation.ValidationMetadata;
 
 /**
@@ -58,6 +61,26 @@
     public String getMaxlength() { return maxlength; }
 
     /**
+     * Gets the maxlength value that is in effect for this tag, as determined 
by checking
+     * [EMAIL PROTECTED] #getMaxlength()} and then the [EMAIL PROTECTED] 
maxlength} element of the [EMAIL PROTECTED] Validate}
+     * annotation on the associated [EMAIL PROTECTED] ActionBean} property.
+     * 
+     * @throws StripesJspException if thrown by [EMAIL PROTECTED] 
#getValidationMetadata()}
+     */
+    protected String getEffectiveMaxlength() throws StripesJspException {
+        if (getMaxlength() == null) {
+            ValidationMetadata validation = getValidationMetadata();
+            if (validation != null && validation.maxlength() != null)
+                return validation.maxlength().toString();
+            else
+                return null;
+        }
+        else {
+            return getMaxlength();
+        }
+    }
+
+    /**
      * Sets type input tags type to "text".
      * @return EVAL_BODY_BUFFERED in all cases.
      */
@@ -93,16 +116,8 @@
         if (value != null) {
             getAttributes().put("value", format(value));
         }
-        
-        if (getMaxlength() == null) {
-            ValidationMetadata validation = getValidationMetadata();
-            if (validation != null && validation.maxlength() != null)
-                set("maxlength", validation.maxlength().toString());
-        }
-        else {
-            set("maxlength", getMaxlength());
-        }
 
+        set("maxlength", getEffectiveMaxlength());
         writeSingletonTag(getPageContext().getOut(), "input");
 
         // Restore the original state before we mucked with it


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to