Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » integration » [javadoc | source]

    1   /*
    2    * $Id: GangsterForm.java 478625 2006-11-23 17:31:52Z wsmoak $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    *  http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   package org.apache.struts2.showcase.integration;
   22   
   23   import javax.servlet.http.HttpServletRequest;
   24   
   25   import org.apache.struts.action.ActionErrors;
   26   import org.apache.struts.action.ActionMapping;
   27   import org.apache.struts.action.ActionMessage;
   28   import org.apache.struts.validator.ValidatorForm;
   29   
   30   public class GangsterForm extends ValidatorForm {
   31   
   32       private String name;
   33       private String age;
   34       private String description;
   35       private boolean bustedBefore;
   36   
   37       /* (non-Javadoc)
   38        * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
   39        */
   40       @Override
   41       public void reset(ActionMapping arg0, HttpServletRequest arg1) {
   42           bustedBefore = false;
   43       }
   44   
   45       /* (non-Javadoc)
   46        * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
   47        */
   48       @Override
   49       public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
   50           ActionErrors errors = super.validate(mapping, request);
   51           if (name == null || name.length() == 0) {
   52               errors.add("name", new ActionMessage("The name must not be blank"));
   53           }
   54   
   55           return errors;
   56       }
   57   
   58       /**
   59        * @return the age
   60        */
   61       public String getAge() {
   62           return age;
   63       }
   64       /**
   65        * @param age the age to set
   66        */
   67       public void setAge(String age) {
   68           this.age = age;
   69       }
   70       /**
   71        * @return the bustedBefore
   72        */
   73       public boolean isBustedBefore() {
   74           return bustedBefore;
   75       }
   76       /**
   77        * @param bustedBefore the bustedBefore to set
   78        */
   79       public void setBustedBefore(boolean bustedBefore) {
   80           this.bustedBefore = bustedBefore;
   81       }
   82       /**
   83        * @return the description
   84        */
   85       public String getDescription() {
   86           return description;
   87       }
   88       /**
   89        * @param description the description to set
   90        */
   91       public void setDescription(String description) {
   92           this.description = description;
   93       }
   94       /**
   95        * @return the name
   96        */
   97       public String getName() {
   98           return name;
   99       }
  100       /**
  101        * @param name the name to set
  102        */
  103       public void setName(String name) {
  104           this.name = name;
  105       }
  106   
  107   
  108   }

Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » integration » [javadoc | source]