Datasheet

<portlet-info>
<title>Pre-configured title</title>
<short-title>Example</short-title>
<keywords>JSR 168, Portlet API, Example, Simple</keywords>
</portlet-info>
This section shows the portlet preferences. Of course, the preferences you define must be unique. The
index-location preference is read-only, so it cannot be changed programmatically; instead, it must
be changed here. The second preference,
sites-to-crawl, shows how multiple values can be specified
for a preference. The last preference,
crawl-depth represents a number that must be converted through
Integer.parseInt, because preferences are all retrieved as either a String or a String array. The
preferences-validator element specifies a class that is used to validate these portlet-preferences.
In this case, the validator would confirm that the
sites-to-crawl are valid and that the crawl-depth is
less than five (to keep the crawling time down).
<portlet-preferences>
<preference>
<name>index-location</name>
<value>/opt/lucene/index</value>
<read-only>true</read-only>
</preference>
<preference>
<name>sites-to-crawl</name>
<value>http://jakarta.apache.org</value>
<value>http://java.sun.com</value>
<value>http://onjava.com</value>
</preference>
<preference>
<name>crawl-depth</name>
<value>2</value>
</preference>
<preferences-validator>
com.opensourceportals.validator.CrawlValidator
</preferences-validator>
</portlet-preferences>
Here we have the relevant security references for the portlet. The role-name element specifies the
parameter that should be passed to the
request.isUserInRole(String roleName) method. The
role-link is the role, defined in the portlet application’s web.xml, into which the user should be
mapped.
<security-role-ref>
<role-name>ADMIN</role-name>
<role-link>administrator</role-link>
</security-role-ref>
This closes the definition of the portlet. This can be repeated as many times as necessary to define all of
the portlets within your portlet application. Of course, each of your portlets must have a unique name
within this portlet application.
</portlet>
30
Chapter 1
04 469513 Ch01.qxd 1/16/04 11:04 AM Page 30