01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * @created Aug 2, 2005
14: * @author James Dixon
15: */
16:
17: package org.pentaho.ui.portlet;
18:
19: import java.io.IOException;
20: import java.util.ArrayList;
21:
22: import javax.portlet.ActionRequest;
23: import javax.portlet.ActionResponse;
24: import javax.portlet.PortletException;
25: import javax.portlet.PortletPreferences;
26: import javax.portlet.RenderRequest;
27: import javax.portlet.RenderResponse;
28:
29: import org.apache.commons.logging.Log;
30: import org.apache.commons.logging.LogFactory;
31: import org.pentaho.ui.component.HtmlComponent;
32:
33: public class HtmlPortlet extends ViewPortlet {
34:
35: private static final Log portletLogger = LogFactory
36: .getLog(HtmlPortlet.class);
37:
38: public Log getLogger() {
39: return portletLogger;
40: }
41:
42: public void processPortletAction(ActionRequest request,
43: ActionResponse response, PentahoPortletSession userSession)
44: throws PortletException, IOException {
45:
46: }
47:
48: public void doPortletView(RenderRequest request,
49: RenderResponse response, PentahoPortletSession userSession)
50: throws PortletException, IOException {
51:
52: PortletUrlFactory urlFactory = new PortletUrlFactory(response,
53: request.getWindowState(), request.getPortletMode());
54:
55: PortletPreferences prefs = request.getPreferences();
56: String location = prefs.getValue("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
57: String error = prefs.getValue("error", null); //$NON-NLS-1$
58: String content = prefs.getValue("content", null); //$NON-NLS-1$
59: String typeStr = prefs.getValue("type", "url"); //$NON-NLS-1$ //$NON-NLS-2$
60:
61: int type = HtmlComponent.TYPE_URL;
62: if (typeStr.equalsIgnoreCase("solution-file")) { //$NON-NLS-1$
63: type = HtmlComponent.TYPE_SOLUTION_FILE;
64: }
65:
66: if (content == null) {
67: ArrayList messages = new ArrayList();
68: HtmlComponent component = new HtmlComponent(type, location,
69: error, urlFactory, messages);
70: component.validate(userSession, null);
71: content = component.getContent("text/html"); //$NON-NLS-1$
72: }
73:
74: response.setContentType("text/html"); //$NON-NLS-1$
75: if (content == null || content.equals("")) { //$NON-NLS-1$
76: content = " "; //$NON-NLS-1$
77: }
78: response.getWriter().print(content);
79:
80: }
81:
82: }
|