KickJava   Java API By Example, From Geeks To Geeks.

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


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: CommentForm.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:05 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.6 2004/12/23 21:01:28 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:40 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.4 2003/07/21 14:16:48 jano
73  * we have new field - list
74  * somethime we are commenting without itemForm in session
75  * Revision 1.3 2003/02/28 13:44:12 colin
76  * made comments work with Struts & popups
77  *
78  * Revision 1.2 2003/02/28 07:30:22 colin
79  * implemented editing/displaying of faqs & notes
80  *
81  * Revision 1.1 2003/02/24 19:09:24 colin
82  * moved to business
83  * -----------------------------------------------------------------------------
84  */

85 package com.ivata.groupware.business.library.struts;
86
87 import javax.servlet.http.HttpServletRequest JavaDoc;
88 import javax.servlet.http.HttpSession JavaDoc;
89
90 import org.apache.struts.action.ActionErrors;
91
92 import com.ivata.groupware.admin.security.server.SecuritySession;
93 import com.ivata.groupware.business.library.Library;
94 import com.ivata.groupware.business.library.comment.CommentDO;
95 import com.ivata.mask.util.StringHandling;
96 import com.ivata.mask.validation.ValidationErrors;
97
98
99 /**
100  * <p>Contains details of a comment which is being changed.</p>
101  *
102  * @since 2003-02-18
103  * @author Colin MacLeod
104  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
105  * @version $Revision: 1.3 $
106  */

107 public class CommentForm extends LibraryForm {
108     /**
109      * <p>Contains the comment currently being edited.</p>
110      */

111     private CommentDO comment;
112     /**
113      * <p>
114      * Library implementation.
115      * </p>
116      */

117     private Library library;
118     /**
119      *<p>it <code>true</code> that refresh list of openComments, otherwise refres display item page.</p>
120      */

121     private String JavaDoc list;
122     /**
123      *
124      * @param library
125      * @param maskParam
126      * Refer to {@link #getMask}.
127      * @param baseClassParam
128      * Refer to {@link #getBaseClass}.
129      */

130     public CommentForm(final Library library) {
131         this.library = library;
132         clear();
133     }
134
135     /**
136      * TODO
137      *
138      * @see com.ivata.mask.web.struts.MaskForm#clear()
139      */

140     protected void clear() {
141         comment = new CommentDO();
142         list = null;
143     }
144
145     /**
146      * <p>Contains the comment currently being edited.</p>
147      *
148      * @return the current value of comment.
149      */

150     public final CommentDO getComment() {
151         return comment;
152     }
153
154     /**
155      *<p>it <code>true</code> that refresh list of openComments, otherwise refres display item page.</p>
156      *
157      * @return the current value of list.
158      */

159     public final String JavaDoc getList() {
160         return this.list;
161     }
162
163     /**/
164     public void reset(final HttpServletRequest JavaDoc request,
165             final HttpSession JavaDoc session) {
166         comment = new CommentDO();
167     }
168
169     /**
170      * <p>Contains the comment currently being edited.</p>
171      *
172      * @param comment the new value of comment.
173      */

174     public final void setComment(final CommentDO comment) {
175         this.comment = comment;
176     }
177
178     /**
179      *<p>it <code>true</code> that refresh list of openComments, otherwise refres display item page.</p>
180      *
181      * @param list the new value of list.
182      */

183     public final void setList(final String JavaDoc list) {
184         this.list = list;
185     }
186
187     /**
188      * Validate the properties that have been set for this HTTP request,
189      * and return an <code>ActionMessages</code> object that encapsulates any
190      * validation errors that have been found. If no errors are found,
191      * return <code>null</code> or an <code>ActionMessages</code> object with
192      * no recorded error messages.
193      * <p>
194      * The default ipmlementation performs no validation and returns
195      * <code>null</code>. Subclasses must override this method to provide
196      * any validation they wish to perform.
197      *
198      * @param request The servlet request we are processing.
199      * @param session The HTTP session we are processing.
200      * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
201      */

202     public ValidationErrors validate(final HttpServletRequest JavaDoc request,
203             final HttpSession JavaDoc session) {
204         // if there is no ok, just get out
205
if (StringHandling.isNullOrEmpty(getOk())) {
206             return null;
207         }
208
209         // if it gets here - ok was pressed. validate on the server side
210
ActionErrors errors;
211         ValidationErrors validationErrors;
212
213         SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession");
214         validationErrors = library.validate(securitySession, comment);
215
216         return validationErrors;
217     }
218 }
219
Popular Tags