Commits

Anonymous committed b6005a5

Fixing incorrect validation names for nested beans in a collection
WW-2112

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/2.0@1615e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

src/java/com/opensymphony/xwork2/validator/validators/VisitorFieldValidator.java

         Object o;
         String field;
         String message;
+        ValidatorContext parent;
 
         public AppendingValidatorContext(ValidatorContext parent, Object object, String field, String message) {
             super(parent, makeTextProvider(object, parent), parent);
 
             //            super(parent);
+            this.parent = parent;
             this.field = field;
             this.message = message;
         }
          * @return field name in OGNL syntax
          */
         public String getFullFieldName(String fieldName) {
+            if (parent instanceof AppendingValidatorContext) {
+                return parent.getFullFieldName("") + field + "." + fieldName;
+            }
             return field + "." + fieldName;
         }
 

src/test/com/opensymphony/xwork2/validator/ValidatorFileParserTest.java

         try {
             ValidatorFileParser.parseValidatorDefinitions(is, testFileName5);
         } catch (XWorkException ex) {
-            assertTrue("Wrong line number", 3 == ex.getLocation().getLineNumber());
+            assertEquals("Wrong line number", 3, ex.getLocation().getLineNumber());
             pass = true;
         }
         assertTrue("Validation file should have thrown exception", pass);