001: /*
002: * $Id: GangsterForm.java 478625 2006-11-23 17:31:52Z wsmoak $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.showcase.integration;
022:
023: import javax.servlet.http.HttpServletRequest;
024:
025: import org.apache.struts.action.ActionErrors;
026: import org.apache.struts.action.ActionMapping;
027: import org.apache.struts.action.ActionMessage;
028: import org.apache.struts.validator.ValidatorForm;
029:
030: public class GangsterForm extends ValidatorForm {
031:
032: private String name;
033: private String age;
034: private String description;
035: private boolean bustedBefore;
036:
037: /* (non-Javadoc)
038: * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
039: */
040: @Override
041: public void reset(ActionMapping arg0, HttpServletRequest arg1) {
042: bustedBefore = false;
043: }
044:
045: /* (non-Javadoc)
046: * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
047: */
048: @Override
049: public ActionErrors validate(ActionMapping mapping,
050: HttpServletRequest request) {
051: ActionErrors errors = super .validate(mapping, request);
052: if (name == null || name.length() == 0) {
053: errors.add("name", new ActionMessage(
054: "The name must not be blank"));
055: }
056:
057: return errors;
058: }
059:
060: /**
061: * @return the age
062: */
063: public String getAge() {
064: return age;
065: }
066:
067: /**
068: * @param age the age to set
069: */
070: public void setAge(String age) {
071: this .age = age;
072: }
073:
074: /**
075: * @return the bustedBefore
076: */
077: public boolean isBustedBefore() {
078: return bustedBefore;
079: }
080:
081: /**
082: * @param bustedBefore the bustedBefore to set
083: */
084: public void setBustedBefore(boolean bustedBefore) {
085: this .bustedBefore = bustedBefore;
086: }
087:
088: /**
089: * @return the description
090: */
091: public String getDescription() {
092: return description;
093: }
094:
095: /**
096: * @param description the description to set
097: */
098: public void setDescription(String description) {
099: this .description = description;
100: }
101:
102: /**
103: * @return the name
104: */
105: public String getName() {
106: return name;
107: }
108:
109: /**
110: * @param name the name to set
111: */
112: public void setName(String name) {
113: this.name = name;
114: }
115:
116: }
|