Portlet.xml概要描述

来源:互联网 发布:黑马程序员开班时间 编辑:程序博客网 时间:2024/06/07 10:04

一,Porlet.xml具体格式

<portlet>

<portlet-name>jsp-portlet</portlet-name>

<display-name>JSP Portlet</display-name>

<portlet-class>com.sample.jsp.portlet.JSPPortlet</portlet-class>

<init-param>

<name>view-jsp</name>

<value>/view.jsp</value>

</init-param>

<expiration-cache>0</expiration-cache>

<supports>

<mime-type>text/html</mime-type>

</supports>

<portlet-info>

<title>JSP Portlet</title>

<short-title>JSP Portlet</short-title>

<keywords>JSP Portlet</keywords>

</portlet-info>

<security-role-ref>

<role-name>administrator</role-name>

</security-role-ref>

<security-role-ref>

<role-name>user</role-name>

</security-role-ref>

</portlet>

 

二,Portlet各标签的含义

portlet-name The portlet-name element contains the canonical name of the portlet. Each portlet name is unique within the portlet application. (This is also referred within Liferay Portal as the portlet id)

portlet-name就像是portletId,必须唯一

display-name The display-name type contains a short name that is intended to be displayed by tools. It is used by display-name elements. The display name need not be unique.

portlet-class The portlet-class element contains the fully qualified class name of the portlet.

需要的Portlet实现对应的Class

init-param The init-param element contains a name/value pair as an initialization param of the portlet.

expiration-cache Expiration-cache defines expiration-based caching for this portlet. The parameter indicates the time in seconds after which the portlet output expires. -1 indicates that the output never expires.

缓存过期的时间

supports The supports element contains the supported mime-type. Supports also indicates the portlet modes a portlet supports for a specific content type. All portlets must support the view mode.

portlet-info Portlet-info defines portlet information.

security-role-ref

The security-role-ref element contains the declaration of a security role reference in the code of the web application. Specifically in Liferay, the role-name references which role’s can access the portlet.

(A Power User can personalize the portal, whereas a User cannot.)

三,Portlet.xml示例

<?xml version="1.0" encoding="UTF-8"?>

<portlet-app

    xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd /opt/SUNWportal/dtd/portlet.xsd"

    version="2.0">

    <portlet>

       <portlet-name>testportal</portlet-name>

       <display-name>Sample JSP</display-name>

       <portlet-class>test.portlet.MyPortlet</portlet-class>

       <init-param>

           <name>view-jsp</name>

           <value>/view.jsp</value>

       </init-param>

       <expiration-cache>0</expiration-cache>

       <supports>

           <mime-type>text/html</mime-type>

       </supports>

      

       <portlet-info>

           <title>myfirstportal</title>

           <short-title>myfirstportal</short-title>

           <keywords>myfirstportal</keywords>

       </portlet-info>

      

       <security-role-ref>

           <role-name>administrator</role-name>

       </security-role-ref>

       <security-role-ref>

           <role-name>guest</role-name>

       </security-role-ref>

       <security-role-ref>

           <role-name>power-user</role-name>

       </security-role-ref>

       <security-role-ref>

           <role-name>user</role-name>

       </security-role-ref>

    </portlet>

</portlet-app>

 本文参考了liferay Portal 5.0的Development文档。

原创粉丝点击