Hi

I've an action class like below. I put the skipvalidation annotation because
I don't want strut to validate all annotated fields. My problem is that I
still want to do the validation for 'name' field. 

So.. is there a way to manually invoke only certain fields' annotation
validation? I could check whether the 'name' field is empty or not in my
'execute' action, but that would be duplicating code and you don't really
want to do that when you have many fields in your class.


@Validation
public class SomeClass extends ActionSupport {

        private static final long serialVersionUID = 1L;

        private String name;
        private String description;
        
        @SkipValidation
        public String execute() {
                return SUCCESS;
        }

        @RequiredStringValidator(fieldName="name", message="Please enter name")
        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }

        @RequiredStringValidator(fieldName="description", message="Please enter
description")
        public String getDescription() {
                return description;
        }

        public void setDescription(String description) {
                this.description = description;
        }
}

Thanks,
Joe
-- 
View this message in context: 
http://www.nabble.com/How-to-invoke-annotation-validation-manually-tp23477091p23477091.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


Reply via email to