Liferay Struts Portlet Development – 1
Liferay Simple Struts Portlet Development
-
create portlet entry in “portlet-ext.xml”
<portlet>
<portlet-name>libraryhome</portlet-name>
<display-name>Library Home</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/library/viewhome</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>Library Home</title>
<short-title>Library Home</short-title>
<keywords>library</keywords>
</portlet-info>
<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>
2.Create liferay specific portlet entry in “liferay-portlet-ext.xml”
<portlet>
<portlet-name>libraryhome</portlet-name>
<struts-path>ext/library</struts-path>
<use-default-template>false</use-default-template>
</portlet>
-
Create “/ext/library/viewhome” struts pageflow in struts-config.xml for the entry ‘<value>/ext/library/viewhome</value>’ in portlet-ext.xml
<action path=“/ext/library/viewhome” forward=“portlet.ext.library.viewhome” />
4. Create tiles pagelayout for “/ext/library/viewhome” – struts path in tiles-defs.xml
<definition name=“portlet.ext.library” extends=“portlet” />
<definition name=“portlet.ext.library.viewhome” extends=“portlet.ext.library”>
<put name=“portlet_content” value=“/portlet/ext/library/view_home.jsp” />
</definition>
-
Create JSP file view_home for the pageto be displayed
<%@ include file=“/html/portlet/ext/library/init.jsp” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8″>
<title>Library Home</title>
</head>
<body>
Library Home
<br> <h3>Home Page will be used entry point for Libarary Process </h3>
</body>
</html>
-
Include init.jsp /html/portlet/ext/library/init.jsp
This is for our portlet initialization parameter or preferences …
-
init.jsp
// this is for liferay, xtra tags file to be used in our jsp while development .. Eg: image tag, display tag, etc …
<%@ include file=“/html/common/init.jsp” %>
<portlet:defineObjects />
<%
WindowState windowState = renderRequest.getWindowState();
%>
-
End..
Create a category, and add this..
Enjoy
Struts portlet with Struts Action will be available in Next Post
-live