KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > forms > MessageForm


1 /*
2  * $$Id: MessageForm.java,v 1.3 2005/06/07 12:32:17 bel70 Exp $$
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * The contents of this file are subject to the Mozilla Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License
8  * at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * The Original Code is JGossip forum code.
16  *
17  * The Initial Developer of the Original Code is the JResearch, Org.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Dmitry Belov <bel@jresearch.org>
23  *
24  * ***** END LICENSE BLOCK ***** */

25 /*
26  * Created on Sep 20, 2003
27  *
28  */

29 package org.jresearch.gossip.forms;
30
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32
33 import org.apache.struts.action.ActionError;
34 import org.apache.struts.action.ActionErrors;
35 import org.apache.struts.action.ActionMapping;
36 import org.apache.struts.validator.ValidatorForm;
37 import org.jresearch.gossip.util.HtmlCodec;
38 import org.jresearch.gossip.util.MessageProcessor;
39
40 /**
41  * DOCUMENT ME!
42  *
43  * @author Bel
44  */

45 public class MessageForm extends ValidatorForm {
46
47     private String JavaDoc fid;
48
49     private String JavaDoc tid;
50
51     private String JavaDoc block = "0";
52
53     private String JavaDoc mid;
54
55     private String JavaDoc title;
56
57     private String JavaDoc text;
58
59     private String JavaDoc subscribe;
60
61     private String JavaDoc announce;
62
63     private String JavaDoc email;
64
65     private String JavaDoc name;
66
67     /**
68      * Reset all properties to their default values.
69      *
70      * @param mapping
71      * The mapping used to select this instance
72      * @param request
73      * The servlet request we are processing
74      */

75     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
76         this.fid = null;
77         this.tid = null;
78         this.block = "0";
79         this.mid = null;
80         this.title = null;
81         this.text = null;
82         this.subscribe = null;
83         this.announce = null;
84         this.email = null;
85         this.name = null;
86     }
87
88     /**
89      * Validate the properties that have been set from this HTTP request, and
90      * return an <code>ActionErrors</code> object that encapsulates any
91      * validation errors that have been found. If no errors are found, return
92      * <code>null</code> or an <code>ActionErrors</code> object with no
93      * recorded error messages.
94      *
95      * @param mapping
96      * The mapping used to select this instance
97      * @param request
98      * The servlet request we are processing
99      *
100      * @return DOCUMENT ME!
101      */

102     public ActionErrors validate(ActionMapping mapping,
103             HttpServletRequest JavaDoc request) {
104         // Perform validator framework validations
105
ActionErrors errors = super.validate(mapping, request);
106
107         if ((this.tid == null || this.tid.equals(""))
108                 && (this.title == null || this.title.equals(""))) {
109             errors.add("title", new ActionError("errors.ERR18"));
110         }
111
112         return errors;
113     }
114
115     /**
116      * DOCUMENT ME!
117      *
118      * @return
119      */

120     public String JavaDoc getFid() {
121         return fid;
122     }
123
124     /**
125      * DOCUMENT ME!
126      *
127      * @return
128      */

129     public String JavaDoc getTid() {
130         return tid;
131     }
132
133     /**
134      * DOCUMENT ME!
135      *
136      * @param i
137      */

138     public void setFid(String JavaDoc i) {
139         fid = i;
140     }
141
142     /**
143      * DOCUMENT ME!
144      *
145      * @param i
146      */

147     public void setTid(String JavaDoc i) {
148         tid = i;
149     }
150
151     /**
152      * DOCUMENT ME!
153      *
154      * @return
155      */

156     public String JavaDoc getBlock() {
157         return block;
158     }
159
160     /**
161      * DOCUMENT ME!
162      *
163      * @param i
164      */

165     public void setBlock(String JavaDoc i) {
166         block = i;
167     }
168
169     /**
170      * DOCUMENT ME!
171      *
172      * @return
173      */

174     public String JavaDoc getMid() {
175         return mid;
176     }
177
178     /**
179      * DOCUMENT ME!
180      *
181      * @param string
182      */

183     public void setMid(String JavaDoc string) {
184         mid = string;
185     }
186
187     /**
188      * DOCUMENT ME!
189      *
190      * @return
191      */

192     public String JavaDoc getSubscribe() {
193         return subscribe;
194     }
195
196     /**
197      * DOCUMENT ME!
198      *
199      * @return
200      */

201     public String JavaDoc getText() {
202         return text;
203     }
204
205     public String JavaDoc getCleanText() {
206         return MessageProcessor.getInstance().cleanup(this.text).trim();
207     }
208
209     /**
210      * DOCUMENT ME!
211      *
212      * @return
213      */

214     public String JavaDoc getTitle() {
215         return title;
216     }
217
218     /**
219      * DOCUMENT ME!
220      *
221      * @param string
222      */

223     public void setSubscribe(String JavaDoc string) {
224         subscribe = string;
225     }
226
227     /**
228      * DOCUMENT ME!
229      *
230      * @param string
231      */

232     public void setText(String JavaDoc string) {
233         text = HtmlCodec.trim(string);
234     }
235
236     /**
237      * DOCUMENT ME!
238      *
239      * @param string
240      */

241     public void setTitle(String JavaDoc string) {
242         title = HtmlCodec.trim(string);
243     }
244
245     /**
246      * DOCUMENT ME!
247      *
248      * @return
249      */

250     public String JavaDoc getEmail() {
251         return email;
252     }
253
254     /**
255      * DOCUMENT ME!
256      *
257      * @param string
258      */

259     public void setEmail(String JavaDoc string) {
260         email = string;
261     }
262
263     /**
264      * DOCUMENT ME!
265      *
266      * @return
267      */

268     public String JavaDoc getName() {
269         return name;
270     }
271
272     /**
273      * DOCUMENT ME!
274      *
275      * @param string
276      */

277     public void setName(String JavaDoc string) {
278         name = string;
279     }
280
281     /**
282      * DOCUMENT ME!
283      *
284      * @return
285      */

286     public String JavaDoc getAnnounce() {
287         return announce;
288     }
289
290     /**
291      * DOCUMENT ME!
292      *
293      * @param string
294      */

295     public void setAnnounce(String JavaDoc string) {
296         announce = string;
297     }
298 }
Popular Tags