Struts portlets are based on the Struts framework, which is an implementation of the Model-View-Controller (MVC) architecture.
The MVC architecture provides a model for separating the different components and roles of the application logic. This development framework helps you create portlets that are easier to maintain over time.
You have to follow the same procedure and file structures as i mentioned in my last post to create the Struts portlet in Liferay.
I. Development
1.1 portlet-ext.xml
<portlet>
<portlet-name>MYSTRUTSPORTLET</portlet-name>
<display-name>My Struts Portlet</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/testing/mystrutsportlet/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>
2.2. liferay-portlet-ext.xml
<portlet>
<portlet-name>MYSTRUTSPORTLET</portlet-name>
<struts-path>testing/mystrutsportlet</struts-path>
<use-default-template>false</use-default-template>
</portlet>
2.3. liferay-display.xml
<portlet id=”MYSTRUTSPORTLET” />
inside,
<category name=”category.example“>
2.4. struts-config.xml
<action path=”/testing/mystrutsportlet/view” forward=”portlet.testing.mystrutsportet.view” />
2.5. tiles-defs.xml
<definition name=”portlet.testing.mystrutsportlet.view“ extends=”portlet”>
<put name="portlet_content" value="/portlet/testing/mystrutsportlet/view.jsp" /></definition>
(create the following two jsp files under “/ext/ext-web/docroot/html/portlet/testing/mystrutsportlet“)
2.6. init.jsp
<%@ include file=”/html/portlet/init.jsp” %>
<p>Add commonly used variables and declarations here!</p>
2.7. view.jsp
<%@ include file=”/html/portlet/testing/mystrutsportlet/init.jsp” %>
Welcome to My first Simple Struts Portlet!
2.8 Language-ext.properties
Add a entry,
javax.portlet.title.MYSTRUTSPORTLET= MY STRUTS PORTLET
You have successfully created Struts Portlet.
Tags: Liferay, struts portlet
June 29, 2009 at 7:22 am |
[...] Share your knowledge Just another WordPress.com weblog « Simple Struts Portlet in Liferay 5.2.x [...]