1 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.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 { 42 43 } 44 45 public void doPortletView(RenderRequest request, RenderResponse response, PentahoPortletSession userSession) throws PortletException, IOException { 46 47 PortletUrlFactory urlFactory = new PortletUrlFactory(response, request.getWindowState(), request.getPortletMode()); 48 49 PortletPreferences prefs = request.getPreferences(); 50 String location = prefs.getValue("location", ""); String error = prefs.getValue("error", null); String content = prefs.getValue("content", null); String typeStr = prefs.getValue("type", "url"); 55 int type = HtmlComponent.TYPE_URL; 56 if (typeStr.equalsIgnoreCase("solution-file")) { type = HtmlComponent.TYPE_SOLUTION_FILE; 58 } 59 60 if (content == null) { 61 ArrayList messages = new ArrayList (); 62 HtmlComponent component = new HtmlComponent(type, location, error, urlFactory, messages); 63 component.validate(userSession, null); 64 content = component.getContent("text/html"); } 66 67 response.setContentType("text/html"); if (content == null || content.equals("")) { content = " "; } 71 response.getWriter().print(content); 72 73 } 74 75 } 76 | Popular Tags |