Sample: Portlet Template, or Editable Portlet (DisplayURL)
Initializer ActionThe DisplayURL portlet's /**Copyright (c) 2003 by SAS Institute Inc., Cary, NC 27513. * All Rights Reserved. */ package com.sas.portal.portlets.displayurl; import java.rmi.RemoteException; import java.util.Properties; import com.sas.portal.Logger; import com.sas.portal.portlet.PortletContext; import com.sas.portal.portlet.PortletInitializerInterface; import com.sas.portal.portlet.configuration.Attribute; import com.sas.portal.portlet.configuration.Configuration; import com.sas.portal.portlet.configuration.ConfigurationFactory; /** * This initializes common properties by putting them into a * PortletContext object. */ public class Initializer implements PortletInitializerInterface { private final String _loggingContext = this.getClass().getName(); /* Key for the URL String in the PortletContext.*/ public static final String DISPLAY_URL_KEY = "sas_DisplayURL_DisplayURL"; /* PortletContext key for the edit screen Ok button URL */ public static final String EDIT_OK_URL_KEY = "sas_DisplayURL_EditOkURL"; /* PortletContext key for the edit screen Cancel button URL */ public static final String EDIT_CANCEL_URL_KEY = "sas_DisplayURL_EditCancelURL"; /** Key for the PortletException object in the PortletContext.*/ public static final String PORTLET_EXCEPTION_KEY = "sasPortletException"; /** * Puts initial properties into the PortletContext object. These * come from the portlet.xml. * @param initProperties a Properties object * @param context the PortletContext for this portlet */ public void initialize(Properties initProperties, PortletContext context) { try { // get the initial url from the portlet configuration object Configuration config = ConfigurationFactory.getConfiguration( context); Attribute attr = config.getAttribute( Initializer.DISPLAY_URL_KEY); String url = (attr == null) ? "" : attr.getValue(); context.setAttribute("error-page", initProperties.getProperty("error-page")); context.setAttribute("display-page", initProperties.getProperty("display-page")); context.setAttribute("edit-page", initProperties.getProperty("edit-page")); context.setAttribute(Initializer.DISPLAY_URL_KEY, url); if (Logger.isDebugEnabled(_loggingContext)){ Logger.debug("Display portlet URL: " + url, _loggingContext); } } catch ( RemoteException e) { context.setAttribute(Initializer.PORTLET_EXCEPTION_KEY, e); } } } |