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.ComponentActions;
19  
20  import org.apache.struts.action.ActionMapping;
21  
22  import javax.servlet.http.HttpServletRequest;
23  /**
24   * Struts form object used for manipulating component business objects within Join.
25   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
26   * @version $Revision: 1.1 $
27   *
28   * @struts.form name="componentForm"
29   */
30  public class ComponentForm extends JoinForm{
31  
32     // Attributes ---------------------------------------------------------------
33  
34     /** The component key */
35     private String key;
36     /** The component type key identifier */
37     private String typeKey;
38     /** The name of release this component is attached to */
39     private String releaseName;
40  
41  
42     // Constructors -------------------------------------------------------------
43  
44     /** Creates a new instance of ComponentForm */
45     public ComponentForm(){
46     }
47  
48  
49     // Public -------------------------------------------------------------------
50  
51     /** @return This component unique key */
52     public String getKey(){
53        return key;
54     }
55     /** @param key This component unique key */
56     public void setKey(String key){
57        this.key = key;
58     }
59     /** @return This component type unique key */
60     public String getTypeKey(){
61        return typeKey;
62     }
63     /** @param typeKey This component type business key */
64     public void setTypeKey(String typeKey){
65        this.typeKey = typeKey;
66     }
67     /** @return The name of the release this component is attached to */
68     public String getReleaseName(){
69        return releaseName;
70     }
71     /** @param releaseName The name of release this component is attached to */
72     public void setReleaseName(String releaseName){
73        this.releaseName = releaseName;
74     }
75  
76  
77     // Implementation of JoinForm -----------------------------------------------
78  
79     /**
80      * Validate inner attributes.
81      * @param operation String representing the operation to invoke on Action
82      * @param mapping Mapping between forwards name and path for this action
83      * @param request The servlet container request wrapper
84      */
85     public void doValidate(String operation, ActionMapping mapping, HttpServletRequest request){
86  
87        if (ComponentActions.DETAILS_OP.equals(operation)){
88           // Check and see if key is missing.
89           if (key == null || key.length() == 0)
90              addActionError("errors.required", getGuiMessageResources().getMessage("label.component.key"));
91        }
92        else if (ComponentActions.SEARCH_OP.equals(operation)){
93           // Check and see if type key is missing.
94           if (typeKey == null || typeKey.length() == 0)
95              addActionError("errors.required", getGuiMessageResources().getMessage("label.component.type"));
96           // Check and see if release name is missing.
97           if (releaseName == null || releaseName.length() == 0)
98              addActionError("errors.required", getGuiMessageResources().getMessage("label.component.release"));
99        }
100    }
101 
102 
103    // Override of ActionForm ---------------------------------------------------
104 
105    /**
106     * Reset form attributes.
107     * @param mapping Mapping between forwards name and path for this action
108     * @param request The servlet container request wrapper
109     */
110    public void reset(ActionMapping mapping, HttpServletRequest request){
111       super.reset(mapping, request);
112    }
113 }
114