4.6.10 PortletSettings object
When the portal administrator deploys a new portlet or copies an existing one, PortletSettings are created. A Portlet parameterized by its PortletSettings is referred to as a concrete portlet.
Figure 4-5 Portlet parameterization objects
This object is best thought of as wrapping the information defined in the <concrete-portlet> section of the portlet.xml deployment descriptor. The PortletSettings object encapsulates the configuration information of the concrete portlet instance. The parameter information is retrieved from the portlet.xml but can be modified at runtime while the portlet is in Configure mode. Therefore, the PortletSettings object can be used as a storage for attributes to be shared by all the concrete portlet instances. When attributes are adjusted or added, be sure to call the store method to persist the new values. The administrator can add new parameters and alter existing parameter values via the Manage Portlets portlet in Administration place. The PortletSettings object also provides access to configuration information such as the title of the concrete portlet and the default locale. This object can be retrieved from the PortletRequest object or is passed as a parameter to the initConcrete and destroyConcrete methods of the portlet. The main methods are:
![]()
getAttribute/setAttribute/removeAttribute: these methods provide access to attributes.
![]()
getTitle: this returns a string indicating the title of the portlet for the current client and the specified locale. Note that this method returns the active title, not necessarily the title specified in the deployment descriptor. If the administrator has changed the title at runtime for example, that value is returned.
![]()
getDefaultLocale: this method returns a Locale object specifying the default locale as determined by the portlet.xml.
![]()
getPortletApplicationSettings: this method will return the PortletApplicationSettings object discussed in 4.6.11, PortletApplicationSettings object. Example 4-9 Working with PortletSettings
String title = request.getPortletSettings().getTitle( request.getLocale(), request.getClient())); java.util.Locale locale = request.getPortletSettings().getDefaultLocale()); PortletApplicationSettings portletAppSettings =
request.getPortletSettings().getApplicationSettings(); String attribute = request.getSettings().getAttribute("attName");
//Only available in doConfigure: request.getSettings().setAttribute("attribute", "Some Value"); request.getSettings().store();
![]()
ibm.com/redbooks