KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > addressbook > struts > GroupFrameAction


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: GroupFrameAction.java,v $
31  * Revision 1.3 2005/04/10 18:47:36 colinmacleod
32  * Changed i tag to em and b tag to strong.
33  *
34  * Revision 1.2 2005/04/09 17:19:08 colinmacleod
35  * Changed copyright text to GPL v2 explicitly.
36  *
37  * Revision 1.1.1.1 2005/03/10 17:50:24 colinmacleod
38  * Restructured ivata op around Hibernate/PicoContainer.
39  * Renamed ivata groupware.
40  *
41  * Revision 1.4 2004/12/31 18:27:42 colinmacleod
42  * Added MaskFactory to constructor of MaskAction.
43  *
44  * Revision 1.3 2004/12/23 21:01:25 colinmacleod
45  * Updated Struts to v1.2.4.
46  * Changed base classes to use ivata masks.
47  *
48  * Revision 1.2 2004/11/12 18:19:13 colinmacleod
49  * Change action and form classes to extend MaskAction, MaskForm respectively.
50  *
51  * Revision 1.1 2004/11/12 15:40:25 colinmacleod
52  * First version in CVS.
53  *
54  * -----------------------------------------------------------------------------
55  */

56 package com.ivata.groupware.business.addressbook.struts;
57
58 import java.lang.reflect.InvocationTargetException JavaDoc;
59
60 import javax.servlet.http.HttpServletRequest JavaDoc;
61 import javax.servlet.http.HttpServletResponse JavaDoc;
62 import javax.servlet.http.HttpSession JavaDoc;
63
64 import org.apache.commons.beanutils.PropertyUtils;
65 import org.apache.struts.action.ActionErrors;
66 import org.apache.struts.action.ActionForm;
67 import org.apache.struts.action.ActionMapping;
68
69 import com.ivata.mask.MaskFactory;
70 import com.ivata.mask.util.StringHandling;
71 import com.ivata.mask.util.SystemException;
72 import com.ivata.mask.web.struts.MaskAction;
73 import com.ivata.mask.web.struts.MaskAuthenticator;
74
75 /**
76  * <p>
77  * This action tells the JSP page <code>groupFrame.jsp</code> what to display,
78  * and how to display it.
79  * </p>
80  *
81  * @since ivata groupware 0.10 (2004-11-03)
82  * @author Colin MacLeod
83  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
84  * @version $Revision: 1.3 $
85  */

86 public class GroupFrameAction extends MaskAction {
87     /**
88      * <p>
89      * Constructor. Called by <strong>PicoContainer.</strong>.
90      * </p>
91      *
92      * @param maskFactory This factory is needed to access the masks and groups
93      * of masks.
94      * @param authenticator used to confirm whether or not the
95      * user should be allowed to continue, in the <code>execute</code> method.
96      */

97     public GroupFrameAction(MaskFactory maskFactory, MaskAuthenticator authenticator) {
98         super(maskFactory, authenticator);
99     }
100
101     /**
102      * <p>
103      * This method does all the hard work in preparing data for
104      * <code>frameIndex.jsp</code>.
105      * </p>
106      *
107      * @param mapping The ActionMapping used to select this instance.
108      * @param log valid logging object to write messages to.
109      * @param errors valid errors object to append errors to. If there are
110      * any errors, the action will return to the input.
111      * @param form optional ActionForm bean for this request (if any)
112      * @param request non-HTTP request we are processing
113      * @param response The non-HTTP response we are creating
114      * @param session returned from the <code>request</code> parameter.
115      * @exception SystemException if there is any problem which
116      * prevents processing. It will result in the webapp being forwarded
117      * to
118      * the standard error page.
119      * @return this method returns the string used to identify the correct
120      * <em>Struts</em> <code>ActionForward</code> which should follow this
121      * page, or <code>null</code> if it should return to the input.
122
123      * @see com.ivata.mask.web.struts.MaskAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionMessages, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpSession)
124      */

125     public String JavaDoc execute(final ActionMapping mapping,
126             final ActionErrors errors,
127             final ActionForm form,
128             final HttpServletRequest JavaDoc request,
129             final HttpServletResponse JavaDoc response,
130             final HttpSession JavaDoc session)
131             throws SystemException {
132         String JavaDoc mode = request.getParameter("mode");
133         if (StringHandling.isNullOrEmpty(mode)) {
134             throw new SystemException("No mode specified in GroupFrameAction");
135         }
136
137         // this frame can handle 3 different types of content:
138
// groups, address books and user groups
139
String JavaDoc menuPage, contentFrameName;
140         // content will be set via JavaScript on the menu pane
141
String JavaDoc contentPage = "/util/loading.jsp";
142
143         if ("group".equals(mode)) {
144             menuPage = "/addressBook/groupTree.action?mode=group";
145             contentFrameName = "ivataGroup";
146         } else if ("addressBook".equals(mode)) {
147             menuPage = "/addressBook/groupList.action?mode=addressBook";
148             contentFrameName = "ivataAddressBook";
149         } else if ("userGroup".equals(mode)) {
150             menuPage = "/addressBook/groupList.action?mode=userGroup";
151             contentFrameName = "ivataUserGroup";
152         } else {
153             throw new SystemException("ERROR in GroupFrameAction: unidentified mode '"
154                     + mode
155                     + "'");
156         }
157
158         try {
159             PropertyUtils.setProperty(form, "contentFrameName", contentFrameName);
160             PropertyUtils.setProperty(form, "contentPage", contentPage);
161             PropertyUtils.setProperty(form, "menuFrameName",
162                     contentFrameName + "List");
163             PropertyUtils.setProperty(form, "menuPage", menuPage);
164         } catch (IllegalAccessException JavaDoc e) {
165             throw new SystemException(e);
166         } catch (InvocationTargetException JavaDoc e) {
167             throw new SystemException(e);
168         } catch (NoSuchMethodException JavaDoc e) {
169             throw new SystemException(e);
170         }
171         return null;
172     }
173 }
174
Popular Tags