[
https://issues.apache.org/struts/browse/WW-2292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42575
]
[EMAIL PROTECTED] edited comment on WW-2292 at 11/6/07 4:23 AM:
------------------------------------------------------------------------
Yes. I extend the ActionSupport like the annotation sample
http://struts.apache.org/2.0.11/docs/validation-annotation.html
Below the class
package com.jdo.actions.customer;
import org.apache.struts2.config.Namespace;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.apache.struts2.dispatcher.ServletRedirectResult;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
@Namespace("/register")
@Results({
@Result(name="success", value="/jsp/success.jsp",
type=ServletRedirectResult.class),
@Result(name="input", value="/jsp/customer.jsp",
type=ServletDispatcherResult.class),
@Result(name="error", value="/jsp/error.jsp",
type=ServletRedirectResult.class)
})
public class CreateAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -2661899805487898664L;
private String name;
private Integer age;
private String email;
@RequiredStringValidator(trim=true, message="The name is required")
@StringLengthFieldValidator(minLength="2", maxLength="10", message="The
name length must be between ${mixLength} and ${maxLength}")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@RequiredFieldValidator(message="The age is required")
@IntRangeFieldValidator(min="0", max="2147483647", message="The age
must be an integer")
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@RequiredStringValidator(trim=true, message="The email is required")
@EmailValidator(message="The email is invalid")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String execute() throws Exception{
return "success";
}
}
was (Author: [EMAIL PROTECTED]):
Yes.
> Validation occurs without need the @Validation annotation with Zero
> Configuration
> ---------------------------------------------------------------------------------
>
> Key: WW-2292
> URL: https://issues.apache.org/struts/browse/WW-2292
> Project: Struts 2
> Issue Type: Bug
> Components: Core Actions
> Affects Versions: 2.0.9, 2.0.11
> Environment: Windows XP 2600.xpsp_sp2_rtm.040803-2158 (SP2). Tomcat
> 6.0.14
> Reporter: Jason Douglas de Oliveira
>
> When the action class has some annotation related with validation like:
> @RequiredStringValidator, @StringLengthFieldValidator,
> @RequiredFieldValidator, etc. The action is validate without need the
> @Validation annotation.
> I try too with @VisitorFieldValidator and the same behavior happen.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.