-
Feb 5th, 2009, 03:56 AM
#1
Prevent redundant validation code
Dear all,
I'm quite new to Spring and ran into a problem, for which I could not find a satisfying solution.
Say I have a Product1Validator and a Product2Validator, both implement Validator. And that I have SimpleFormControllers for both Product1 and
Product2.
Now, from the Product1 page, I also want to be able to create Product2's
(from a quick popup, only filling in some required fields).
I do not know how to use the Product2 validator from Product1's controller,
so I added a static method validate(Product2) to Product2Validator.
It works quite well, but the fact that I have a duplicate validate() method (the static and instance variant) does not feel good.
I also cannot have the instance method call the static one here, because the instance method uses org.springframework.validation.Errors.
Hope I made myself clear enough here ...
And thanks for any design tips.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules