Wednesday, September 7, 2011

portlet.xml configuration options

Share |
You can find portlet.xml file located at <PORTLET Project Directoy>/docroot/WEB-INF/portlet.xml . Following is sample portlet.xml file form sample portlet project
portlet.xml

 
<?xml version="1.0"?>

<portlet-app version="2.0" 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 http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
    <portlet>
        <portlet-name>hello-word</portlet-name>
        <display-name>Hello World</display-name>
        <portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</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>Hello World</title>
            <short-title>Hello World</short-title>
            <keywords>Hello World</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>


Following are descriptions for various elements of portlet.xml

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)

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

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

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

expirationcache - Expiration-cache defines expiration-based caching forthis 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 mimetype. 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. e.g portlet title, short title, keywords etc.

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. Here you can also give custom roles created in side Liferay

Share |

No comments:

Post a Comment