1 package formbean; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 import org.apache.struts.action.ActionError; 6 import org.apache.struts.action.ActionErrors; 7 import org.apache.struts.action.ActionForm; 8 import org.apache.struts.action.ActionMapping; 9 10 public final class ArtistForm extends ActionForm { 11 12 private String artistName = null; 13 private String dateOfBirth = null; 14 15 public void setArtistName(String value) { 16 artistName = value; 17 } 18 public String getArtistName() { 19 return artistName; 20 } 21 22 public void setDateOfBirth(String value) { 23 dateOfBirth = value; 24 } 25 public String getDateOfBirth() { 26 return dateOfBirth; 27 } 28 29 35 public void reset(ActionMapping mapping, HttpServletRequest request) { 36 37 this.artistName = null; 38 this.dateOfBirth = null; 39 40 } 41 42 52 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 53 54 System.err.println("****Inside ArtistForm.validate()"); 55 ActionErrors errors = new ActionErrors(); 56 if ((artistName == null) || (artistName.length() < 1)) 57 errors.add("artistName", new ActionError("error.artistname.required")); 58 59 if (dateOfBirth == null) 60 errors.add("dateOfBirth", new ActionError("No date of birth provided")); 61 62 return errors; 63 64 } 65 66 } 67 | Popular Tags |