KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > ui > portlet > HtmlPortlet


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * 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 JavaDoc;
20 import java.util.ArrayList JavaDoc;
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.getLog(HtmlPortlet.class);
36
37     public Log getLogger() {
38         return portletLogger;
39     }
40
41     public void processPortletAction(ActionRequest request, ActionResponse response, PentahoPortletSession userSession) throws PortletException, IOException JavaDoc {
42
43     }
44
45     public void doPortletView(RenderRequest request, RenderResponse response, PentahoPortletSession userSession) throws PortletException, IOException JavaDoc {
46
47         PortletUrlFactory urlFactory = new PortletUrlFactory(response, request.getWindowState(), request.getPortletMode());
48
49         PortletPreferences prefs = request.getPreferences();
50         String JavaDoc location = prefs.getValue("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
51
String JavaDoc error = prefs.getValue("error", null); //$NON-NLS-1$
52
String JavaDoc content = prefs.getValue("content", null); //$NON-NLS-1$
53
String JavaDoc typeStr = prefs.getValue("type", "url"); //$NON-NLS-1$ //$NON-NLS-2$
54

55         int type = HtmlComponent.TYPE_URL;
56         if (typeStr.equalsIgnoreCase("solution-file")) { //$NON-NLS-1$
57
type = HtmlComponent.TYPE_SOLUTION_FILE;
58         }
59
60         if (content == null) {
61             ArrayList JavaDoc messages = new ArrayList JavaDoc();
62             HtmlComponent component = new HtmlComponent(type, location, error, urlFactory, messages);
63             component.validate(userSession, null);
64             content = component.getContent("text/html"); //$NON-NLS-1$
65
}
66
67         response.setContentType("text/html"); //$NON-NLS-1$
68
if (content == null || content.equals("")) { //$NON-NLS-1$
69
content = " "; //$NON-NLS-1$
70
}
71         response.getWriter().print(content);
72
73     }
74
75 }
76
Popular Tags