01: /*
02: * Created on Feb 18, 2004
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.vfny.geoserver.form.data;
08:
09: import org.apache.struts.action.ActionError;
10: import org.apache.struts.action.ActionErrors;
11: import org.apache.struts.action.ActionForm;
12: import org.apache.struts.action.ActionMapping;
13: import java.util.regex.Pattern;
14: import javax.servlet.http.HttpServletRequest;
15:
16: /**
17: * DataNamespacesNewForm purpose.
18: * <p>
19: * Description of DataNamespacesNewForm ...
20: * </p>
21: *
22: * @author rgould, Refractions Research, Inc.
23: * @author $Author: jive $ (last modification)
24: * @version $Id: DataNamespacesNewForm.java 6177 2007-02-19 10:11:27Z aaime $
25: */
26: public class DataNamespacesNewForm extends ActionForm {
27: private String prefix;
28:
29: public void reset(ActionMapping arg0, HttpServletRequest request) {
30: super .reset(arg0, request);
31:
32: prefix = "";
33: }
34:
35: /**
36: * Implementation of validate.
37: *
38: * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
39: *
40: * @param mapping
41: * @param request
42: * @return Any ActionErrors produced by validation
43: */
44: public ActionErrors validate(ActionMapping mapping,
45: HttpServletRequest request) {
46: ActionErrors errors = new ActionErrors();
47:
48: if ((getPrefix() == null) || getPrefix().equals("")) {
49: errors.add("prefix", new ActionError(
50: "error.prefix.required", getPrefix()));
51: } else if (!Pattern.matches("^\\w*$", getPrefix())) {
52: errors.add("dataStoreID", new ActionError(
53: "error.prefix.invalid", getPrefix()));
54: }
55:
56: return errors;
57: }
58:
59: /**
60: * Access prefix property.
61: *
62: * @return Returns the prefix.
63: */
64: public String getPrefix() {
65: return prefix;
66: }
67:
68: /**
69: * Set prefix to prefix.
70: *
71: * @param prefix The prefix to set.
72: */
73: public void setPrefix(String prefix) {
74: this.prefix = prefix;
75: }
76: }
|