KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > formbean > GalleryForm


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 GalleryForm extends ActionForm {
11
12     private String JavaDoc galleryName = null;
13
14     public void setGalleryName(String JavaDoc value) {
15         galleryName = value;
16     }
17     public String JavaDoc getGalleryName() {
18         return galleryName;
19     }
20
21     /**
22      * Reset all properties to their default values.
23      *
24      * @param mapping The mapping used to select this instance
25      * @param request The servlet request we are processing
26      */

27     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
28         this.galleryName = null;
29     }
30
31     /**
32      * Validate the properties that have been set from this HTTP request,
33      * and return an <code>ActionErrors</code> object that encapsulates any
34      * validation errors that have been found. If no errors are found, return
35      * <code>null</code> or an <code>ActionErrors</code> object with no
36      * recorded error messages.
37      *
38      * @param mapping The mapping used to select this instance
39      * @param request The servlet request we are processing
40      */

41     public ActionErrors validate(
42         ActionMapping mapping,
43         HttpServletRequest JavaDoc request) {
44
45         ActionErrors errors = new ActionErrors();
46         if ((galleryName == null) || (galleryName.length() < 1))
47             errors.add(
48                 "galleryName",
49                 new ActionError("error.galleryname.required"));
50
51         return errors;
52
53     }
54 }
Popular Tags