01: /*
02: * NodeForm.java
03: */
04: package hero.struts.forms;
05:
06: import javax.servlet.http.HttpServletRequest;
07: import org.apache.struts.action.ActionError;
08: import org.apache.struts.action.ActionErrors;
09: import org.apache.struts.action.ActionForm;
10: import org.apache.struts.action.ActionMapping;
11:
12: /**
13: * Form bean for the node. This form has the following fields,
14: * with default values in square brackets:
15: * <ul>
16: * <li><b>name</b> - The username. [REQUIRED]
17: * </ul>
18: *
19: * @author Miguel Valdes Faura
20: * @version $Revision: 1.1 $ $Date: 2004/07/30 14:57:57 $
21: */
22:
23: public final class NodeForm extends ActionForm {
24:
25: // --------------------------------------------------- Instance Variables
26:
27: /**
28: * The name of the node
29: */
30: private String name = null;
31:
32: // ----------------------------------------------------------- Properties
33:
34: /**
35: * Get the name
36: *@return String
37: */
38: public String getName() {
39: return (name);
40: }
41:
42: /**
43: * Set the name
44: * @param name
45: */
46: public void setName(String name) {
47: this .name = name;
48: }
49:
50: // --------------------------------------------------------- Public Methods
51:
52: /**
53: * Reset all properties to their default values.
54: *
55: * @param mapping The mapping used to select this instance
56: * @param request The servlet request we are processing
57: */
58: public void reset(ActionMapping mapping, HttpServletRequest request) {
59: this .name = null;
60:
61: }
62:
63: /**
64: * Validate the properties that have been set from this HTTP request,
65: * and return an <code>ActionErrors</code> object that encapsulates any
66: * validation errors that have been found. If no errors are found, return
67: * <code>null</code> or an <code>ActionErrors</code> object with no
68: * recorded error messages.
69: *
70: * @param mapping The mapping used to select this instance
71: * @param request The servlet request we are processing
72: */
73: public ActionErrors validate(ActionMapping mapping,
74: HttpServletRequest request) {
75: ActionErrors errors = new ActionErrors();
76: if (name == null || name.length() == 0)
77: errors.add("name", new ActionError("error.name.required"));
78: return (errors);
79: }
80:
81: }
|