This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes Issue with compound form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Issue with compound form bean" Watch "Issue with compound form bean" New topic
Author

Issue with compound form bean

Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
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
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

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.



[How To Ask Questions][Read before you PM me]
Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Issue with compound form bean
 
Similar Threads
Nested if()
Does your company require documentation? If so, what kind?
Are the inline conditionals to tough for a junior programmer ?
Assertions and sub-classing