01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.form.data;
06:
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: import java.util.regex.Pattern;
12: import javax.servlet.http.HttpServletRequest;
13:
14: /**
15: * Gather enough information to reate a new Style for editing.
16: *
17: * @author jgarnett, Refractions Research, Inc.
18: * @author $Author: jive $ (last modification)
19: * @version $Id: StylesNewForm.java 6326 2007-03-15 18:36:40Z jdeolive $
20: */
21: public class StylesNewForm extends ActionForm {
22: /** StyleID entered by user */
23: private String styleID;
24:
25: public void reset(ActionMapping arg0, HttpServletRequest request) {
26: super .reset(arg0, request);
27: styleID = "";
28: }
29:
30: /**
31: * Implementation of validate.
32: *
33: * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
34: *
35: * @param mapping
36: * @param request
37: * @return Any ActionErrors produced by validation
38: */
39: public ActionErrors validate(ActionMapping mapping,
40: HttpServletRequest request) {
41: ActionErrors errors = new ActionErrors();
42:
43: if ((styleID == null) || styleID.equals("")) {
44: errors.add("styleID", new ActionError(
45: "error.styleID.required", styleID));
46: } else if (!Pattern.matches("^[-\\w.:]*$", styleID)) {
47: errors.add("styleID", new ActionError(
48: "error.styleID.invalid", styleID));
49: }
50:
51: return errors;
52: }
53:
54: /**
55: * Access styleID property.
56: *
57: * @return Returns the styleID.
58: */
59: public String getStyleID() {
60: return styleID;
61: }
62:
63: /**
64: * Set styleID to styleID.
65: *
66: * @param styleID The styleID to set.
67: */
68: public void setStyleID(String styleID) {
69: this.styleID = styleID;
70: }
71: }
|