View Javadoc

1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.control.form;
16  
17  import org.figure8.join.control.JoinForm;
18  import org.figure8.join.control.action.ParameterActions;
19  
20  import org.apache.struts.action.ActionMapping;
21  
22  import javax.servlet.http.HttpServletRequest;
23  /**
24   * Form object to manage parameters into Join application. 
25   * @author <a href="mailto:jerome.evrard@gmail.com">Jerome Evrard</a>
26   * @version $Revision: 1.1 $
27   * 
28   * @struts.form name="parameterForm"
29   */
30  public class ParameterForm extends JoinForm{
31  
32     // Attributes ---------------------------------------------------------------
33     
34     /** The parameter name */
35     private String name;
36     /** The parameter description */
37     private String description;
38  
39  
40     // Public -------------------------------------------------------------------
41  
42     /** @return Returns the name of parameter. */
43     public String getName(){
44        return name;
45     }
46     /** @param name The name to set. */
47     public void setName(String name){
48        this.name = name;
49     }
50  
51     /** @return Returns the description. */
52     public String getDescription(){
53        return description;
54     }
55     /** @param description The description to set. */
56     public void setDescription(String description){
57        this.description = description;
58     }
59  
60  
61     // Override of JoinForm -----------------------------------------------------
62     
63     /**
64      * Validation of the form attributes.
65      * @param operation String representing the operation to invoke on Action
66      * @param mapping Mapping between forwards name and path for this action
67      * @param request The servlet container request wrapper
68      */
69     public void doValidate(String operation, ActionMapping mapping, HttpServletRequest request){
70        if (ParameterActions.LOAD_OP.equalsIgnoreCase(operation) || ParameterActions.SAVE_OP.equalsIgnoreCase(operation)){
71           // Check attributes
72           if (name == null || name.trim().length() == 0)
73              addActionError("errors.required", getGuiMessageResources().getMessage("label.parameter.name"));
74        }
75     }
76  }