KickJava   Java API By Example, From Geeks To Geeks.

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


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: IndexForm.java,v $
31  * Revision 1.2 2005/04/09 17:20:01 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:51:19 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.5 2004/11/12 18:19:16 colinmacleod
39  * Change action and form classes to extend MaskAction, MaskForm respectively.
40  *
41  * Revision 1.4 2004/07/13 19:48:12 colinmacleod
42  * Moved project to POJOs from EJBs.
43  * Applied PicoContainer to services layer (replacing session EJBs).
44  * Applied Hibernate to persistence layer (replacing entity EJBs).
45  *
46  * Revision 1.3 2004/03/21 21:16:39 colinmacleod
47  * Shortened name to ivata op.
48  *
49  * Revision 1.2 2004/02/01 22:07:33 colinmacleod
50  * Added full names to author tags
51  *
52  * Revision 1.1.1.1 2004/01/27 20:59:59 colinmacleod
53  * Moved ivata openportal to SourceForge..
54  *
55  * Revision 1.2 2003/10/15 14:11:33 colin
56  * fixing for XDoclet
57  *
58  * Revision 1.3 2003/06/03 13:12:44 peter
59  * fixed sortAscending reset value (false)
60  *
61  * Revision 1.2 2003/02/25 11:53:34 colin
62  * bugfixes and minor restructuring
63  *
64  * Revision 1.1 2003/02/24 19:09:24 colin
65  * moved to business
66  *
67  * Revision 1.4 2003/02/04 17:39:10 colin
68  * updated for new MaskAction interface
69  *
70  * Revision 1.3 2003/01/27 07:28:17 colin
71  * cosmetic changes
72  *
73  * Revision 1.10 2003/01/18 20:50:26 colin
74  * extended MaskAction and consolidated login checking
75  * (userName in session?)
76  * implemented javascript checking at login and help
77  * functionality
78  *
79  * Revision 1.2 2003/01/18 20:27:25 colin
80  * added new mail action superclass
81  * many fixes
82  *
83  * Revision 1.1 2002/11/17 20:05:08 colin
84  * first version of struts mail index
85  * -----------------------------------------------------------------------------
86  */

87 package com.ivata.groupware.business.mail.struts;
88
89 import javax.servlet.http.HttpServletRequest JavaDoc;
90 import javax.servlet.http.HttpSession JavaDoc;
91
92 import org.apache.struts.action.ActionMapping;
93
94 import com.ivata.groupware.business.mail.MailConstants;
95 import com.ivata.groupware.util.SettingDateFormatter;
96 import com.ivata.mask.Mask;
97 import com.ivata.mask.validation.ValidationErrors;
98 import com.ivata.mask.web.struts.DialogForm;
99
100
101 /**
102  * <p>This form is used to identify a message folder to list and the
103  * selected messages on that folder.</p>
104  *
105  * @since 2002-11-14
106  * @author Colin MacLeod
107  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
108  * @version $Revision: 1.2 $
109  *
110  */

111 public class IndexForm extends DialogForm {
112     /**
113      * <p>
114      * Date formatter, used in the JSP page.
115      * </p>
116      */

117     private SettingDateFormatter dateFormatter;
118
119     /**
120      * <p>If the current folder (see {@link #getFolderName getFolderName})
121      * is the trash folder, setting this <code>true</code> specifies the
122      * selected messages should be permanently deleted.</p>
123      */

124     private boolean deleteTrash;
125
126     /**
127      * <p>The name of the folder to locate messages which will be
128      * forwarded, replied to or used as a draft template.</p>
129      */

130     private String JavaDoc folderName;
131
132     /**
133      * <p>Determines whether or not the selected messages should be
134      * forwarded.</p>
135      */

136     private boolean forwardMessages;
137
138     /**
139      * <p>Automatically set by the <code>ListBodyTag</code>, this
140      * attribute sets the first row in the page.</p>
141      */

142     private int listRowFrom;
143
144     /**
145      * <p>Column of the display list which corresponds to
146      * <code>sortBy</code>,</p>
147      */

148     private int listSortColumn;
149
150     /**
151      * <p>Contains all message ids being displayed (to compare with the
152      * selected ones).</p>
153      */

154     private String JavaDoc[] messageIds;
155
156     /**
157      * <p>Indicates a folder name to which the currently selected messages
158      * should be moved to.</p>
159      */

160     private String JavaDoc moveTo;
161
162     /**
163      * <p>Determines whether or not previously selected ids should be
164      * retained.</p>
165      */

166     private boolean retainPrevious;
167
168     /**
169      * <p>Indicates all messages should be marked as selected. This
170      * selects all ids not shown on the current page - JavaScript selects
171      * the ones on the current page.</p>
172      */

173     private boolean selectAll;
174
175     /**
176      * <p>Contains all message ids the user selected.</p>
177      *
178      */

179     private String JavaDoc[] selectedMessageIds;
180
181     /**
182      * <p>If <code>true</code> then the messages are sorted in ascending
183      * order, otherwise (<code>false</code>) they are descending.</p>
184      */

185     private boolean sortAscending;
186
187     /**
188      * <p>The field to sort the returned list by. Set to one of the
189      * <code>SORT_...</code> constants in {@link
190      * com.ivata.groupware.business.mail.MailConstants MailConstants}.
191      */

192     private Integer JavaDoc sortBy;
193
194     /**
195      * <p>
196      * Defines the base class of all objects in the value object list.
197      * </p>
198      */

199     private Class JavaDoc baseClass;
200
201     /**
202      * <p>
203      * Mask containing all the field definitions for this list.
204      * </p>
205      */

206     private Mask mask;
207     /**
208      * <p>
209      * Construct an index form. This is created by the request processor.
210      * </p>
211      *
212      * @param maskParam Refer to {@link DialogForm#DialogForm}.
213      * @param baseClassParam Refer to {@link DialogForm#DialogForm}.
214      * @param dateFormatter used in the JSP page.
215      */

216     public IndexForm(final SettingDateFormatter dateFormatter) {
217         this.dateFormatter = dateFormatter;
218     }
219     /**
220      * <p>
221      * Return all form state to initial values.
222      * </p>
223      *
224      * @see com.ivata.mask.web.struts.MaskForm#clear()
225      */

226     protected void clear() {
227         deleteTrash = false;
228         folderName = null;
229         forwardMessages = false;
230         listRowFrom = 0;
231         listSortColumn = 4;
232         messageIds = null;
233         moveTo = null;
234         retainPrevious = false;
235         selectAll = false;
236         selectedMessageIds = null;
237         sortAscending = true;
238         sortBy = MailConstants.SORT_SENT;
239     }
240     /**
241      * <p>
242      * Date formatter, used in the JSP page.
243      * </p>
244      *
245      * @return used in the JSP page.
246      */

247     public final SettingDateFormatter getDateFormatter() {
248         return dateFormatter;
249     }
250
251     /**
252      * <p>If the current folder (see {@link #getFolderName getFolderName})
253      * is the trash folder, setting this <code>true</code> specifies the
254      * selected messages should be permanently deleted.</p>
255      *
256      * @return <code>true</code> if the selected messages will be deleted,
257      * otherwise <code>false</code>.
258      */

259     public final boolean getDeleteTrash() {
260         return deleteTrash;
261     }
262
263     /**
264      * <p>Get the name of the folder to locate messages which will be
265      * forwarded, replied to or used as a draft template.</p>
266      *
267      * @return the current name of the folder where the messages are
268      * located.
269      */

270     public final String JavaDoc getFolderName() {
271         return folderName;
272     }
273
274     /**
275      * <p>Find out if the selected messages should be forwarded as a new
276      * message.</p>
277      *
278      * @return <code>true</code> to specify that the selected messages
279      * should be forwarded as a new message, otherwise <code>false</code>.
280      */

281     public final boolean getForwardMessages() {
282         return forwardMessages;
283     }
284
285     /**
286      * <p>Automatically set by the <code>ListBodyTag</code>, this
287      * attribute sets the first row in the page.</p>
288      *
289      * @return the first row to be shown in the list control
290      */

291     public final int getListRowFrom() {
292         return listRowFrom;
293     }
294
295     /**
296      * <p>Column of the display list which corresponds to
297      * <code>sortBy</code>,</p>
298      *
299      * @return the current value of listSortColumn.
300      */

301     public final int getListSortColumn() {
302         return listSortColumn;
303     }
304
305     /**
306      * <p>Contains all message ids being displayed (to compare with the
307      * selected ones).</p>
308      *
309      * @return the current value of messageIds.
310      */

311     public final String JavaDoc[] getMessageIds() {
312         return messageIds;
313     }
314
315     /**
316      * <p>Get the folder name to which the currently selected messages
317      * should be moved.</p>
318      *
319      * @return the name of the folder to move the currently selected
320      * messages to, or <code>null</code> if no move action was selected..
321      */

322     public final String JavaDoc getMoveTo() {
323         return moveTo;
324     }
325
326     /**
327      * <p>Get whether or not previously selected ids should be
328      * retained.</p>
329      *
330      * @return <code>true</code> if previously selected message ids should
331      * be retained, otherwise <code>false</code>.
332      */

333     public final boolean getRetainPrevious() {
334         return retainPrevious;
335     }
336
337     /**
338      * <p>Get whether all messages should be marked as selected. This
339      * selects all ids not shown on the current page - JavaScript selects
340      * the ones on the current page.</p>
341      *
342      * @return <code>true</code> if all messages not shown should be
343      * selected, otherwise <code>false</code>
344      */

345     public final boolean getSelectAll() {
346         return selectAll;
347     }
348
349     /**
350      * <p>Contains all message ids the user selected.</p>
351      *
352      * @return current value of the message ids the user selected
353      */

354     public final String JavaDoc[] getSelectedMessageIds() {
355         return selectedMessageIds;
356     }
357
358     /**
359      * <p>Get whether the messages are sorted in ascending or descending
360      * order.</p>
361      *
362      * @return <code>true</code> if the messages are sorted in ascending
363      * order, otherwise (<code>false</code>) indicates they are
364      * descending.
365      */

366     public final boolean getSortAscending() {
367         return sortAscending;
368     }
369
370     /**
371      * <p>Get the field to sort the returned list by, one of the
372      * <code>SORT_...</code> constants in {@link
373      * com.ivata.groupware.business.mail.MailConstants MailConstants}.
374      *
375      * @return the current value indicating which column to sort by.
376      */

377     public final Integer JavaDoc getSortBy() {
378         return sortBy;
379     }
380
381     /**
382      * <p>Reset all bean properties to their default state. This method
383      * is called before the properties are repopulated by the controller
384      * servlet.<p>
385      *
386      * @param mapping The mapping used to select this instance
387      * @param request The servlet request we are processing.
388      */

389     public void reset(final ActionMapping mapping,
390             final HttpServletRequest JavaDoc request) {
391         this.folderName = null;
392         this.listRowFrom = 0;
393         this.messageIds = new String JavaDoc[0];
394         this.moveTo = null;
395         this.retainPrevious = false;
396         this.selectedMessageIds = new String JavaDoc[0];
397         this.selectAll = false;
398         this.sortAscending = false;
399         this.sortBy = MailConstants.SORT_SENT;
400         this.forwardMessages = false;
401         this.deleteTrash = false;
402     }
403
404     /**
405      * <p>
406      * Date formatter, used in the JSP page.
407      * </p>
408      *
409      * @param formatter used in the JSP page.
410      */

411     public final void setDateFormatter(final SettingDateFormatter formatter) {
412         dateFormatter = formatter;
413     }
414
415     /**
416      * <p>If the current folder (see {@link #getFolderName getFolderName})
417      * is the trash folder, setting this <code>true</code> specifies the
418      * selected messages should be permanently deleted.</p>
419      *
420      * @param deleteTrash <code>true</code> if the selected messages will
421      * be deleted, otherwise <code>false</code>.
422      */

423     public final void setDeleteTrash(final boolean deleteTrash) {
424         this.deleteTrash = deleteTrash;
425     }
426
427     /**
428      * <p>Set the name of the folder to locate messages which will be
429      * forwarded, replied to or used as a draft template.</p>
430      *
431      * @param folderName the current name of the folder where the messages
432      * are located.
433      */

434     public final void setFolderName(final String JavaDoc folderName) {
435         this.folderName = folderName;
436     }
437
438     /**
439      * <p>Specify that the selected messages should be forwarded as a new
440      * message.</p>
441      *
442      * @param forwardMessages <code>true</code> to specify that the
443      * selected messages should be forwarded as a new message, otherwise
444      * <code>false</code>.
445      */

446     public final void setForwardMessages(final boolean forwardMessages) {
447         this.forwardMessages = forwardMessages;
448     }
449
450     /**
451      * <p>Automatically set by the <code>ListBodyTag</code>, this
452      * attribute sets the first row in the page.</p>
453      *
454      * @param listRowFrom the first row to be displayed in the list
455      * control.
456      */

457     public final void setListRowFrom(final int listRowFrom) {
458         this.listRowFrom = listRowFrom;
459     }
460
461     /**
462      * <p>Column of the display list which corresponds to
463      * <code>sortBy</code>,</p>
464      *
465      * @param listSortColumn the new value of listSortColumn.
466      */

467     public final void setListSortColumn(final int listSortColumn) {
468         this.listSortColumn = listSortColumn;
469     }
470
471     /**
472      * <p>Contains all message ids being displayed (to compare with the
473      * selected ones).</p>
474      *
475      * @param messageIds the new value of messageIds.
476      */

477     public final void setMessageIds(final String JavaDoc[] messageIds) {
478         this.messageIds = messageIds;
479     }
480
481     /**
482      * <p>Set the folder name to which the currently selected messages
483      * should be moved.</p>
484      *
485      * @param folderName the name of the folder to move the currently
486      * selected messages to, or <code>null</code> if no move action was
487      * selected..
488      */

489     public final void setMoveTo(final String JavaDoc moveTo) {
490         this.moveTo = moveTo;
491     }
492
493     /**
494      * <p>Set whether or not previously selected ids should be
495      * retained.</p>
496      *
497      * @param retainPrevious set to <code>true</code> if previously
498      * selected message ids should be retained, otherwise
499      * <code>false</code>.
500      */

501     public final void setRetainPrevious(final boolean retainPrevious) {
502         this.retainPrevious = retainPrevious;
503     }
504
505     /**
506      * <p>Set whether all messages should be marked as selected. This
507      * selects all ids not shown on the current page - JavaScript selects
508      * the ones on the current page.</p>
509      *
510      * @param selectAll <code>true</code> if all messages not shown should
511      * be selected, otherwise <code>false</code>
512      */

513     public final void setSelectAll(final boolean selectAll) {
514         this.selectAll = selectAll;
515     }
516
517     /**
518      * <p>Contains all message ids the user selected.</p>
519      *
520      * @param selectedMessageIds the new value of the message ids the user
521      * selected
522      */

523     public final void setSelectedMessageIds(final String JavaDoc[] selectedMessageIds) {
524         this.selectedMessageIds = selectedMessageIds;
525     }
526
527     /**
528      * <p>Set whether the messages are sorted in ascending or descending
529      * order.</p>
530      *
531      * @param sortAscending set to <code>true</code> if the messages are
532      * sorted in ascending order, otherwise (<code>false</code>) indicates
533      * they are descending.
534      */

535     public final void setSortAscending(final boolean sortAscending) {
536         this.sortAscending = sortAscending;
537     }
538
539     /**
540      * <p>Set the field to sort the returned list by, one of the
541      * <code>SORT_...</code> constants in {@link
542      * com.ivata.groupware.business.mail.MailConstants MailConstants}.
543      *
544      * @param sortBy the new value indicating which column to sort by.
545      */

546     public final void setSortBy(final Integer JavaDoc sortBy) {
547         this.sortBy = sortBy;
548     }
549     /**
550      * TODO
551      *
552      * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
553      */

554     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
555             final HttpSession JavaDoc session) {
556         // TODO Auto-generated method stub
557
return null;
558     }
559     /**
560      * <p>
561      * Defines the base class of all objects in the value object list.
562      * </p>
563      *
564      * @return base class of all objects in the value object list.
565      */

566     public final Class JavaDoc getBaseClass() {
567         return baseClass;
568     }
569     /**
570      * <p>
571      * Mask containing all the field definitions for this list.
572      * </p>
573      *
574      * @return mask containing all the field definitions for this list.
575      */

576     public final Mask getMask() {
577         return mask;
578     }
579
580 }
581
Popular Tags