KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > struts > forms > NodeForm


1 /*
2  * NodeForm.java
3  */

4 package hero.struts.forms;
5
6
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8 import org.apache.struts.action.ActionError;
9 import org.apache.struts.action.ActionErrors;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionMapping;
12
13
14 /**
15  * Form bean for the node. This form has the following fields,
16  * with default values in square brackets:
17  * <ul>
18  * <li><b>name</b> - The username. [REQUIRED]
19  * </ul>
20  *
21  * @author Miguel Valdes Faura
22  * @version $Revision: 1.1 $ $Date: 2004/07/30 14:57:57 $
23  */

24
25
26 public final class NodeForm extends ActionForm {
27     
28     // --------------------------------------------------- Instance Variables
29

30     /**
31      * The name of the node
32      */

33     private String JavaDoc name = null;
34
35     
36     // ----------------------------------------------------------- Properties
37

38    
39     /**
40      * Get the name
41      *@return String
42      */

43     public String JavaDoc getName() {
44         return (name);
45     }
46
47     /**
48      * Set the name
49      * @param name
50      */

51     public void setName(String JavaDoc name) {
52         this.name = name;
53     }
54
55     // --------------------------------------------------------- Public Methods
56

57     /**
58      * Reset all properties to their default values.
59      *
60      * @param mapping The mapping used to select this instance
61      * @param request The servlet request we are processing
62      */

63     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
64     this.name = null;
65         
66     }
67
68
69     /**
70      * Validate the properties that have been set from this HTTP request,
71      * and return an <code>ActionErrors</code> object that encapsulates any
72      * validation errors that have been found. If no errors are found, return
73      * <code>null</code> or an <code>ActionErrors</code> object with no
74      * recorded error messages.
75      *
76      * @param mapping The mapping used to select this instance
77      * @param request The servlet request we are processing
78      */

79     public ActionErrors validate(ActionMapping mapping,
80                                  HttpServletRequest JavaDoc request) {
81         ActionErrors errors = new ActionErrors();
82         if (name == null || name.length()==0)
83             errors.add("name",
84                    new ActionError("error.name.required"));
85         return (errors);
86     }
87
88
89
90 }
91
92
Popular Tags