01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/common/tool-lib/src/java/org/theospi/utils/mvc/impl/HelperView.java $
03: * $Id:HelperView.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 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.sakaiproject.metaobj.shared.control.RedirectView;
29: import org.sakaiproject.tool.api.ToolSession;
30: import org.sakaiproject.tool.cover.SessionManager;
31:
32: /**
33: * Created by IntelliJ IDEA.
34: * User: John Ellis
35: * Date: Dec 31, 2005
36: * Time: 11:25:24 AM
37: * To change this template use File | Settings | File Templates.
38: */
39: public class HelperView extends RedirectView {
40:
41: private String modelPrefix;
42:
43: public void render(Map model, HttpServletRequest request,
44: HttpServletResponse response) throws Exception {
45: // take model entries and register them as helper params
46: ToolSession toolSession = SessionManager
47: .getCurrentToolSession();
48:
49: for (Iterator i = model.entrySet().iterator(); i.hasNext();) {
50: Map.Entry entry = (Map.Entry) i.next();
51: toolSession.setAttribute(createName(entry.getKey()), entry
52: .getValue());
53: }
54:
55: super .render(model, request, response);
56: }
57:
58: protected String createName(Object key) {
59: return getModelPrefix() + key;
60: }
61:
62: public String getModelPrefix() {
63: return modelPrefix;
64: }
65:
66: public void setModelPrefix(String modelPrefix) {
67: this.modelPrefix = modelPrefix;
68: }
69:
70: }
|