1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| private String age;
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public ActionErrors validate( ActionMapping mapping, HttpServletRequest request){
ActionErrors errors = new ActionErrors();
f(age==null || age.length()<1)
errors.add("age", new ActionMessage("errors.required","l'age"));
else{
try{
int x=Integer.parseInt(age);
}
catch(NumberFormatException e){
errors.add("age",new ActionMessage("errors.invalid","l'age"));
}
}
return errors;
} |
Partager