Show TOC Start of Content Area

Background documentation Initializing Portlets  Locate the document in its SAP Library structure

The portlet initialization takes place right after the portlet object has been instantiated and before it is invoked to handle the first request. In this phase, the portlet can initialize costly resources and other one-time activities. The portlet container invokes the init method of the Portlet interface with an object that implements the PortletConfig interface. The PortletConfig object provides the portlet with its configuration. The configuration information is retrieved from the portlet definition in the deployment descriptor.

The portlet can use the PortletConfig object to retrieve the portlet name, the portlet initialization parameters, the portlet resource bundle and the portlet application context.

Example

private PortletConfig config;

  private String jspName;

  private String portletName;

 

  /**

   * Called by the portlet container to indicate to a portlet that the

   * portlet is being placed into service.

   */

  public void init(PortletConfig config) throws PortletException {

    this.config = config;

    //gets the name of the JSP that will be used in rendering method

    jspName = config.getInitParameter("jspView");

    portletName = config.getPortletName();

  }

 

 

End of Content Area