001: /*
002: * EdgeForm.java
003: */
004: package hero.struts.forms;
005:
006: import javax.servlet.http.HttpServletRequest;
007: import org.apache.struts.action.ActionError;
008: import org.apache.struts.action.ActionErrors;
009: import org.apache.struts.action.ActionForm;
010: import org.apache.struts.action.ActionMapping;
011:
012: /**
013: * Form bean for the edge. This form has the following fields,
014: * with default values in square brackets:
015: * <ul>
016: * <li><b>nodeIn</b> - The nodeIn of the edge. [REQUIRED]
017: * <li><b>nodeOut</b> - The nodeOut of the edge. [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 EdgeForm extends ActionForm {
025:
026: // --------------------------------------------------- Instance Variables
027:
028: /**
029: * The name of the in node
030: */
031: private String nodeIn = null;
032:
033: /**
034: * The name of the out node
035: */
036: private String nodeOut = null;
037:
038: // ----------------------------------------------------------- Properties
039:
040: /**
041: * Get the nodeIn
042: *@return String
043: */
044: public String getNodeIn() {
045: return (nodeIn);
046: }
047:
048: /**
049: * Set the nodeIn.
050: * @param nodeIn
051: */
052: public void setNodeIn(String nodeIn) {
053: this .nodeIn = nodeIn;
054: }
055:
056: /**
057: * Get the nodeOut
058: *@return String
059: */
060: public String getNodeOut() {
061: return (nodeOut);
062: }
063:
064: /**
065: * Set the nodeOut.
066: * @param nodeOut
067: */
068: public void setNodeOut(String nodeOut) {
069: this .nodeOut = nodeOut;
070: }
071:
072: // --------------------------------------------------------- Public Methods
073:
074: /**
075: * Reset all properties to their default values.
076: *
077: * @param mapping The mapping used to select this instance
078: * @param request The servlet request we are processing
079: */
080:
081: public void reset(ActionMapping mapping, HttpServletRequest request) {
082: this .nodeIn = null;
083: this .nodeOut = null;
084:
085: }
086:
087: /**
088: * Validate the properties that have been set from this HTTP request,
089: * and return an <code>ActionErrors</code> object that encapsulates any
090: * validation errors that have been found. If no errors are found, return
091: * <code>null</code> or an <code>ActionErrors</code> object with no
092: * recorded error messages.
093: *
094: * @param mapping The mapping used to select this instance
095: * @param request The servlet request we are processing
096: */
097: public ActionErrors validate(ActionMapping mapping,
098: HttpServletRequest request) {
099: ActionErrors errors = new ActionErrors();
100: if (nodeIn == null || nodeIn.length() == 0)
101: errors.add("nodeIn", new ActionError(
102: "error.nodeIn.required"));
103: if (nodeOut == null || nodeOut.length() == 0)
104: errors.add("nodeOut", new ActionError(
105: "error.nodeOut.required"));
106:
107: return (errors);
108: }
109:
110: }
|