|
From: Seth L. <se...@eh...> - 2004-03-03 23:43:23
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 (putting this reply on list because of some explanation that might others) Keith Donald wrote: | Seth, | | The way I look at it is this: | | The validation rules I want to apply to a domain object are generally very | specific to that domain object. For example, I may have a Pet class, like | in the Pet clinic. I want to validate that all Pet's have a name, all Pet's | have a unique name, and no Pet weighs less than 1 pound. I can either Yes, this is exactly the way Spring works now. It asks you to bind a certain validator to a certain controller class. The way my Attribute Validator works, is you place the validation attributes on the domain object. This way, the domain object has the validation meta data attached to it. All you need to bind is the generic AttributeValidator class to each controller. This way, one validator handles all domain objects (as long as they have the validation rules bound to them, of course :) More and more it sounds like we're coming from two opposite ends. No right or wrong here, just very different. | Or I can just go to my Pet.java source file and see them as source-level | attributes. Right, this is exactly what I do. No need for a resolver now. | commons-attributes? However, that still doesn't cut out the need to lookup | the validator for a bean (aka command in spring-web) in order to kick See above and my code. I should put an example on the web site I put up. That might explain everything. General Explanation: 1 (singleton) AttributeValidator for webapp, implements spring.Validator N controllers N command objects (the beans populated from the form) 1:1 controller:command object 1:1 controller:validator 1:M command object:attributes (validation rules) So the command object has the validation rules in form of attributes. The generic attributevalidator can look into the command object, get the attributes, and do the validation. Hope that helps. Seth -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFARmpg5EIB1scRes8RAuGyAJ9VTMEJ8u8Ss+Vj/RtVvWwzyhpJ+ACePtgr HnkBdQsJSdJTWCrBQxsjUh8= =0TbM -----END PGP SIGNATURE----- |