001: package hero.struts.forms;
002:
003: import java.util.AbstractCollection;
004:
005: import javax.servlet.http.HttpServletRequest;
006: import org.apache.struts.action.ActionError;
007: import org.apache.struts.action.ActionErrors;
008: import org.apache.struts.action.ActionForm;
009: import org.apache.struts.action.ActionMapping;
010:
011: /**
012: * Form bean for Activity. This form has the following fields,
013: * with default values in square brackets:
014: * <ul>
015: * <li><b>role</b> - The name of the hook. [REQUIRED]
016: * <li><b>deadline</b> - The event for this hook. [REQUIRED]
017: * <li><b>description</b> - The hook type [REQUIRED]
018: * </ul>
019: *
020: * @author Miguel Valdes Faura
021: * @version $Revision: 1.1 $ $Date: 2004/07/30 14:57:57 $
022: */
023:
024: public final class ActivityForm extends ActionForm {
025:
026: // =================================================== Instance Variables
027:
028: /**
029: * The activity role
030: */
031: private String role = null;
032:
033: /**
034: * The activity deadline
035: */
036:
037: private String deadline = null;
038:
039: /**
040: * The activity description
041: */
042:
043: private String description = null;
044:
045: /**
046: * Type atribute
047: */
048:
049: private String type = null;
050:
051: /**
052: * Anticipable atribute
053: */
054:
055: private String anticipable = null;
056:
057: /**
058: * Automatic atribute
059: */
060:
061: private String automatic = null;
062:
063: // =========================================================== Properties
064:
065: /**
066: * Return the activity role
067: */
068: public String getRole() {
069:
070: return (this .role);
071:
072: }
073:
074: /**
075: * Set the activity role
076: *
077: */
078: public void setRole(String role) {
079:
080: this .role = role;
081:
082: }
083:
084: /**
085: * Return the activity deadline
086: */
087: public String getDeadline() {
088: if (this .deadline.length() > 10)
089: return (this .deadline.substring(0, 10));
090: else
091: return (this .deadline);
092:
093: }
094:
095: /**
096: * Set the activity deadline
097: *
098: */
099: public void setDeadline(String deadline) {
100:
101: this .deadline = deadline;
102:
103: }
104:
105: /**
106: * Return the activity description
107: */
108: public String getDescription() {
109:
110: return (this .description);
111:
112: }
113:
114: /**
115: * Set the activity description
116: *
117: */
118: public void setDescription(String description) {
119:
120: this .description = description;
121:
122: }
123:
124: /**
125: * Return the activity type
126: */
127: public String getType() {
128:
129: return (this .type);
130:
131: }
132:
133: /**
134: * Set the activity type
135: *
136: */
137: public void setType(String type) {
138: this .type = type;
139: }
140:
141: /**
142: * Return the anticipable value
143: */
144: public String getAnticipable() {
145:
146: return (this .anticipable);
147:
148: }
149:
150: /**
151: * Set anticipable value
152: *
153: */
154: public void setAnticipable(String anticipable) {
155:
156: this .anticipable = anticipable;
157:
158: }
159:
160: /**
161: * Return the automatic value
162: */
163: public String getAutomatic() {
164:
165: return (this .automatic);
166:
167: }
168:
169: /**
170: * Set automatic value
171: *
172: */
173: public void setAutomatic(String automatic) {
174:
175: this .automatic = automatic;
176:
177: }
178:
179: // --------------------------------------------------------- Public Methods
180:
181: /**
182: * Reset all properties to their default values.
183: *
184: * @param mapping The mapping used to select this instance
185: * @param request The servlet request we are processing
186: */
187: public void reset(ActionMapping mapping, HttpServletRequest request) {
188:
189: this .role = null;
190: this .deadline = null;
191: this .description = null;
192: this .type = null;
193: }
194:
195: /**
196: * Validate the properties that have been set from this HTTP request,
197: * and return an <code>ActionErrors</code> object that encapsulates any
198: * validation errors that have been found. If no errors are found, return
199: * <code>null</code> or an <code>ActionErrors</code> object with no
200: * recorded error messages.
201: *
202: * @param mapping The mapping used to select this instance
203: * @param request The servlet request we are processing
204: */
205: public ActionErrors validate(ActionMapping mapping,
206: HttpServletRequest request) {
207:
208: ActionErrors errors = new ActionErrors();
209:
210: if (role == null || role.length() == 0)
211: errors.add("role", new ActionError("error.role.required"));
212: if (deadline == null || deadline.length() == 0)
213: errors.add("deadline", new ActionError(
214: "error.deadline.required"));
215: if (description == null || description.length() == 0)
216: errors.add("description", new ActionError(
217: "error.description.required"));
218:
219: return (errors);
220:
221: }
222: }
|