• 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

Issue with compound form bean

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a bean which is backing a form in my code and it contains, conditionally, other beans like so



The controller method that handles posts to the form looks like so (ServiceResponseWrapper is a class we created which we use to pass the result back as JSON):



I am having some problems with this setup. One issue is that mySubBean1.prop1 isn't being validated. The other is that when I do this



the code pukes.

Any thoughts,
Rob
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well lets deal with issue one first, and then see if the second issue persists. The validation framework is not recursive by default which is desirable in some cases. In order to get the behavior you want you need to annotate your sub beans with @Valid.

 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That indeed took care of the first issue. The second issue was caused by a problem in the javascript that resulted in the form being posted normally as opposed to an AJAX post which the code was expecting.

Thanks,
Rob
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic