Forums Register Login

MVC and Form Validation

+Pie Number of slices to send: Send
Which component is responsible for doing form validation or any type of validation? Should it be the controller or the model?
I am thinking it is up to the controller to validate the form parameters. I know this can be accomplished quite easily using JavaScript but I will refrain from using it for this task.
I am not using Struts, but I have a pretty good idea that the Action classes will do much of the validation.
Any ideas?
Thanks
+Pie Number of slices to send: Send
have you checked this link?
http://www.javaworld.com/javaworld/jw-03-2000/jw-0331-ssj-forms.html
i've been using this...
hope it helps
+Pie Number of slices to send: Send
In Struts the primary (field-oriented) validation is done by the "model". Which they consider a violation of what a model's for, but it works, so it doesn't really matter.
An alternative implementation has been worked out where the actual validation is done declaratively, but it's still attached to the model.
This is just part of the validation process, however. If a form fails validation, the bean is sent (back) for correction, otherwise the Action processor gets control and it can do business-rule type validation, which is to say validation where the relationships between fields is considered more closely.
In a TRUE MVC implementation -- which is something that no HTTP-based system is capable of delivering, the validation is really a controller thing, where validation can actually occur as you are inputting the data. For example, making the terminal beep and reject letters being typed into a numeric field. JavaScript can be used for that type of purpose.
What are you doing in my house? Get 'em tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 705 times.
Similar Threads
Form Level Error Messages In JSF
design advaice for data validation
Validating some extra fields of action form not in my jsp?
Where To Locate Data Binding and Validation
Have any problem using validator
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:09:08.