How to Create a Struts Portlet using Liferay Plugin Sdk

There is an article available at Liferay Wiki to help you develop a Struts Based Portlet using there Plugin SDK, but chances are pretty high that the article alone wont suffice.

Here are a few problems you might face when you develop a Struts based Portlet.

1. You might get errors for ActionForward, ActionMapping and so on.
2. Your project will have compilation problems.

Here are a few simple steps to create a Struts Based portlet:


1. Download plugin-sdk from http://sourceforge.net/projects/lportal/files/
2. Create a new project in your eclipse using this plugin.
3. Modify the build.properties. Make another copy of the same as build..properties and place it at same location.
4. Change the file to give your tomcat location. Also tell the deploy folder location where it will dump war file.
5. Before you create a new Struts Portlet, check for your ant. Go to command prompt and type ant. If it gives some message you are fine. Else you need to set ANT_HOME variable like your JAVA_HOME
6.When you create a new Struts Portlet using SDK then you must create and action class which extends StrutsAction and implements its methods like doView().

Like for example:

public class SampleStrutsAction extends StrutsPortlet {

public void doView(RenderRequest req, RenderResponse res)
throws IOException, PortletException {

super.doView(req, res);
}

7. After creating this class you need to refer it in the portlet.xml file:
Create an entry like:

com.xyz.struts.portlet.SampleStrutsAction

8. Now you are ready to create an action class having the render() and processAction() methods.

9. You may need to do one more thing, that is attaching the Liferay Portal Source Code if you want to add more functionality to your Portlet.

A sample struts portlet can be found here. Just deploy it to see that it works fine. Then import it to view the structure.

One more thing, attach portlet.jar, portal-kernel.jar and struts.jar to your plugin sdk.

Compile your portlet and then deploy.

Setting up Freemarker + Spring Portlet in Spring MVC – Spring

I had been searching and searching and to no avail.
Can some one please show me how to set up spring portlet to use Freemarker instead of jsp/jstl in an spring mvc framework please??
Havent had much luck finding it on the web

well specifically want to know whats the portlet equivilant of this
<bean id=”urlMapping”>
<property name=”mappings”>
<value>
/twitter.html=TwitterController
/twitterLogin.html=TwitterController
/twitterUpdate.html=TwitterController
</value>
</property>
<property name=”order” value=”0″/>
</bean>

given that there is no SimpleUrlHandlerMapping in the web.portlet packages in spring.

Okay. That doesn’t have anything to do with JSP / FreeMarker. Just a straightforward “how does Spring MVC map portlet requests to controllers/views?” thing.

Are you using Spring 2.5 or an older version? Reason I ask is, the first choice is whether you are going to use the Annotation-based Controllers or the Interface-based Controllers. Mapping is quite different depending on these. If you are using 2.5, I highly recommend going with the Annotation-based controllers.

Other resources to look at to understand the major differences between servlet requests and portlet requests in Spring:

Chapter 16 of the reference manual:
http://static.springsource.org/sprin…e/portlet.html

The slides and sample code from a seminar I did earlier this year on Spring Portlet MVC:
http://www.ja-sig.org/wiki/x/CACDAQ