Portlet.xml概要描述

一,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文档。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值