KickJava   Java API By Example, From Geeks To Geeks.

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


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-2005 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.MessagesManager;
17 import info.magnolia.cms.servlets.MVCServletHandlerImpl;
18 import info.magnolia.cms.util.RequestFormUtil;
19 import info.magnolia.cms.util.Resource;
20
21 import java.io.IOException JavaDoc;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25
26
27 /**
28  * This is the MVCHandler for simple dialog pages.
29  * @author Philipp Bracher
30  * @version $Revision$
31  */

32
33 public abstract class DialogPageMVCHandler extends MVCServletHandlerImpl {
34
35     protected static final String JavaDoc COMMAND_SHOW = "show"; //$NON-NLS-1$
36

37     protected static final String JavaDoc VIEW_DRAW = "draw"; //$NON-NLS-1$
38

39     /**
40      * the request passed by the MVCServlet
41      */

42     protected HttpServletRequest JavaDoc request;
43
44     /**
45      * The repsonse passed by the MVCServlet
46      */

47     protected HttpServletResponse JavaDoc response;
48
49     /**
50      * The posted multipart form. Use params for easy access.
51      */

52     protected MultipartForm form;
53
54     protected info.magnolia.cms.i18n.Messages msgs;
55
56     protected RequestFormUtil params;
57
58     /**
59      * @param request
60      * @param response
61      */

62     public DialogPageMVCHandler(String JavaDoc name, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
63         super(name, request, response);
64
65         this.request = request;
66         this.response = response;
67
68         form = Resource.getPostedForm(request);
69         params = new RequestFormUtil(request, form);
70         msgs = MessagesManager.getMessages(request);
71     }
72
73     /*
74      * @see info.magnolia.cms.servlets.MVCServletHandler#getCommand()
75      */

76     public String JavaDoc getCommand() {
77         return COMMAND_SHOW;
78     }
79
80     /**
81      * @return
82      */

83     public String JavaDoc show() {
84         return VIEW_DRAW;
85     }
86
87     public void renderHtml(String JavaDoc view) throws IOException JavaDoc {
88         if (VIEW_DRAW.equals(view)) {
89             try {
90                 draw(request, response);
91             }
92             catch (Exception JavaDoc e) {
93                 response.getWriter().print(e);
94             }
95         }
96     }
97
98     protected abstract void draw(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc;
99
100 }
Popular Tags