KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > mail > struts > DisplayForm


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: DisplayForm.java,v $
31  * Revision 1.3 2005/04/10 18:47:43 colinmacleod
32  * Changed i tag to em and b tag to strong.
33  *
34  * Revision 1.2 2005/04/09 17:20:01 colinmacleod
35  * Changed copyright text to GPL v2 explicitly.
36  *
37  * Revision 1.1.1.1 2005/03/10 17:51:17 colinmacleod
38  * Restructured ivata op around Hibernate/PicoContainer.
39  * Renamed ivata groupware.
40  *
41  * Revision 1.6 2004/11/12 18:19:16 colinmacleod
42  * Change action and form classes to extend MaskAction, MaskForm respectively.
43  *
44  * Revision 1.5 2004/09/30 15:09:34 colinmacleod
45  * Bug fixes
46  *
47  * Revision 1.4 2004/07/13 19:48:12 colinmacleod
48  * Moved project to POJOs from EJBs.
49  * Applied PicoContainer to services layer (replacing session EJBs).
50  * Applied Hibernate to persistence layer (replacing entity EJBs).
51  *
52  * Revision 1.3 2004/03/21 21:16:39 colinmacleod
53  * Shortened name to ivata op.
54  *
55  * Revision 1.2 2004/02/01 22:07:32 colinmacleod
56  * Added full names to author tags
57  *
58  * Revision 1.1.1.1 2004/01/27 20:59:59 colinmacleod
59  * Moved ivata openportal to SourceForge..
60  *
61  * Revision 1.2 2003/10/15 14:11:33 colin
62  * fixing for XDoclet
63  *
64  * Revision 1.2 2003/02/25 11:53:33 colin
65  * bugfixes and minor restructuring
66  *
67  * Revision 1.1 2003/02/24 19:09:24 colin
68  * moved to business
69  *
70  * Revision 1.2 2003/02/04 17:39:10 colin
71  * updated for new MaskAction interface
72  *
73  * Revision 1.1 2003/01/18 20:24:26 colin
74  * changed design from thread to display based
75  *
76  * Revision 1.1 2002/11/17 20:05:47 colin
77  * first version of struts threading
78  * supports forward/reply but HTML not yet supported
79  * -----------------------------------------------------------------------------
80  */

81 package com.ivata.groupware.business.mail.struts;
82
83 import javax.servlet.http.HttpServletRequest JavaDoc;
84 import javax.servlet.http.HttpSession JavaDoc;
85
86 import com.ivata.groupware.business.mail.MailConstants;
87 import com.ivata.groupware.business.mail.message.MessageDO;
88 import com.ivata.mask.Mask;
89 import com.ivata.mask.validation.ValidationErrors;
90 import com.ivata.mask.web.struts.DialogForm;
91
92
93 /**
94  * <p>This form is used to identify an existing message to display, or
95  * from which we want to create a new
96  * one. Depending on the value of the <code>thread</code> attribute,
97  * the newmessage can:<br/>
98  * <ul>
99  * <li>Reply to the main recipient of the previous message</li>
100  * <li>Reply to all visible (i.e. not <em>BCC</em>) recipients of the
101  * previous message</li>
102  * <li>Forward existing message, or messages</li>
103  * <li>Edit an existing message as a temple for a new message.</li>
104  * </ul></p>
105  *
106  * @since 2002-11-11
107  * @author Colin MacLeod
108  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
109  * @version $Revision: 1.3 $
110  */

111 public class DisplayForm extends DialogForm {
112
113     /**
114      * <p>Indicates this message should be moved to the trash folder.
115      * After the message has been moved, the next message in the folder
116      * will
117      * be displayed or (if there are no more messages) the folder
118      * index.</p>
119      */

120     private boolean delete;
121
122     /**
123      * <p>Indicates this message should be permanently erased from the
124      * trash folder. After the message has been deleted, the next message
125      * in
126      * the trash folder will be displayed or (if there are no more
127      * messages)
128      * the trash folder index.</p>
129      */

130     private boolean deleteTrash;
131
132     /**
133      * <p>Used to store the result from a submit button, if this is
134      * non-<code>null</code>, then the next message in the current folder
135      * will be displayed.</p>
136      */

137     private String JavaDoc displayNext;
138
139     /**
140      * <p>Used to store the result from a submit button, if this is
141      * non-<code>null</code>, then the previous message in the current
142      * folder will be displayed.</p>
143      */

144     private String JavaDoc displayPrevious;
145
146     /**
147      * <p>Set by the action to indicate whether there are more messages in
148      * the current folder after this one.</p>
149      */

150     private boolean hasNext;
151
152     /**
153      * <p>Set by the action to indicate whether there are more messages in
154      * the current folder before this one.</p>
155      */

156     private boolean hasPrevious;
157
158     /**
159      * <p>Stores the data of the currently displayed message.</p>
160      */

161     private MessageDO message = new MessageDO();
162     private boolean sortAscending;
163     private Integer JavaDoc sortBy;
164     /**
165      * <p>Set to one of the constants in {@link
166      * com.ivata.groupware.business.mail.MailConstants MailConstants}, this
167      * indicator
168      * tells us that the message is a:<br/>
169      * <ul>
170      * <li>reply to all recipients of a previous message</li>
171      * <li>reply to one recipient of a previous message</li>
172      * <li>previous message(s) forwarded to new recipients</li>
173      * <li>an existing (draft) message being altered for resending</li>
174      * </ul></p>
175      */

176     private Integer JavaDoc thread;
177
178     /**
179      * <p>
180      * Defines the base class of all objects in the value object list.
181      * </p>
182      */

183     private Class JavaDoc baseClass;
184
185     /**
186      * <p>
187      * Mask containing all the field definitions for this list.
188      * </p>
189      */

190     private Mask mask;
191     /**
192      * <p>
193      * Return all form state to initial values.
194      * </p>
195      *
196      * @see com.ivata.mask.web.struts.MaskForm#clear()
197      */

198     protected void clear() {
199         delete = false;
200         deleteTrash = false;
201         displayNext = null;
202         displayPrevious = null;
203         hasNext = false;
204         hasPrevious = false;
205         message = new MessageDO();
206         sortAscending = true;
207         sortBy = MailConstants.SORT_SENT;
208         thread = null;
209     }
210
211     /**
212      * <p>Indicates this message should be moved to the trash folder.
213      * After the message has been moved, the next message in the folder
214      * will
215      * be displayed or (if there are no more messages) the folder
216      * index.</p>
217      *
218      * @return the current value of delete.
219      */

220     public final boolean getDelete() {
221         return delete;
222     }
223
224     /**
225      * <p>Indicates this message should be permanently erased from the
226      * trash folder. After the message has been deleted, the next message
227      * in
228      * the trash folder will be displayed or (if there are no more
229      * messages)
230      * the trash folder index.</p>
231      *
232      * @return the current value of deleteTrash.
233      */

234     public final boolean getDeleteTrash() {
235         return deleteTrash;
236     }
237
238     /**
239      * <p>Used to store the result from a submit button, if this is
240      * non-<code>null</code>, then the next message in the current folder
241      * will be displayed.</p>
242      *
243      * @return the current value of displayNext.
244      */

245     public final String JavaDoc getDisplayNext() {
246         return displayNext;
247     }
248
249     /**
250      * <p>Used to store the result from a submit button, if this is
251      * non-<code>null</code>, then the previous message in the current
252      * folder will be displayed.</p>
253      *
254      * @return the current value of displayPrevious.
255      */

256     public final String JavaDoc getDisplayPrevious() {
257         return displayPrevious;
258     }
259
260     /**
261      * <p>Get the name of the folder to locate messages which will be
262      * forwarded, replied to or used as a draft template.</p>
263      *
264      * @return the current name of the folder where the messages are
265      * located.
266      */

267     public final String JavaDoc getFolderName() {
268         return message.getFolderName();
269     }
270
271     /**
272      * <p>Set by the action to indicate whether there are more messages in
273      * the current folder after this one.</p>
274      *
275      * @return the current value of hasNext.
276      */

277     public final boolean getHasNext() {
278         return hasNext;
279     }
280
281     /**
282      * <p>Set by the action to indicate whether there are more messages in
283      * the current folder before this one.</p>
284      *
285      * @return the current value of hasPrevious.
286      */

287     public final boolean getHasPrevious() {
288         return hasPrevious;
289     }
290
291     /**
292      * <p>Get the unique identifier of the message to be displayed.</p>
293      *
294      * @return the current value of the message identifier.
295      */

296     public final String JavaDoc getId() {
297         return message.getMessageID();
298     }
299
300     /**
301      * <p>Get the message data object which contains the main
302      * information in this form.</p>
303      *
304      * @return message data object which contains all of the
305      * information in this form.
306      */

307     public MessageDO getMessage() {
308         return message;
309     }
310
311     /**
312      * <p>Get whether the messages are sorted in ascending or descending
313      * order.</p>
314      *
315      * @return <code>true</code> if the messages are sorted in ascending
316      * order, otherwise (<code>false</code>) indicates they are
317      * descending.
318      */

319     public final boolean getSortAscending() {
320         return sortAscending;
321     }
322
323     /**
324      * <p>Get the field to sort the returned list by, one of the
325      * <code>SORT_...</code> constants in {@link
326      * com.ivata.groupware.business.mail.MailConstants MailConstants}.
327      *
328      * @return the current value indicating which column to sort by.
329      */

330     public final Integer JavaDoc getSortBy() {
331         return sortBy;
332     }
333
334     /**
335      * <p>Get the setting of <code>thread</code>. This indicator tells us
336      * that the message is a:<br/>
337      * <ul>
338      * <li>reply to all recipients of a previous message</li>
339      * <li>reply to one recipient of a previous message</li>
340      * <li>previous message(s) forwarded to new recipients</li>
341      * <li>an existing (draft) message being altered for resending</li>
342      * </ul></p>
343      *
344      * @return the current value of thread, one of the constants in {@link
345      * com.ivata.groupware.business.mail.MailConstants MailConstants},
346      */

347     public final Integer JavaDoc getThread() {
348         return thread;
349     }
350
351     /**
352      * <p>Indicates this message should be moved to the trash folder.
353      * After the message has been moved, the next message in the folder
354      * will
355      * be displayed or (if there are no more messages) the folder
356      * index.</p>
357      *
358      * @param delete the new value of delete.
359      */

360     public final void setDelete(final boolean delete) {
361         this.delete = delete;
362     }
363
364     /**
365      * <p>Indicates this message should be permanently erased from the
366      * trash folder. After the message has been deleted, the next message
367      * in
368      * the trash folder will be displayed or (if there are no more
369      * messages)
370      * the trash folder index.</p>
371      *
372      * @param deleteTrash the new value of deleteTrash.
373      */

374     public final void setDeleteTrash(final boolean deleteTrash) {
375         this.deleteTrash = deleteTrash;
376     }
377
378     /**
379      * <p>Used to store the result from a submit button, if this is
380      * non-<code>null</code>, then the next message in the current folder
381      * will be displayed.</p>
382      *
383      * @param displayNext the new value of displayNext.
384      */

385     public final void setDisplayNext(final String JavaDoc displayNext) {
386         this.displayNext = displayNext;
387     }
388
389     /**
390      * <p>Used to store the result from a submit button, if this is
391      * non-<code>null</code>, then the previous message in the current
392      * folder will be displayed.</p>
393      *
394      * @param displayPrevious the new value of displayPrevious.
395      */

396     public final void setDisplayPrevious(final String JavaDoc displayPrevious) {
397         this.displayPrevious = displayPrevious;
398     }
399
400     /**
401      * <p>Set the name of the folder to locate messages which will be
402      * forwarded, replied to or used as a draft template.</p>
403      *
404      * @param folderName the current name of the folder where the messages
405      * are located.
406      */

407     public final void setFolderName(final String JavaDoc folderName) {
408         message.setFolderName(folderName);
409     }
410
411     /**
412      * <p>Set by the action to indicate whether there are more messages in
413      * the current folder after this one.</p>
414      *
415      * @param hasNext the new value of hasNext.
416      */

417     public final void setHasNext(final boolean hasNext) {
418         this.hasNext = hasNext;
419     }
420
421     /**
422      * <p>Set by the action to indicate whether there are more messages in
423      * the current folder before this one.</p>
424      *
425      * @param hasPrevious the new value of hasPrevious.
426      */

427     public final void setHasPrevious(final boolean hasPrevious) {
428         this.hasPrevious = hasPrevious;
429     }
430
431     /**
432      * <p>Set the unique identifier of the message to be displayed.</p>
433      *
434      * @param messageId new value of the message identifier.
435      */

436     public final void setId(final String JavaDoc messageId) {
437         this.message.setMessageID(messageId);
438     }
439
440     /**
441      * <p>Set the message data object which contains the main
442      * information in this form. The contents of the form are entirely
443      * replaced by the contents of the messge provided.</p>
444      *
445      * @param message message data object which contains all of
446      * the new information in this form.
447      */

448     public final void setMessage(final MessageDO message) {
449         this.message = message;
450     }
451
452     /**
453      * <p>Set whether the messages are sorted in ascending or descending
454      * order.</p>
455      *
456      * @param sortAscending set to <code>true</code> if the messages are
457      * sorted in ascending order, otherwise (<code>false</code>) indicates
458      * they are descending.
459      */

460     public final void setSortAscending(final boolean sortAscending) {
461         this.sortAscending = sortAscending;
462     }
463
464     /**
465      * <p>Set the field to sort the returned list by, one of the
466      * <code>SORT_...</code> constants in {@link
467      * com.ivata.groupware.business.mail.MailConstants MailConstants}.
468      *
469      * @param sortBy the new value indicating which column to sort by.
470      */

471     public final void setSortBy(final Integer JavaDoc sortBy) {
472         this.sortBy = sortBy;
473     }
474
475     /**
476      * <p>Set the setting of <code>thread</code>. This indicator tells us
477      * that the message is a:<br/>
478      * <ul>
479      * <li>reply to all recipients of a previous message</li>
480      * <li>reply to one recipient of a previous message</li>
481      * <li>previous message(s) forwarded to new recipients</li>
482      * <li>an existing (draft) message being altered for resending</li>
483      * </ul></p>
484      *
485      * @param thread the new value of thread, one of the constants in
486      * {@link com.ivata.groupware.business.mail.MailConstants MailConstants},
487      */

488     public final void setThread(final Integer JavaDoc thread) {
489         this.thread = thread;
490     }
491     /**
492      * TODO
493      *
494      * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
495      */

496     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
497             final HttpSession JavaDoc session) {
498         // TODO Auto-generated method stub
499
return null;
500     }
501     /**
502      * <p>
503      * Defines the base class of all objects in the value object list.
504      * </p>
505      *
506      * @return base class of all objects in the value object list.
507      */

508     public final Class JavaDoc getBaseClass() {
509         return baseClass;
510     }
511     /**
512      * <p>
513      * Mask containing all the field definitions for this list.
514      * </p>
515      *
516      * @return mask containing all the field definitions for this list.
517      */

518     public final Mask getMask() {
519         return mask;
520     }
521 }
522
Popular Tags