001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: WebAppForm.java 8314 2006-05-03 09:43:47Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.container;
027:
028: import java.util.List;
029:
030: import javax.servlet.http.HttpServletRequest;
031:
032: import org.apache.struts.action.ActionMessage;
033: import org.apache.struts.action.ActionErrors;
034: import org.apache.struts.action.ActionForm;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.webapp.jonasadmin.Jlists;
037:
038: /**
039: * @author Michel-Ange ANTON
040: */
041: public class WebAppForm extends ActionForm {
042:
043: // --------------------------------------------------------- Properties variables
044:
045: private String action = "edit";
046: private boolean save = false;
047: private String pathContext = null;
048: private String labelPathContext = null;
049: private List booleanValues = Jlists.getBooleanValues();
050: private String objectName = null;
051: private String j2eeApplication = null;
052: private String j2eeServer = null;
053: private String name = null;
054:
055: // --------------------------------------------------------- Public Methods
056:
057: /**
058: * Reset all properties to their default values.
059: *
060: * @param mapping The mapping used to select this instance
061: * @param request The servlet request we are processing
062: */
063:
064: public void reset(ActionMapping mapping, HttpServletRequest request) {
065: action = "edit";
066: save = false;
067: }
068:
069: /**
070: * Validate the properties that have been set from this HTTP request,
071: * and return an <code>ActionErrors</code> object that encapsulates any
072: * validation errors that have been found. If no errors are found, return
073: * <code>null</code> or an <code>ActionErrors</code> object with no
074: * recorded error messages.
075: *
076: * @param mapping The mapping used to select this instance
077: * @param request The servlet request we are processing
078: * @return List of errors
079: */
080: public ActionErrors validate(ActionMapping mapping,
081: HttpServletRequest request) {
082: ActionErrors oErrors = new ActionErrors();
083: // Path context
084: if (getPathContext().length() == 0) {
085: oErrors.add("context", new ActionMessage(
086: "error.webapp.context.required"));
087: }
088: return oErrors;
089: }
090:
091: // --------------------------------------------------------- Properties Methods
092:
093: public String getPathContext() {
094: return pathContext;
095: }
096:
097: public void setPathContext(String pathContext) {
098: this .pathContext = pathContext;
099: if (pathContext.length() > 0) {
100: if (pathContext.charAt(0) != '/') {
101: this .pathContext = "/" + pathContext;
102: }
103: }
104: }
105:
106: public String getAction() {
107: return action;
108: }
109:
110: public void setAction(String action) {
111: this .action = action;
112: }
113:
114: public List getBooleanValues() {
115: return booleanValues;
116: }
117:
118: public String getLabelPathContext() {
119: return labelPathContext;
120: }
121:
122: public void setLabelPathContext(String labelPathContext) {
123: this .labelPathContext = labelPathContext;
124: }
125:
126: public boolean isSave() {
127: return save;
128: }
129:
130: public void setSave(boolean save) {
131: this .save = save;
132: }
133:
134: public String getObjectName() {
135: return objectName;
136: }
137:
138: public void setObjectName(String objectName) {
139: this .objectName = objectName;
140: }
141:
142: public String getJ2eeApplication() {
143: return j2eeApplication;
144: }
145:
146: public void setJ2eeApplication(String j2eeApplication) {
147: this .j2eeApplication = j2eeApplication;
148: }
149:
150: public String getJ2eeServer() {
151: return j2eeServer;
152: }
153:
154: public void setJ2eeServer(String j2eeServer) {
155: this .j2eeServer = j2eeServer;
156: }
157:
158: public String getName() {
159: return name;
160: }
161:
162: public void setName(String name) {
163: this.name = name;
164: }
165:
166: }
|