4.6.3 PortletAdapter

This class is provided as a default implementation of the Portlet class. It is recommended that your portlet extends from this abstract class rather than from the Portlet class. The adapter only provides implementations of the portlet-specific methods. It does not provide an implementation for the doXXX methods of the servlet parent (for example, doPost, doGet, etc.). The service method in PortletAdapter will not call doGet or doPost and therefore should not be used in your portlet. In addition to the methods of the Portlet class, this class defines several additional methods.

The methods getVariable, setVariable and removeVariable provide access to the variables you can set on the concrete portlet. It is important to remember that these variables are at the concrete level and therefore will not be shared with other concrete portlets even though they may be based upon the same abstract portlet. These variables are available only in code and are not presented in portal administration, nor are they configurable in the portlet.xml deployment descriptor. Example 4-1 illustrates the usage of these methods.

Example 4-1 Setting and Accessing the concrete portlet variable

setVariable("var", "Some Value");
String var = (String) getVariable("var");


Redbooks
ibm.com/redbooks