The portlet can be configured from portlet init parameters specified in a Web application deployment descriptor. Named init parameters are treated as properties of the portlet. Parameters prefixed with cxt:
are looked up using the portlet’s name context.
The following example demonstrates how a portlet whose portlet class extends GenericPortletService
might be configured in its deployment descriptor:
<portlet> <portlet-name>MyPortletService</portlet-name> <portlet-class>com.acme.portlet.MyPortletService</portlet-class> <init-param> <param-name>loggingDebug</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingWarning</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingError</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>loggingInfo</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>MyString</param-name> <param-value>foobar</param-value> </init-param> <param-name>Object</param-name> <param-value>ctx:dynamo:/com/Acme/MyFooObject</param-value> </init-param> </portlet>
Portlets derived from GenericPortletService
can use the lookup
method to look up objects by JNDI context. The object’s JNDI context is accessible through the context
property. A GenericPortletService
can log information using the standard Nucleus logging facilities provided. Support for info, warning, error and debug levels are provided by the service. If a performance monitor is enabled, the portlet collects performance metrics about the handleService
method.
Helloworld Portlet Deployment Descriptor File
The Helloworld sample portlet uses the DispatchPortlet
class. Here is the deployment descriptor file used by the Helloworld sample portlet, which is located at <ATG11dir>/Portlet/helloworld/helloworld/helloworld/WEB-INF/portlet.xml
:
<?xml version="1.0" encoding="UTF-8" ?> <portlet-app xmlns=http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd version="1.0" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="portlet-app_1_0.xsd"> <portlet> <portlet-name>HelloWorldPortlet</portlet-name> <display-name>Hello World Portlet</display-name> <portlet-class>atg.portlet.DispatchPortlet</portlet-class> <init-param> <name>path</name> <value>/index.jsp</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info> <title>Hello World Portlet</title> </portlet-info> </portlet> </portlet-app>
Note how the following parameters are configured:
Element | Description | Value |
---|---|---|
portlet-class | The Java class specified as the portlet class | atg.portlet.DispatchPortlet |
path | The relative URL of the JSP that the portlet dispatches to. | /index.jsp |
supports | MIME type and portlet modes supported by the portlet | text/html |