Thursday, October 9, 2008

Create Simple Struts Portlet

These are the steps for creating simple Struts Portlet.

[the xml files are located under "ext/ext-web/docroot/WEB-INF"]


1.1. portlet-ext.xml



<portlet>

<portlet-name>EXT_3</portlet-name>

<display-name>Library Portlet</display-name>

<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>

<init-param>

<name>view-action</name>

<value>/ext/library/view</value>

</init-param>

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

<supports>

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

</supports>

<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>

<security-role-ref>

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

</security-role-ref>

<security-role-ref>

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

</security-role-ref>

</portlet>



1.2. liferay-portlet-ext.xml


<portlet>

<portlet-name>EXT_3</portlet-name>

<struts-path>ext/library</struts-path>

<use-default-template>false</use-default-template>

</portlet>



1.3. struts-config.xml



<action path="/ext/library/view" forward="portlet.ext.library.view" />



1.4. tiles-defs.xml


<definition name="portlet.ext.library" extends="portlet" />

<definition name="portlet.ext.library.view" extends="portlet.ext.library">

<put name="portlet_content" value="/portlet/ext/library/view.jsp" />

</definition>





(create the following two jsp files under "/ext/ext-web/docroot/html/portlet/ext/library")


1.5. init.jsp



<%@ include file="/html/common/init.jsp" %>

<p>Add commonly used variables and declarations here!</p>



1.6. view.jsp


<%@ include file="/html/portlet/ext/library/init.jsp" %>

Simple Struts Portlet!



1.7 Language-ext.properties



javax.portlet.title.EXT_3=Library Portlet


- Gnaniyar Zubair

No comments: