01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/shared/control/ForwardView.java $
03: * $Id: ForwardView.java 14230 2006-09-05 18:02:51Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared.control;
21:
22: import java.util.Iterator;
23: import java.util.Map;
24:
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27:
28: import org.springframework.web.servlet.view.AbstractUrlBasedView;
29:
30: /**
31: * Created by IntelliJ IDEA.
32: * User: John Ellis
33: * Date: May 18, 2004
34: * Time: 3:12:19 PM
35: * To change this template use File | Settings | File Templates.
36: */
37: public class ForwardView extends AbstractUrlBasedView {
38:
39: private String action = "";
40:
41: /**
42: * Subclasses must implement this method to render the view.
43: * <p>The first take will be preparing the request: This may include setting
44: * the model elements as request attributes, e.g. in the case of a JSP view.
45: *
46: * @param model combined output Map, with dynamic values taking precedence
47: * over static attributes
48: * @param request current HTTP request
49: * @param response current HTTP response
50: * @throws Exception if rendering failed
51: */
52: protected void renderMergedOutputModel(Map model,
53: HttpServletRequest request, HttpServletResponse response)
54: throws Exception {
55: request.setAttribute("action", getUrl());
56:
57: for (Iterator i = model.entrySet().iterator(); i.hasNext();) {
58: Map.Entry entry = (Map.Entry) i.next();
59: request.setAttribute((String) entry.getKey(), entry
60: .getValue());
61: }
62:
63: request.getRequestDispatcher(getUrl()).forward(request,
64: response);
65: }
66:
67: public String getAction() {
68: return action;
69: }
70:
71: public void setAction(String action) {
72: this.action = action;
73: }
74: }
|