Command (Form Backing) Objects by R4R Team

Command (Form Backing) Objects:-

Spring uses the notion of a command object, which essentially is a JavaBean style class that gets populated with the data from an HTML formís fields.This same object is also passed to our validators  for data validation, and if the validations pass, it is passed to the onSubmit method (in controller related classes) for processing of valid data. Given that this command object is a simple JavaBean-style class, we can use our business objects directly for data binding instead of writing special classes just for data binding.

(OR)

Command Objects are POJOs used to bind the request data and make it available on screen. In Struts action forms, we used to extend the objects from a Struts class, but here we donít need to do it. This is one of the advantages of Spring, that the data objects are not coupled with the framework. There is difference between the command object and form when these terms are used in Spring MVC documentation.The term ĎFormí is used to describe the process of binding attributes of the object with fields of a screen form. Thus, submission, resubmission etc. features are associated with respect to a form.

@RequestMapping("/somepath/foo/do")

public String someHandlerMethod(

@ModelAttribute("commandObject") CommandObject commandObject,

Model model,

BindingResult result) {

...processing...

return("");

}

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!