1 package ch.ige.edossier.web.struts;
2
3 import javax.servlet.http.HttpServletRequest;
4 import org.apache.struts.action.*;
5 import org.apache.struts.upload.FormFile;
6
7
18 public class AnswerForm extends ActionForm
19 {
20 private int answerId = 0;
21 private int interceptionId = 0;
22 private String name = null;
23 private String email = null;
24 private String telNr = null;
25 private String text = null; private String standardtext = ""; private FormFile uploadData = null;
28
29
33 public int getAnswerId()
34 {
35 return answerId;
36 }
37
38 public void setAnswerId( int answerId )
39 {
40 this.answerId = answerId;
41 }
42
43 public int getInterceptionId()
44 {
45 return interceptionId;
46 }
47
48 public void setInterceptionId( int interceptionId )
49 {
50 this.interceptionId = interceptionId;
51 }
52
53 public String getStandardtext()
54 {
55 return standardtext;
56 }
57
58 public void setStandardtext( String standardtext )
59 {
60 this.standardtext = standardtext;
61 }
62
63 public String getName()
64 {
65 return name;
66 }
67
68 public void setName( String name )
69 {
70 this.name = name;
71 }
72
73 public String getEmail()
74 {
75 return email;
76 }
77
78 public void setEmail( String email )
79 {
80 this.email = email;
81 }
82
83 public String getTelNr()
84 {
85 return telNr;
86 }
87
88 public void setTelNr( String telNr )
89 {
90 this.telNr = telNr;
91 }
92
93 public String getText()
94 {
95 return text;
96 }
97
98 public void setText( String text )
99 {
100 this.text = text;
101 }
102
103 public FormFile getUploadData()
104 {
105 return uploadData;
106 }
107
108 public void setUploadData( FormFile uploadData )
109 {
110 this.uploadData = uploadData;
111 }
112
113
121 public ActionErrors validate( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
122 {
123 ActionErrors errors = new ActionErrors();
124
125 if( name == null || name.trim().equals( "" ) )
126 {
127 errors.add( "name", new ActionError( "validate.answer.nameRequired" ) );
128 }
129 else if( name.length() > 40 )
130 {
131 errors.add( "name", new ActionError( "validate.answer.nameLength" ) );
132 }
133
134 if( email == null || email.trim().equals( "" ) )
135 {
136 errors.add( "email", new ActionError( "validate.answer.emailRequired" ) );
137 }
138 else if( email.length() > 50 )
139 {
140 errors.add( "email", new ActionError( "validate.answer.emailLength" ) );
141 }
142 else if( email.indexOf( "@" ) == -1 )
143 {
144 errors.add( "email", new ActionError( "validate.answer.emailNotValid" ) );
145 }
146
147 if( telNr == null || telNr.trim().equals( "" ) )
148 {
149 errors.add( "telNr", new ActionError( "validate.answer.telNrRequired" ) );
150 }
151 else if( telNr.length() > 23 )
152 {
153 errors.add( "telNr", new ActionError( "validate.answer.telNrLength" ) );
154 }
155
156
157 if( ( this.text == null || this.text.trim().equals( "" ) ) &&
158 ( this.standardtext == null || this.standardtext.trim().equals( "" ) ) )
159 {
160 errors.add( "text", new ActionError( "validate.answer.textRequired" ) );
161 }
162
163 return errors;
164 }
165
166
171 public void reset( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
172 {
173 this.standardtext = "";
174 this.name = null;
175 this.email = null;
176 this.telNr = null;
177 this.text = null;
178 }
179 }
180