1.Define the Portlet
potlet-ext.xml
<portlet>
<portlet-name>EXT_4</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>
<portlet-name>EXT_4</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>
liferay-portlet-ext.xml
<
portlet
>
< portlet-name > EXT_4 </ portlet-name >
< struts-path > ext/library </ struts-path >
< use-default-template > false </ use-default-template >
</ portlet >
< portlet-name > EXT_4 </ portlet-name >
< struts-path > ext/library </ struts-path >
< use-default-template > false </ use-default-template >
</ portlet >
2.Define the page flow and layout
struts-config.xml
<
action
path
="/ext/library/view"
forward
="portlet.ext.library.view"
/>
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 >
< definition name ="portlet.ext.library.view" extends ="portlet.ext.library" >
< put name ="portlet_content" value ="/portlet/ext/library/view.jsp" />
</ definition >
3.Create the JSP in .../ext/ext-web/docroot/html/portlet/ext/library/
init.jsp
<%
...
@ include file="/html/common/init.jsp"
%>
< p > Add commonly used variables and declarations here! </ p >
< p > Add commonly used variables and declarations here! </ p >
view.jsp
<%
...
@ include file="/html/portlet/ext/library/init.jsp"
%>
Simple struts portlet!
Simple struts portlet!
4.Set the Portlet Title
go to .../ext/ext-ejb/classes/content/Language-ext.properties, add:
javax.portlet.title.EXT_4=Library
5.Add the Portlet to a Caterory
go to .../ext/ext-web/docroot/WEB-INF/liferay-display.xml, add:
<category name="category.test">
<portlet id="EXT_1" />
<portlet id="EXT_4" />
...
</category>
...
Finally,
.../ext>ant deploy