KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > formbean > ArtistForm


1 package formbean;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
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 JavaDoc artistName = null;
13     private String JavaDoc dateOfBirth = null;
14
15     public void setArtistName(String JavaDoc value) {
16         artistName = value;
17     }
18     public String JavaDoc getArtistName() {
19         return artistName;
20     }
21
22     public void setDateOfBirth(String JavaDoc value) {
23         dateOfBirth = value;
24     }
25     public String JavaDoc getDateOfBirth() {
26         return dateOfBirth;
27     }
28
29     /**
30       * Reset all properties to their default values.
31       *
32       * @param mapping The mapping used to select this instance
33       * @param request The servlet request we are processing
34       */

35     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
36
37         this.artistName = null;
38         this.dateOfBirth = null;
39
40     }
41
42     /**
43      * Validate the properties that have been set from this HTTP request,
44      * and return an <code>ActionErrors</code> object that encapsulates any
45      * validation errors that have been found. If no errors are found, return
46      * <code>null</code> or an <code>ActionErrors</code> object with no
47      * recorded error messages.
48      *
49      * @param mapping The mapping used to select this instance
50      * @param request The servlet request we are processing
51      */

52     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc 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