001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: CommentForm.java,v $
031: * Revision 1.3 2005/04/10 20:31:58 colinmacleod
032: * Added new themes.
033: * Changed id type to String.
034: * Changed i tag to em and b tag to strong.
035: * Improved PicoContainerFactory with NanoContainer scripts.
036: *
037: * Revision 1.2 2005/04/09 17:19:46 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:52:05 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.6 2004/12/23 21:01:28 colinmacleod
045: * Updated Struts to v1.2.4.
046: * Changed base classes to use ivata masks.
047: *
048: * Revision 1.5 2004/11/12 18:19:15 colinmacleod
049: * Change action and form classes to extend MaskAction, MaskForm respectively.
050: *
051: * Revision 1.4 2004/07/13 19:47:29 colinmacleod
052: * Moved project to POJOs from EJBs.
053: * Applied PicoContainer to services layer (replacing session EJBs).
054: * Applied Hibernate to persistence layer (replacing entity EJBs).
055: *
056: * Revision 1.3 2004/03/21 21:16:29 colinmacleod
057: * Shortened name to ivata op.
058: *
059: * Revision 1.2 2004/02/01 22:07:31 colinmacleod
060: * Added full names to author tags
061: *
062: * Revision 1.1.1.1 2004/01/27 20:58:40 colinmacleod
063: * Moved ivata openportal to SourceForge..
064: *
065: * Revision 1.3 2003/11/13 16:11:08 jano
066: * commitng everything to CVS
067: * can deploy and application is ruuning, can login into
068: *
069: * Revision 1.2 2003/10/15 14:16:53 colin
070: * fixing for XDoclet
071: *
072: * Revision 1.4 2003/07/21 14:16:48 jano
073: * we have new field - list
074: * somethime we are commenting without itemForm in session
075: * Revision 1.3 2003/02/28 13:44:12 colin
076: * made comments work with Struts & popups
077: *
078: * Revision 1.2 2003/02/28 07:30:22 colin
079: * implemented editing/displaying of faqs & notes
080: *
081: * Revision 1.1 2003/02/24 19:09:24 colin
082: * moved to business
083: * -----------------------------------------------------------------------------
084: */
085: package com.ivata.groupware.business.library.struts;
086:
087: import javax.servlet.http.HttpServletRequest;
088: import javax.servlet.http.HttpSession;
089:
090: import org.apache.struts.action.ActionErrors;
091:
092: import com.ivata.groupware.admin.security.server.SecuritySession;
093: import com.ivata.groupware.business.library.Library;
094: import com.ivata.groupware.business.library.comment.CommentDO;
095: import com.ivata.mask.util.StringHandling;
096: import com.ivata.mask.validation.ValidationErrors;
097:
098: /**
099: * <p>Contains details of a comment which is being changed.</p>
100: *
101: * @since 2003-02-18
102: * @author Colin MacLeod
103: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
104: * @version $Revision: 1.3 $
105: */
106: public class CommentForm extends LibraryForm {
107: /**
108: * <p>Contains the comment currently being edited.</p>
109: */
110: private CommentDO comment;
111: /**
112: * <p>
113: * Library implementation.
114: * </p>
115: */
116: private Library library;
117: /**
118: *<p>it <code>true</code> that refresh list of openComments, otherwise refres display item page.</p>
119: */
120: private String list;
121:
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 getList() {
160: return this .list;
161: }
162:
163: /**/
164: public void reset(final HttpServletRequest request,
165: final HttpSession 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 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 request,
203: final HttpSession 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
214: .getAttribute("securitySession");
215: validationErrors = library.validate(securitySession, comment);
216:
217: return validationErrors;
218: }
219: }
|