• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Does setNestedPath() method works with a sub-object as a Collection type

 
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose I have Class A has a collection type referencing Class B, Class B class a List referencing Class C.

In this case, how can I set the nested path, I am confused.

e.g.

aaa.bbb.ccc (does bbb needs to be concrete class object, how about collection type)?

Thanks.
 
Jiafan Zhou
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be clear on this, following code is an example.

A.class
Code:

...
Collection<B> bbb;
...

B.class
Code:

...
List<String> ccc;
...

Note that each bean has a corresponding custom validation class begins with V.

Code:

String oldPath = errors.getNestedPath();
errors.setNestedPath(oldPath + "bbb"); // is this correct?

// run the validation
...

// reset the old path
errors.setNestedPath(oldPath);

Then whenever the validation is invoked, there is an error message shown on the console. I think this is because Spring Framework cannot correctly pass the "bbb.ccc" because bbb is a Collection type defined in A.class.

Also note that if the bbb is not a collecton type, everything works fine.

Need helps on this touch question.

Thanks,
Jiafan
 
Jiafan Zhou
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the error message is shown below.
Mon Aug 27 14:18:17 BST 2007 - Ignoring item test_case, notReadablePropertyException: An unrecoverable error has occurred: Invalid property 'bbb.ccc' of bean class [A]: Bean property 'bbb.ccc' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? (ccc).

I think this issue also reveals a bigger question on using the setNestedPath(String) method, when the subtree contains a collection type object, does a simple String like "bbb" be able to let Framework find the correct property for the Error message?
 
Jiafan Zhou
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a solution myself now. It follows standard Java bean notation. aaa.bbb.ccc means aaa.getBbb().getCcc(). For collections the notation changes to aaa.bbb[index].ccc and is translated to aaa.getBbb().get(index).getCcc().

After those amazing square brackets, my code works perfectly.

Regards,
Jiafan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic