/*
* NodeForm.java
*/
package hero.struts.forms;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for the node. This form has the following fields,
* with default values in square brackets:
* <ul>
* <li><b>name</b> - The username. [REQUIRED]
* </ul>
*
* @author Miguel Valdes Faura
* @version $Revision: 1.1 $ $Date: 2004/07/30 14:57:57 $
*/
public final class NodeForm extends ActionForm {
// --------------------------------------------------- Instance Variables
/**
* The name of the node
*/
private String name = null;
// ----------------------------------------------------------- Properties
/**
* Get the name
*@return String
*/
public String getName() {
return (name);
}
/**
* Set the name
* @param name
*/
public void setName(String name) {
this.name = name;
}
// --------------------------------------------------------- Public Methods
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.name = null;
}
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (name == null || name.length()==0)
errors.add("name",
new ActionError("error.name.required"));
return (errors);
}
}
|