Skip to content

Commit 16bc236

Browse files
author
graeme
committed
fix for GRAILS-2452
git-svn-id: https://svn.codehaus.org/grails/trunk@6704 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 4ba1931 commit 16bc236

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

src/web/org/codehaus/groovy/grails/web/servlet/GrailsFlashScope.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ private void reassociateObjectsWithErrors(Map scope) {
5151
if(value instanceof Map) {
5252
reassociateObjectsWithErrors((Map)value);
5353
}
54+
reasssociateObjectWithErrors(scope, value);
55+
56+
}
57+
}
58+
59+
private void reasssociateObjectWithErrors(Map scope, Object value) {
60+
if(value instanceof Collection) {
61+
Collection values = (Collection)value;
62+
for (Iterator i = values.iterator(); i.hasNext();) {
63+
Object current = i.next();
64+
reasssociateObjectWithErrors(scope, current);
65+
}
66+
}
67+
else {
5468
String errorsKey = ERRORS_PREFIX + System.identityHashCode(value);
5569
Object errors = scope.get(errorsKey);
5670
if(value!=null && errors != null) {
@@ -59,7 +73,6 @@ private void reassociateObjectsWithErrors(Map scope) {
5973
mc.setProperty(value, ERRORS_PROPERTY, errors);
6074
}
6175
}
62-
6376
}
6477
}
6578

@@ -139,13 +152,23 @@ public Object put(Object key, Object value) {
139152
private void storeErrorsIfPossible(Object value) {
140153
if(value != null) {
141154

142-
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(value.getClass());
143-
if(mc.hasProperty(value, ERRORS_PROPERTY)!=null) {
144-
Object errors = mc.getProperty(value, ERRORS_PROPERTY);
145-
if(errors != null) {
146-
next.put(ERRORS_PREFIX + System.identityHashCode(value), errors);
155+
if(value instanceof Collection) {
156+
Collection values = (Collection)value;
157+
for (Iterator i = values.iterator(); i.hasNext();) {
158+
Object current = i.next();
159+
storeErrorsIfPossible(current);
160+
}
161+
}
162+
else {
163+
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(value.getClass());
164+
if(mc.hasProperty(value, ERRORS_PROPERTY)!=null) {
165+
Object errors = mc.getProperty(value, ERRORS_PROPERTY);
166+
if(errors != null) {
167+
next.put(ERRORS_PREFIX + System.identityHashCode(value), errors);
168+
}
147169
}
148170
}
171+
149172
}
150173
}
151174

0 commit comments

Comments
 (0)