On Tue, Mar 11, 2008 at 7:10 AM, xianwinwin <[EMAIL PROTECTED]> wrote: > > assuming registration is composed of fname, lname, ss, dob and except dob > all fields are mandatory. > > Question: how do I make sure those fields will be input? should I have > something like: > > @RequiredStringValidator(message="Legal Name is missing") > private setFname(String fn) > > on the registration - if so - wouldn't that effect other classes that uses > registration??? > > thanks for any input!
Hi xianwinwin, You can annotate an action method with @Validations and validate from there, ie: @Validations( requiredString = { @RequiredFieldValidator( type=ValidatorType.FIELD, fieldName="registration.fname" message="Foo!" ) } ) public String save() { ... } http://struts.apache.org/2.x/docs/validation-annotation.html Admittedly, I used this approach these past few days and found myself back to validations in XML: http://blog.ealden.net/2008/03/working-with-struts-2-validators.html Thanks -- Ealden Esto E. Escañan http://blog.ealden.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]