Wednesday, September 7, 2011

liferay-portlet.xml configuration

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


 
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.0.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">

<liferay-portlet-app>
    <portlet>
        <portlet-name>hello-word</portlet-name>
        <icon>/icon.png</icon>
        <instanceable>true</instanceable>
        <header-portlet-css>/css/main.css</header-portlet-css>
        <footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
        <css-class-wrapper>hello-word-portlet</css-class-wrapper>
    </portlet>
    <role-mapper>
        <role-name>administrator</role-name>
        <role-link>Administrator</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>guest</role-name>
        <role-link>Guest</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>power-user</role-name>
        <role-link>Power User</role-link>
    </role-mapper>
    <role-mapper>
        <role-name>user</role-name>
        <role-link>User</role-link>
    </role-mapper>
</liferay-portlet-app>



Following are descriptions for various elements of liferay-portlet.xml


portlet-name - The portlet-name element contains the canonical name of the portlet. This needs to be the same as the portletname given in portlet.xml

icon - Path to icon image for this portlet.

instanceable - Indicates if multiple instances of this portlet can appear on the same page.

headerportlet-css - The path to the .css file for this portlet to be included in the <head> of the page

footerportletjavascript - The path to the .js file for this portlet, to be included at the end of the page before </body>
Share |

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 |