|
Sample: Portlet Template, or Editable Portlet (DisplayURL)
Base ActionThe DisplayURL portlet's
/**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.container.deployment.PortletActionInfoInterface;
import com.sas.portal.portlet.NavigationUtil;
import com.sas.portal.portlet.PortletActionInterface;
import com.sas.portal.portlet.PortletContext;
import com.sas.portal.portlets.displayurl.Initializer;
public abstract class BaseAction implements PortletActionInterface
{
private final String _loggingContext = this.getClass().getName();
private PortletActionInfoInterface _actionInfo = null;
/**
* This method must be overridden in subclasses.
* They must call super and supply a return value.
* In this class, the method returns null.
*
* @see com.sas.portal.portlet.PortletActionInterface#service(
* HttpServletRequest, HttpServletResponse, PortletContext)
*/
public String service(HttpServletRequest request,
HttpServletResponse response,
PortletContext context) throws Exception
{
Logger.debug("started..", _loggingContext);
response.setContentType("text/html;charset=UTF-8");
// prepare the localized resources for use by the jsp.
try {
NavigationUtil.prepareLocalizedResources(
"com.sas.portal.portlets.displayurl.Resources",
request, context);
}
catch (java.io.IOException ioe) {
Logger.error(ioe.getMessage(), _loggingContext, ioe);
}
return null;
}
/**
* @see com.sas.portal.portlet.PortletActionInterface#setInfo(
* PortletActionInfoInterface)
*/
public final void setInfo(PortletActionInfoInterface info)
{
_actionInfo = info;
}
/**
* @see com.sas.portal.portlet.PortletActionInterface#getInfo()
*/
public final PortletActionInfoInterface getInfo()
{
return _actionInfo;
}
/**
* Check the PortletContext for an exception object. If present,
* throw it so that the error handler will kick in.
* @param context the PortletContext
*/
protected static final void errorCheck(PortletContext context)
throws Exception
{
Exception e = (Exception)context.getAttribute(
Initializer.PORTLET_EXCEPTION_KEY);
if (e != null)
throw e;
}
}
|