PDA

View Full Version : Well ..NO validate method but want to display messages next to text box .



rajeevnadgauda
Mar 10th, 2012, 02:45 PM
I am new to spring mvc, I am using the onsubmit method and since i am using different kind of variables in my pojo including a refrence to another class. And i have been asked to do all validations in the business layer and hence can't use the validator . I have also disabled binding of form data .NOw i want to display error messages at the side of the text box, which i have created in a list in my program. Can i use Error class and returnthe modelandview object with addObject. Also what tag can i use so as to make it easy to display the error messages along the side of a particular text box.Sorry if it is silly but i can't use a validator i am not supposed to so please help.

dr_pompeii
Mar 10th, 2012, 06:41 PM
Hello

Start reading carefully this documentation 16. Web MVC framework (http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/mvc.html)

Gradinko
Mar 12th, 2012, 08:45 AM
Definitely don't agree with where you're going in terms of doing all validation i the business layer, BUT to answer your question I think you may want to just look at creating and throwing a BindException from your business layer. This will involve adding Errors objects to the exception, which will later be picked up by the form:errors tag in your view and display error messages.