Portlet描述文件通过portlet.xml文件定义application portlet和conrete portlet。这一节将介绍portlet.xml的定义。
Portlet描述文件有下面的结构:
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app-collection>
![](/images/load.gif)
<portlet-app-def>
![](/images/load.gif)
<portlet-app ...>
![](/images/load.gif)
<concrete-portlet-app ...>
![](/images/load.gif)
<concrete-portlet-app ...>
</portlet-app-def>
</portlet-app-collection>
![](/images/load.gif)
portlet-app-collection定义portlet的集合
![](/images/load.gif)
portlet-app-def定义了application porlet和多个conrete portlet
![](/images/load.gif)
portlet-app提供了一个application portlet的定义
![](/images/load.gif)
concrete-portlet-app提供了一个concrete portlet的定义
一个具体portlet定义了conrete portlet的属性。一个application portlet可以有多个conrete portlet。
<concrete-portlet-app id="org.myorganization.portlets.myportlet.1">
![](/images/load.gif)
<context-param>
![](/images/load.gif)
<param-name>buzzle</param-name>
<param-value>yea</param-value>
</context-param>
<concrete-portlet>
![](/images/load.gif)
<portlet-name>Hello World 1</portlet-name>
![](/images/load.gif)
<default-locale>en</default-locale>
![](/images/load.gif)
<language locale="en_US">
![](/images/load.gif)
<title>Hello World - Sample Portlet #1</title>
![](/images/load.gif)
<title-short>Hello World</title-short>
![](/images/load.gif)
<description>Here is a simple portlet</description>
![](/images/load.gif)
<keywords>portlet hello world</keywords>
![](/images/load.gif)
</language>
<language locale="zh_CN">
<title>您好#1</title>
<title-short>您好 </title-short>
<description>久违了</description>
<keywords>问候</keywords>
</language>
<allowed-access visibility="PRIVATE" role="ADMIN"/>
![](/images/load.gif)
<config-param>
![](/images/load.gif)
<param-name>a config parameter</param-name>
<param-value>a config value</param-value>
</config-param>
</concrete-portlet>
</concrete-portlet-app>
![](/images/load.gif)
Id是conrete portlet的指示符,由application portlet Id加上一个整数组成。一般来说,由1开始递增
![](/images/load.gif)
(可选)定义了portlet context信息,由PortletApplicationSettings 对象封装
![](/images/load.gif)
concrete portlet,用作产生PortletSettings对象
![](/images/load.gif)
(可选)conrete portlet的指示符
![](/images/load.gif)
(可选) 缺省的locale
![](/images/load.gif)
(可选) 其他的locale
![](/images/load.gif)
(可选)title
![](/images/load.gif)
(可选) 更简短的title,可以被用作WML设备上显示
![](/images/load.gif)
(可选) 摘要
![](/images/load.gif)
(可选) 关键字
![](/images/load.gif)
(可选) 定义了用户浏览这个portlet的时候的可视化属性。Allowed 的值有两个 PRIVATE 和PUBLIC. Role属性哪个角色可以访问这个portlet。 可用的值是在PortletRole 对象中定义的值
![](/images/load.gif)
附加的concrete portlet 设置,可以通过PortletSettings 对象取得