Revision: 384
Author:   tfenne
Date:     2006-08-16 17:49:07 -0700 (Wed, 16 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/stripes/?rev=384&view=rev

Log Message:
-----------
Fixed a bug reported in 1.4 beta 2 on the user list that form field focus 
doesn't work when there are global errors present (but no field errors).

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/tag/FormTag.java
    trunk/stripes/src/net/sourceforge/stripes/validation/ValidationErrors.java
Modified: trunk/stripes/src/net/sourceforge/stripes/tag/FormTag.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/FormTag.java  2006-08-15 
00:49:14 UTC (rev 383)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/FormTag.java  2006-08-17 
00:49:07 UTC (rev 384)
@@ -360,7 +360,7 @@
             ValidationErrors errors = bean == null ? null : 
bean.getContext().getValidationErrors();
 
             // If there are validaiton errors, select the first field in error
-            if (errors != null && errors.size() > 0) {
+            if (errors != null && errors.hasFieldErrors()) {
                 List<ValidationError> fieldErrors = errors.get(tag.getName());
                 if (fieldErrors != null && fieldErrors.size() > 0) {
                     tag.setFocus(true);

Modified: 
trunk/stripes/src/net/sourceforge/stripes/validation/ValidationErrors.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/validation/ValidationErrors.java  
2006-08-15 00:49:14 UTC (rev 383)
+++ trunk/stripes/src/net/sourceforge/stripes/validation/ValidationErrors.java  
2006-08-17 00:49:07 UTC (rev 384)
@@ -115,4 +115,19 @@
 
         return super.put(field, errors);
     }
+
+    /**
+     * Returns true if there are field-specific errors present, and false if 
there are
+     * only global errors, or no errors at all.
+     *
+     * @return true if field errors exist, false otherwise
+     */
+    public boolean hasFieldErrors() {
+        if ( keySet().contains(GLOBAL_ERROR) ) {
+            return size() > 1;
+        }
+        else {
+            return size() > 0;
+        }
+    }
 }


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


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to