KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > library > struts > ItemForm


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: ItemForm.java,v $
31  * Revision 1.3 2005/04/10 20:31:58 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:46 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:52:01 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.6 2004/12/23 21:01:29 colinmacleod
45  * Updated Struts to v1.2.4.
46  * Changed base classes to use ivata masks.
47  *
48  * Revision 1.5 2004/11/12 18:19:15 colinmacleod
49  * Change action and form classes to extend MaskAction, MaskForm respectively.
50  *
51  * Revision 1.4 2004/07/13 19:47:29 colinmacleod
52  * Moved project to POJOs from EJBs.
53  * Applied PicoContainer to services layer (replacing session EJBs).
54  * Applied Hibernate to persistence layer (replacing entity EJBs).
55  *
56  * Revision 1.3 2004/03/21 21:16:29 colinmacleod
57  * Shortened name to ivata op.
58  *
59  * Revision 1.2 2004/02/01 22:07:31 colinmacleod
60  * Added full names to author tags
61  *
62  * Revision 1.1.1.1 2004/01/27 20:58:41 colinmacleod
63  * Moved ivata openportal to SourceForge..
64  *
65  * Revision 1.3 2003/11/13 16:11:08 jano
66  * commitng everything to CVS
67  * can deploy and application is ruuning, can login into
68  *
69  * Revision 1.2 2003/10/15 14:16:53 colin
70  * fixing for XDoclet
71  *
72  * Revision 1.11 2003/07/11 15:08:12 peter
73  * version control comment added
74  * Revision 1.10 2003/06/20 13:22:15 jano
75  * we want deleteFile button in list of attached files
76  *
77  * Revision 1.9 2003/05/20 08:29:40 jano
78  * maintaing attaching files to libray item
79  *
80  * Revision 1.8 2003/05/13 15:41:00 jano
81  * new methods in DriveBean
82  *
83  * Revision 1.7 2003/05/07 14:01:59 jano
84  * we want findFilesByPath
85  *
86  * Revision 1.6 2003/03/21 15:40:36 peter
87  * fixed delete - super.reset was not called
88  *
89  * Revision 1.5 2003/03/12 14:14:48 jano
90  * renaming newHeading -> newPoint
91  * fixing problem arround that
92  *
93  * Revision 1.4 2003/03/03 20:55:19 colin
94  * skipped validation if clear button pressed
95  *
96  * Revision 1.3 2003/02/28 09:37:13 jano
97  * RuntimeException(e) -> IntrnetRuntimeException
98  *
99  * Revision 1.2 2003/02/28 07:30:22 colin
100  * implemented editing/displaying of faqs & notes
101  *
102  * Revision 1.1 2003/02/24 19:09:24 colin
103  * moved to business
104  * -----------------------------------------------------------------------------
105  */

106 package com.ivata.groupware.business.library.struts;
107
108 import java.util.HashMap JavaDoc;
109 import java.util.List JavaDoc;
110 import java.util.Map JavaDoc;
111 import java.util.Set JavaDoc;
112 import java.util.Vector JavaDoc;
113
114 import javax.servlet.http.HttpServletRequest JavaDoc;
115 import javax.servlet.http.HttpSession JavaDoc;
116
117 import org.apache.struts.action.ActionMapping;
118
119 import com.ivata.groupware.admin.security.server.SecuritySession;
120 import com.ivata.groupware.business.library.Library;
121 import com.ivata.groupware.business.library.item.LibraryItemDO;
122 import com.ivata.mask.Mask;
123 import com.ivata.mask.MaskFactory;
124 import com.ivata.mask.util.StringHandling;
125 import com.ivata.mask.validation.ValidationError;
126 import com.ivata.mask.validation.ValidationErrors;
127
128
129 /**
130  * <p>This form is used both to display and to submit a library
131  * item</p>
132  *
133  * @since 2003-02-19
134  * @author Colin MacLeod
135  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
136  * @version $Revision: 1.3 $
137  */

138 public class ItemForm extends LibraryForm {
139     /**
140      * <p>Version control comment</p>
141      */

142     private String JavaDoc comment;
143
144     /**
145      * <p>Button for deleting attached files to item.</p>
146      */

147     private String JavaDoc deleteFileButton;
148
149     /**
150      * <p>Page to include with extra fields for this document type, on
151      * display.</p>
152      */

153     private String JavaDoc displayIncludePage;
154     /**
155      * <p>If in display mode, indicates the page number to currently
156      * show.</p>
157      */

158     private int displayPage;
159
160     /**
161      * <p>Defines list of DriveFileDO with are attached with this
162      * item (if any).</p>
163      */

164     private List JavaDoc fileList = new Vector JavaDoc();
165
166     /**
167      * <p>Contains all of the information about the current library
168      * item</p>
169      */

170     private LibraryItemDO item;
171
172     private Library library;
173
174     /**
175      * <p>Defines the page to link to. This varies depending on
176      * whether the item is being submitted or displayed.</p>
177      */

178     private String JavaDoc linkPage;
179
180     /**
181      * <p>If non-<code>null</code>, indicates a new page should be
182      * addes for DOCUMENT, new heading for MEETING, new FAQ category for
183      * FAQs.</p>
184      */

185     private String JavaDoc newPage;
186
187     /**
188      * <p>TRICK
189      *
190      * storing index of button which was click in submiting page of
191      * Meeting or Faq.
192      * index is store in first field of array.
193      *
194      * for MEETING it's creating new AgendaPoin in heading with that
195      * index.
196      * for FAQ it's creating new Question in faq category with that
197      * index.</p>
198      */

199     private String JavaDoc[] newPoint;
200
201     /**
202      * <p>Link to link the next page to, or the empty string if there is
203      * no next
204      * page.</p>
205      */

206     private String JavaDoc nextPageLink;
207
208     /**
209      * <p>Contains the links with appear to the top right of displayed
210      * items.</p>
211      */

212     private String JavaDoc pageLinks;
213
214     /**
215      * <p>Link to link the previous page to, or the empty string if there
216      * is no
217      * previous page.</p>
218      */

219     private String JavaDoc previousPageLink;
220
221     /**
222      * <p>All Ids of selected files by user from list of attached files.
223      * We need maped propertties.</p>
224      */

225     private Map JavaDoc selectedAttachedFilesIds;
226
227     /**
228      * <p>All Ids of selected files by user from list of new files.</p>
229      */

230     private String JavaDoc[] selectedNewFilesIds;
231
232     /**
233      * <p>Page to include with extra fields for this document type, on
234      * submission</p>
235      */

236     private String JavaDoc submitIncludePage;
237
238     /**
239      * <p>Key to the localized text for the summary field (submit
240      * mode).</p>
241      */

242     private String JavaDoc summaryPromptKey;
243
244     /**
245      * <p>Specifies the theme name for the document summary section.</p>
246      */

247     private String JavaDoc summaryThemeName;
248
249     /**
250      * <p>Key to the localized text for the summary window (submit
251      * mode).</p>
252      */

253     private String JavaDoc summaryTitleKey;
254
255     /**
256      * <p>Specifies the theme name for the body of the document.</p>
257      */

258     private String JavaDoc themeName;
259
260     /**
261      * <p>In submit mode, stores all of the captions of the topics we are
262      * allowed to see.</p>
263      */

264     private Map JavaDoc topicCaptions;
265
266     /**
267      * <p>In submit mode, stores all of the unique identifiers of the
268      * topics we are allowed to see.</p>
269      */

270     private Set JavaDoc topicIds;
271
272     /**
273      * <p>In submit mode, stores all of the image filenames of the topics
274      * we are allowed to see.</p>
275      */

276     private Map JavaDoc topicImages;
277
278     /**
279      * <p>Defines list of FileDO with are goint to attch with this
280      * item.</p>
281      */

282     private List JavaDoc uploadingFileList;
283     private Mask mask;
284     /**
285      *
286      * @param library
287      * @param maskParam
288      * Refer to {@link #getMask}.
289      * @param baseClassParam
290      * Refer to {@link #getBaseClass}.
291      */

292     public ItemForm(final Library library, final MaskFactory maskFactory) {
293         this.library = library;
294         mask = maskFactory.getMask(LibraryItemDO.class);
295     }
296
297     /**
298      * TODO
299      *
300      * @see com.ivata.mask.web.struts.MaskForm#clear()
301      */

302     protected void clear() {
303         comment = null;
304         deleteFileButton = null;
305         displayIncludePage = null;
306         displayPage = -1;
307         // TODO
308
fileList = new Vector JavaDoc();
309         item = null;
310         linkPage = null;
311         newPage = null;
312         newPoint = new String JavaDoc[]{ };
313         nextPageLink = "";
314         pageLinks = "";
315         previousPageLink = "";
316         selectedAttachedFilesIds = null;
317         selectedNewFilesIds = null;
318         submitIncludePage = null;
319         summaryPromptKey = null;
320         summaryThemeName = null;
321         summaryTitleKey = null;
322         themeName = null;
323         topicCaptions = null;
324         topicIds = null;
325         topicImages = null;
326         uploadingFileList = null;
327     }
328
329     /**
330        <p>Version control comment</p>
331        @return the comment
332
333      */

334     public final String JavaDoc getComment() {
335         return comment;
336     }
337
338     /**
339      * <p>Button for deleting attached files to item.</p>
340      *
341      * @return the current value of deleteFileButton.
342      */

343     public final String JavaDoc getDeleteFileButton() {
344         return this.deleteFileButton;
345     }
346
347     /**
348      * <p>Page to include with extra fields for this document type, on
349      * display.</p>
350      *
351      * @return the current value of displayIncludePage.
352      */

353     public final String JavaDoc getDisplayIncludePage() {
354         return displayIncludePage;
355     }
356
357     /**
358      * <p>If in display mode, indicates the page number to currently
359      * show.</p>
360      *
361      * @return the current value of displayPage.
362      */

363     public final int getDisplayPage() {
364         return displayPage;
365     }
366
367     /**
368      * <p>Defines list of files DO's with are attched with this
369      * item.</p>
370      *
371      * @return the current value of fileList.
372      */

373     public List JavaDoc getFileList() {
374         return this.fileList;
375     }
376
377     /**
378      * <p>Contains all of the information about the current library
379      * item</p>
380      *
381      * @return the current value of item.
382      */

383     public final LibraryItemDO getItem() {
384         return item;
385     }
386
387     /**
388      * <p>Defines the page to link to. This varies depending on
389      * whether the item is being submitted or displayed.</p>
390      *
391      * @return the current value of linkPage.
392      */

393     public final String JavaDoc getLinkPage() {
394         return linkPage;
395     }
396
397     /**
398      * <p>If non-<code>null</code>, indicates a new page should be
399      * addes.</p>
400      *
401      * @return the current value of newPage.
402      */

403     public final String JavaDoc getNewPage() {
404         return newPage;
405     }
406
407     /**
408      * <p> TRICK
409      * storing index of button which was click in submiting page of
410      * Meeting or Faq.
411      * return first field of array, ther is a index of click button.
412      *
413      * for MEETING it's creating new AgendaPoin in heading with that
414      * index.
415      * for FAQ it's creating new Question in faq category with that
416      * index.</p>
417      *
418      * @return the current index of newPoint
419      */

420     public final String JavaDoc getNewPoint(final int index) {
421         // it's should return value of field from arrray with that index
422
// look to setter
423
return this.newPoint[0];
424     }
425
426     /**
427      * <p>Link to link the next page to, or the empty string if there is
428      * no next
429      * page.</p>
430      *
431      * @return the current value of nextPageLink.
432      */

433     public final String JavaDoc getNextPageLink() {
434         return nextPageLink;
435     }
436
437     /**
438      * <p>Contains the links with appear to the top right of displayed
439      * items.</p>
440      *
441      * @return the current value of pageLinks.
442      */

443     public final String JavaDoc getPageLinks() {
444         return pageLinks;
445     }
446
447     /**
448      * <p>Link to link the previous page to, or the empty string if there
449      * is no
450      * previous page.</p>
451      *
452      * @return the current value of previoustPageLink.
453      */

454     public final String JavaDoc getPreviousPageLink() {
455         return previousPageLink;
456     }
457
458     /**
459      * <p>Geting selected file ID from maped properties.</p>
460      *
461      * @param key - which checkBox is selected
462      */

463     public final Object JavaDoc getSelectedAttachedFilesIds(final String JavaDoc key) {
464         return this.selectedAttachedFilesIds.get(key);
465     }
466
467     /**
468      * <p>All Ids of selected files by user from list of new files.</p>
469      *
470      * @return the current value of selectedNewFilesIds.
471      */

472     public final String JavaDoc[] getSelectedNewFilesIds() {
473         return this.selectedNewFilesIds;
474     }
475
476     /**
477      * <p>Page to include with extra fields for this document type, on
478      * submission</p>
479      *
480      * @return the current value of submitIncludePage.
481      */

482     public final String JavaDoc getSubmitIncludePage() {
483         return submitIncludePage;
484     }
485
486     /**
487      * <p>Key to the localized text for the summary field (submit
488      * mode).</p>
489      *
490      * @return the current value of summaryPromptKey.
491      */

492     public final String JavaDoc getSummaryPromptKey() {
493         return summaryPromptKey;
494     }
495
496     /**
497      * <p>Specifies the theme name for the document summary section.</p>
498      *
499      * @return the current value of summaryThemeName.
500      */

501     public final String JavaDoc getSummaryThemeName() {
502         return summaryThemeName;
503     }
504
505     /**
506      * <p>Key to the localized text for the summary window (submit
507      * mode).</p>
508      *
509      * @return the current value of summaryTitleKey.
510      */

511     public final String JavaDoc getSummaryTitleKey() {
512         return summaryTitleKey;
513     }
514
515     /**
516      * <p>Specifies the theme name for the body of the document.</p>
517      *
518      * @return the current value of themeName.
519      */

520     public final String JavaDoc getThemeName() {
521         return themeName;
522     }
523
524     /**
525      * <p>In submit mode, stores all of the captions of the topics we are
526      * allowed to see.</p>
527      *
528      * @return the current value of topicCaptions.
529      */

530     public final Map JavaDoc getTopicCaptions() {
531         return topicCaptions;
532     }
533
534     /**
535      * <p>In submit mode, stores all of the unique identifiers of the
536      * topics we are allowed to see.</p>
537      *
538      * @return the current value of topicIds.
539      */

540     public final Set JavaDoc getTopicIds() {
541         return topicIds;
542     }
543
544     /**
545      * <p>In submit mode, stores all of the image filenames of the topics
546      * we are allowed to see.</p>
547      *
548      * @return the current value of topicImages.
549      */

550     public final Map JavaDoc getTopicImages() {
551         return topicImages;
552     }
553
554     /**
555      * <p>Defines list of files DO's with are goint to attch with this
556      * item.</p>
557      *
558      * @return the current value of uploadingFileList.
559      */

560     public List JavaDoc getUploadingFileList() {
561         return this.uploadingFileList;
562     }
563
564     /**
565      * <p>Reset all bean properties to their default state. This method
566      * is called before the properties are repopulated by the controller
567      * servlet.</p>
568      *
569      * @param mapping The mapping used to select this instance
570      * @param request The servlet request we are processing
571      *
572      */

573     public void reset(final ActionMapping mapping,
574             final HttpServletRequest JavaDoc request) {
575         super.reset(mapping, request);
576         setEdit(null);
577         newPage = null;
578         comment = null;
579
580         // remember only index of click button of new Point or new Question
581
newPoint = new String JavaDoc[1];
582
583         if (this.selectedAttachedFilesIds == null) {
584             this.selectedAttachedFilesIds = new HashMap JavaDoc();
585         } else {
586             this.selectedAttachedFilesIds.clear();
587         }
588
589         this.selectedNewFilesIds = new String JavaDoc[0];
590
591         /*
592                 if (item != null) {
593                     // make this one larger than it needs to be, in case a new
594                     // category is added!
595                     if (item.getType().equals(LibraryItemConstants.ITEM_MEETING)) {
596                         newPoint = null;
597                     } else if (item.getType().equals(LibraryItemConstants.ITEM_FAQ)) {
598                         newPoint = new String[item.getFaqCategories().size() + 1];
599
600                     } else {
601                         newPoint = null;
602                     }
603                 }
604         */

605     }
606
607     /**
608        <p>Version control comment</p>
609        @param comment the comment
610
611      */

612     public final void setComment(final String JavaDoc comment) {
613         this.comment = comment;
614     }
615
616     /**
617      * <p>Button for deleting attached files to item.</p>
618      *
619      * @param deleteFileButton the new value of deleteFileButton.
620      */

621     public final void setDeleteFileButton(final String JavaDoc deleteFileButton) {
622         this.deleteFileButton = deleteFileButton;
623     }
624
625     /**
626      * <p>Page to include with extra fields for this document type, on
627      * display.</p>
628      *
629      * @param displayIncludePage the new value of displayIncludePage.
630      */

631     public final void setDisplayIncludePage(final String JavaDoc displayIncludePage) {
632         this.displayIncludePage = displayIncludePage;
633     }
634
635     /**
636      * <p>If in display mode, indicates the page number to currently
637      * show.</p>
638      *
639      * @param displayPage the new value of displayPage.
640      */

641     public final void setDisplayPage(final int displayPage) {
642         this.displayPage = displayPage;
643     }
644
645     /**
646      * <p>Defines list of files DO's with are attched with this
647      * item.</p>
648      *
649      * @param fileList the new value of fileList.
650      */

651     public final void setFileList(final List JavaDoc fileList) {
652         this.fileList = fileList;
653     }
654
655     /**
656      * <p>Contains all of the information about the current library
657      * item</p>
658      *
659      * @param item the new value of item.
660      */

661     public final void setItem(final LibraryItemDO item) {
662         this.item = item;
663     }
664
665     /**
666      * <p>Defines the page to link to. This varies depending on
667      * whether the item is being submitted or displayed.</p>
668      *
669      * @param linkPage the new value of linkPage.
670      */

671     public final void setLinkPage(final String JavaDoc linkPage) {
672         this.linkPage = linkPage;
673     }
674
675     /**
676      * <p>If non-<code>null</code>, indicates a new page should be
677      * addes.</p>
678      *
679      * @param newPage the new value of newPage.
680      */

681     public final void setNewPage(final String JavaDoc newPage) {
682         this.newPage = newPage;
683     }
684
685     /**
686      * <p>TRICK
687      * storing index of button which was click in submiting page of
688      * Meeting or Faq.
689      * set first field of array
690      *
691      * for MEETING it's creating new AgendaPoin in heading with that
692      * index.
693      * for FAQ it's creating new Question in faq category with that
694      * index.</p>
695      *
696      * @param index is the index of heading or faq category
697      * @param value is the value of button
698      */

699     public final void setNewPoint(final int index,
700             final String JavaDoc value) {
701         this.newPoint[0] = String.valueOf(index);
702     }
703
704     /**
705      * <p>Link to link the next page to, or the empty string if there is
706      * no next
707      * page.</p>
708      *
709      * @param nextPageLink the new value of nextPageLink.
710      */

711     public final void setNextPageLink(final String JavaDoc nextPageLink) {
712         this.nextPageLink = nextPageLink;
713     }
714
715     /**
716      * <p>Contains the links with appear to the top right of displayed
717      * items.</p>
718      *
719      * @param pageLinks the new value of pageLinks.
720      */

721     public final void setPageLinks(final String JavaDoc pageLinks) {
722         this.pageLinks = pageLinks;
723     }
724
725     /**
726      * <p>Link to link the previous page to, or the empty string if there
727      * is no
728      * previous page.</p>
729      *
730      * @param previoustPageLink the new value of previoustPageLink.
731      */

732     public final void setPreviousPageLink(final String JavaDoc previousPageLink) {
733         this.previousPageLink = previousPageLink;
734     }
735
736     /**
737      * <p>Seting selected file ID to maped properties.</p>
738      *
739      * @param key - which checkBox is selected
740      * @param value - value which is setTo haspMap with that key
741      */

742     public final void setSelectedAttachedFilesIds(final String JavaDoc key,
743             final Object JavaDoc value) {
744         this.selectedAttachedFilesIds.put(key, value);
745     }
746
747     /**
748      * <p>All Ids of selected files by user from list of new files.</p>
749      *
750      * @param selectedNewFilesIds the new value of selectedNewFilesIds.
751      */

752     public final void setSelectedNewFilesIds(final String JavaDoc[] selectedNewFilesIds) {
753         this.selectedNewFilesIds = selectedNewFilesIds;
754     }
755
756     /**
757      * <p>Page to include with extra fields for this document type, on
758      * submission</p>
759      *
760      * @param submitIncludePage the new value of submitIncludePage.
761      */

762     public final void setSubmitIncludePage(final String JavaDoc submitIncludePage) {
763         this.submitIncludePage = submitIncludePage;
764     }
765
766     /**
767      * <p>Key to the localized text for the summary field (submit
768      * mode).</p>
769      *
770      * @param summaryPromptKey the new value of summaryPromptKey.
771      */

772     public final void setSummaryPromptKey(final String JavaDoc summaryPromptKey) {
773         this.summaryPromptKey = summaryPromptKey;
774     }
775
776     /**
777      * <p>Specifies the theme name for the document summary section.</p>
778      *
779      * @param summaryThemeName the new value of summaryThemeName.
780      */

781     public final void setSummaryThemeName(final String JavaDoc summaryThemeName) {
782         this.summaryThemeName = summaryThemeName;
783     }
784
785     /**
786      * <p>Key to the localized text for the summary window (submit
787      * mode).</p>
788      *
789      * @param summaryTitleKey the new value of summaryTitleKey.
790      */

791     public final void setSummaryTitleKey(final String JavaDoc summaryTitleKey) {
792         this.summaryTitleKey = summaryTitleKey;
793     }
794
795     /**
796      * <p>Specifies the theme name for the body of the document.</p>
797      *
798      * @param themeName the new value of themeName.
799      */

800     public final void setThemeName(final String JavaDoc themeName) {
801         this.themeName = themeName;
802     }
803
804     /**
805      * <p>In submit mode, stores all of the captions of the topics we are
806      * allowed to see.</p>
807      *
808      * @param topicCaptions the new value of topicCaptions.
809      */

810     public final void setTopicCaptions(final Map JavaDoc topicCaptions) {
811         this.topicCaptions = topicCaptions;
812     }
813
814     /**
815      * <p>In submit mode, stores all of the unique identifiers of the
816      * topics we are allowed to see.</p>
817      *
818      * @param topicIds the new value of topicIds.
819      */

820     public final void setTopicIds(final Set JavaDoc topicIds) {
821         this.topicIds = topicIds;
822     }
823
824     /**
825      * <p>In submit mode, stores all of the image filenames of the topics
826      * we are allowed to see.</p>
827      *
828      * @param topicImages the new value of topicImages.
829      */

830     public final void setTopicImages(final Map JavaDoc topicImages) {
831         this.topicImages = topicImages;
832     }
833
834     /**
835      * <p>Defines list of files DO's with are goint to attch with this
836      * item.</p>
837      *
838      * @param uploadingFileList the new value of uploadingFileList.
839      */

840     public final void setUploadingFileList(final List JavaDoc uploadingFileList) {
841         this.uploadingFileList = uploadingFileList;
842     }
843
844     /**
845      * Validate the properties that have been set for this HTTP request,
846      * and return an <code>ActionMessages</code> object that encapsulates
847      * any
848      * validation errors that have been found. If no errors are found,
849      * return <code>null</code> or an <code>ActionMessages</code> object
850      * with
851      * no recorded error messages.
852      * <p>
853      * The default ipmlementation performs no validation and returns
854      * <code>null</code>. Subclasses must override this method to provide
855      * any validation they wish to perform.
856      *
857      * @param request The servlet request we are processing.
858      * @param session The sessuib we are processing.
859      * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
860      */

861     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
862             final HttpSession JavaDoc session) {
863         ValidationErrors errors = new ValidationErrors();
864
865         // if there is no item yet, or clear was pressed, just get out
866
if ((item == null) || !StringHandling.isNullOrEmpty(getClear())) {
867             return null;
868         }
869
870         // if a topic was specified make sure it is valid
871
if ((item.getTopic() == null)
872                 || (item.getTopic().getId().equals(new Integer JavaDoc(-1)))) {
873             errors.add(new ValidationError(
874                     "submit",
875                     Library.BUNDLE_PATH,
876                     mask.getField("topicId"),
877                     "errors.library.item.submit.noTopic"));
878         }
879
880         // if there is no ok/cancel, just report the topic error
881
if (StringHandling.isNullOrEmpty(getOk())) {
882             return errors;
883         }
884
885         // if it gets here - ok was pressed. validate on the server side
886
SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession");
887         ValidationErrors libraryErrors = library.validate(securitySession, item);
888         if (libraryErrors != null) {
889             errors.addAll(libraryErrors);
890         }
891
892         return errors;
893     }
894 }
895
Popular Tags