Announcement Announcement Module
No announcement yet.
Nested maps vs. nested beans? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nested maps vs. nested beans?


    Maybe this problem is easy to solve, but I have been running against a wall, lately. I am using Freemarker and Spring, trying to do some validation stuff. No trouble with getting data displayed. Problems begin where I try to get validation results displayed.

    Consider a bean "a" that has an attribute "b" which is also of a bean type and has an attribute "c". If I use the bean "a" as @ModelAttribute("a"), and initialize "b" properly, then I can access ${a.b.c} from within the template. I can do [@spring.bind "a.*"] from within Freemarker and if I do a rejectValue() from within the controller, I get my errors nicely displayed using a macro that reads all errrors from the BindingResult.

    So far so good. No trouble here.

    My question goes
    Is it possible to do the same using a map "a" that is added to the ModelMap and that contains another Map "b" which in turn has an attribute "c"?

    Currently I do not think so: I get things *displayed* easily, using again the ${a,b,c} syntax within Freemarker. However, if I try to use binding, e.g. [@spring.bind "a.b"/] with corresponding rejectValue() calls, I am told that there is no "getter" for "b" in "a". Of course, there is not, as "a" is not a bean, but a Map.

    Is that true, that this way of using spring.bind works only for beans and does not work for maps?

    I would be very thankful for any pointer you can give to me.