KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > PageMVCHandler


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.admininterface;
14
15 import info.magnolia.cms.beans.runtime.MultipartForm;
16 import info.magnolia.cms.i18n.Messages;
17 import info.magnolia.cms.i18n.MessagesManager;
18 import info.magnolia.cms.servlets.CommandBasedMVCServletHandler;
19 import info.magnolia.cms.util.RequestFormUtil;
20 import info.magnolia.cms.util.Resource;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29
30 /**
31  * This is the MVCHandler for simple pages. The properties with coresponding request parameters are set with BeanUtils.
32  * @author Philipp Bracher
33  * @version $Revision: 7292 $
34  */

35
36 public abstract class PageMVCHandler extends CommandBasedMVCServletHandler {
37
38     /**
39      * Logger
40      */

41     Logger log = LoggerFactory.getLogger(PageMVCHandler.class);
42
43     /**
44      * The name of the parameter passed by the request. Not used for simple pages.
45      */

46     protected static final String JavaDoc COMMAND_PARAMETER_NAME = "command";
47
48     protected static final String JavaDoc COMMAND_SHOW = "show"; //$NON-NLS-1$
49

50     protected static final String JavaDoc VIEW_SHOW = "show"; //$NON-NLS-1$
51

52     /**
53      * The posted multipart form. Use params for easy access.
54      */

55     private MultipartForm form;
56
57     /**
58      * The messages used for this page
59      */

60     private Messages msgs;
61
62     /**
63      * Parameters passed by the request.
64      */

65     private RequestFormUtil params;
66
67     /**
68      * Constuctor
69      * @param name
70      * @param request
71      * @param response
72      */

73     public PageMVCHandler(String JavaDoc name, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
74         super(name, request, response);
75
76         setForm(Resource.getPostedForm(request));
77         setParams(new RequestFormUtil(request, getForm()));
78         setMsgs(MessagesManager.getMessages());
79     }
80
81     /**
82      * @see info.magnolia.cms.servlets.MVCServletHandlerImpl#init()
83      */

84     public void init() {
85         super.init();
86         if (StringUtils.isEmpty(this.getCommand())) {
87             this.setCommand(COMMAND_SHOW);
88         }
89     }
90
91     /**
92      * This is an empty implementation return the default show view.
93      * @return the view name
94      */

95     public String JavaDoc show() {
96         return VIEW_SHOW;
97     }
98
99     /**
100      * @param form The form to set.
101      */

102     protected void setForm(MultipartForm form) {
103         this.form = form;
104     }
105
106     /**
107      * @return Returns the form.
108      */

109     protected MultipartForm getForm() {
110         return form;
111     }
112
113     /**
114      * @param msgs The msgs to set.
115      */

116     protected void setMsgs(Messages msgs) {
117         this.msgs = msgs;
118     }
119
120     /**
121      * @return Returns the msgs.
122      */

123     protected Messages getMsgs() {
124         return msgs;
125     }
126
127     /**
128      * @param params The params to set.
129      */

130     protected void setParams(RequestFormUtil params) {
131         this.params = params;
132     }
133
134     /**
135      * @return Returns the params.
136      */

137     protected RequestFormUtil getParams() {
138         return params;
139     }
140 }
Popular Tags