Hello
I have a form on a
JSP:
Where a user is required to enter a valid number for later use as the key of a domain object.
In the matching controller, I would like to use a SpringValidator to do the validation as follows:
Will not allow it because I understand that validators are meant for domain objects.
So in order to get around this, for now, I've used the following:
Where SomethingValidator has a validate method:
And Messages is a simple utility class containing an arraylist of strings.
The above code works, for now, I but I would much rather use a SpringValidator.
Does anyone have any ideas of how I might do this?
I have tried using the id as a Spring model attribute but it doesn't actually belong to a domain object but to no avail. I could use id as part of a model attribute representing the domain object id actually belongs to, but putting all of the object's fields on the form as hidden fields and passing them to the controller seems daft.
On a related matter, is it best to bundle all controller methods for a domain object into one controller, or is it better to factor them into individual controllers where each handles one or more related operations?
I have used the latter approach so far.
Thanks
Martin O'Shea.