Sample: Portlet Template, or Editable Portlet (DisplayURL)
OK and Cancel ActionsThe DisplayURL portlet's /**Copyright (c) 2003 by SAS Institute Inc., Cary, NC 27513. * All Rights Reserved. */ package com.sas.portal.portlets.displayurl; import com.sas.portal.portlet.configuration.ConfigurationFactory; import com.sas.portal.portlet.configuration.Configuration; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.sas.portal.Logger; import com.sas.portal.portlet.PortletContext; /** * Action class that processes the Ok action from the editor. It * persists the user-specified URL, sets up the display model, then * instructs the portlet container to present the display page. */ public final class OKAction extends BaseAction { private final String _loggingContext = this.getClass().getName(); /** * Service the portlet request. * * @param request the HttpServletRequest * @param response the HttpServeltResponse * @param context the PortletContext * @return the URL to call */ public String service (HttpServletRequest request, HttpServletResponse response, PortletContext context) throws Exception { super.service(request, response, context); String url = request.getParameter(Initializer.DISPLAY_URL_KEY); context.setAttribute(Initializer.DISPLAY_URL_KEY, url); // save the URL parameter Configuration config = ConfigurationFactory.getConfiguration( context); config.setAttribute(Initializer.DISPLAY_URL_KEY, url); ConfigurationFactory.storeConfiguration(context, config); if (Logger.isDebugEnabled(_loggingContext)){ Logger.debug("Display portlet URL: " + url, _loggingContext); } // back to the default, display, mode // context.resetMode(); return (String)context.getAttribute("display-page"); } } /** Copyright (c) 2003 by SAS Institute Inc., Cary, NC 27513. * All Rights Reserved. */ package com.sas.portal.portlets.displayurl; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; //import com.sas.portal.Logger; import com.sas.portal.portlet.PortletContext; /** * Action class that processes the Cancel action from the editor. It * sets up the display model then instructs the portlet container to * present the display page. */ public final class CancelAction extends BaseAction { // private final String _loggingContext = this.getClass().getName(); /** * Service the portlet request. * * @param request the HttpServletRequest * @param response the HttpServeltResponse * @param context the PortletContext * @return the URL to call */ public String service(HttpServletRequest request, HttpServletResponse response, PortletContext context) throws Exception { super.service(request, response, context); // back to the default, display, mode // context.resetMode(); return (String)context.getAttribute("display-page"); } } |