1   package ch.ige.edossier.web.struts;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import org.apache.struts.action.*;
5   
6   /**
7    * B32.03 - eDossier-Interceptions - Diplomarbeit an der Software-Schule Schweiz<br>
8    * Die Klasse ContactForm ist die Datenhaltung der contact.jsp.
9    * <p>
10   * Copyright (c) 2004, Eidgenössisches Institut für Geistiges Eigentum
11   * @author    Anita Rueegsegger, Marc Bouquet
12   * @version   $Id: ContactForm.java,v 1.7 2004/11/15 18:22:52 bouquet Exp $
13   */
14  public class ContactForm extends ActionForm
15  {
16    private String cbxTo;
17    private String txfNr;
18    private String txfZipCode;
19    private String cbxSection;
20    private String txfEmail;
21    private String txfFirm;
22    private String txfMessage;
23    private String txfName;
24    private String txfCity;
25    private String txfStreet;
26    private String txfPhone;
27  
28    //*******************************************************************************************************************
29     //  G E T T E R -  U N D  S E T T E R - M E T H O D E N  D E R  A C T I O N F O R M
30     //*******************************************************************************************************************
31  
32      public String getCbxSection()
33      {
34        return cbxSection;
35      }
36  
37    public String getCbxTo()
38    {
39      return cbxTo;
40    }
41  
42    public String getTxfCity()
43    {
44      return txfCity;
45    }
46  
47    public String getTxfEmail()
48    {
49      return txfEmail;
50    }
51  
52    public String getTxfFirm()
53    {
54      return txfFirm;
55    }
56  
57    public String getTxfMessage()
58    {
59      return txfMessage;
60    }
61  
62    public String getTxfName()
63    {
64      return txfName;
65    }
66  
67    public String getTxfNr()
68    {
69      return txfNr;
70    }
71  
72    public String getTxfPhone()
73    {
74      return txfPhone;
75    }
76  
77    public String getTxfStreet()
78    {
79      return txfStreet;
80    }
81  
82    public String getTxfZipCode()
83    {
84      return txfZipCode;
85    }
86  
87    public void setTxfZipCode( String txfZipCode )
88    {
89      this.txfZipCode = txfZipCode;
90    }
91  
92    public void setTxfStreet( String txfStreet )
93    {
94      this.txfStreet = txfStreet;
95    }
96  
97    public void setTxfPhone( String txfPhone )
98    {
99      this.txfPhone = txfPhone;
100   }
101 
102   public void setTxfNr( String txfNr )
103   {
104     this.txfNr = txfNr;
105   }
106 
107   public void setTxfName( String txfName )
108   {
109     this.txfName = txfName;
110   }
111 
112   public void setTxfMessage( String txfMessage )
113   {
114     this.txfMessage = txfMessage;
115   }
116 
117   public void setTxfFirm( String txfFirm )
118   {
119     this.txfFirm = txfFirm;
120   }
121 
122   public void setTxfEmail( String txfEmail )
123   {
124     this.txfEmail = txfEmail;
125   }
126 
127   public void setTxfCity( String txfCity )
128   {
129     this.txfCity = txfCity;
130   }
131 
132   public void setCbxTo( String cbxTo )
133   {
134     this.cbxTo = cbxTo;
135   }
136 
137   public void setCbxSection( String cbxSection )
138   {
139     this.cbxSection = cbxSection;
140   }
141 
142   /**
143    * Diese Methode prüft die eingegeben Daten auf der JSP und fügt diese im Fehlerfall in die
144    * ActionErrors.
145    * @param actionMapping ActionMapping
146    * @param httpServletRequest HttpServletRequest
147    * @return ActionErrors
148    */
149   public ActionErrors validate( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
150   {
151     ActionErrors errors = new ActionErrors();
152 
153     if( txfName == null || txfName.equals( "" ) )
154     {
155       errors.add( "txfName", new ActionError( "validate.contact.nameRequired" ) );
156     }
157     else if( txfPhone.length() > 40 )
158     {
159       errors.add( "txfName", new ActionError( "validate.contact.nameLength" ) );
160     }
161     if( txfStreet == null || txfStreet.equals( "" ) )
162     {
163       errors.add( "txfStreet", new ActionError( "validate.contact.streetRequired" ) );
164     }
165     if( txfNr == null || txfNr.equals( "" ) )
166     {
167       errors.add( "txfNr", new ActionError( "validate.contact.nrRequired" ) );
168     }
169     if( txfZipCode == null || txfZipCode.equals( "" ) )
170     {
171       errors.add( "txfZipCode", new ActionError( "validate.contact.zipcodeRequired" ) );
172     }
173     else if( txfZipCode.length() > 5 )
174     {
175       errors.add( "txfZipCode", new ActionError( "validate.contact.zipcodeLength" ) );
176     }
177     if( txfCity == null || txfCity.equals( "" ) )
178     {
179       errors.add( "txfCity", new ActionError( "validate.contact.cityRequired" ) );
180     }
181     if( txfPhone.length() > 13 )
182     {
183       errors.add( "txfPhone", new ActionError( "validate.contact.phoneLength" ) );
184     }
185     if( txfEmail == null || txfEmail.equals( "" ) )
186     {
187       errors.add( "txfEmail", new ActionError( "validate.contact.emailRequired" ) );
188     }
189     else if( txfEmail.length() > 50 )
190     {
191       errors.add( "txfEmail", new ActionError( "validate.contact.emailLength" ) );
192     }
193     else if( txfEmail.indexOf( "@" ) == -1 )
194     {
195       errors.add( "txfEmail", new ActionError( "validate.contact.emailNotValid" ) );
196     }
197     return errors;
198   }
199 
200   /**
201    * Diese Methode setzt die Eingabedaten auf der JSP zurück in den Defaultwert
202    * @param actionMapping ActionMapping
203    * @param httpServletRequest HttpServletRequest
204    */
205   public void reset( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
206   {
207     this.cbxTo = null;
208     this.txfNr = "";
209     this.txfZipCode = "";
210     this.cbxSection = null;
211     this.txfEmail = "";
212     this.txfFirm = "";
213     this.txfMessage = "";
214     this.txfName = "";
215     this.txfCity = "";
216     this.txfStreet = "";
217     this.txfPhone = "";
218   }
219 }
220