First of all, download liferay-portal-tomcat-6.0.6-20110225.zip and liferay-plugins-sdk-6.0.6-20110225.zip from http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.0.6/
Next, open Eclipse and go to Help/Install New Software. After that, click Add to add a new repository. Set the name as Liferay and the location as http://releases.liferay.com/tools/ide/eclipse/helios/stable
Then, you have to select Liferay repository and check Liferay Tools and click Next to download Liferay plugins for Eclipse. Also, you have to accept the license.
When the process installation finishes, you must restart Eclipse IDE.
Next, extract the contents of liferay-portal-tomcat-6.0.6-20110225.zip and liferay-plugins-sdk-6.0.6-20110225.zip in any directory of your computer.
After that, configure a New Server in Eclipse. You must lookup for Liferay V6.0
Set the Liferay Tomcat Directory(this target must be the Tomcat server which is into Liferay server).
Set the Tomcat bundle zip(this target must be the ext.zip into the ext directory of the liferay-plugins-sdk)
Finally, click Finish.
Now, we have to configure the Eclipse preferences for Liferay.
Lookup for Liferay Installed Plugin. Click add.
Set the location where you extracted liferay-plugins-sdk and set a name. Finally, click OK
click ok again.
Then we are going to create our first project.
click on File/new/Liferay Project
Set the name for the project
Click Next.
Select Liferay MVC and check Create Custom portlet class
Click Next.
Set name for the portlet class, set a java package and select javax.portlet.GenericPortlet as superclass then Click Next.
You may change the name of the portlet for Liferay, click Next
Also, you may change the css styles also set the category where the portlet will be set. Click Next
In this screen you should check the option processAction to process information which will be sent from a form.
Next, change view.jsp to:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
${message}
<form id="formData" action="<portlet:actionURL/>" method="POST">
<table>
<tr><td>Phone:</td><td><input type="text" name="phone"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td><input type="submit" value="Send Info"></td>
<td><input type="reset" value="Clean"></td></tr>
</table>
</form>
Next, create a new JSP page. Right Click over the project new/other/Web/JSP
set the name result.jsp
Change result.jsp to:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
${info}
After that, open the file PorletTest.java.
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String phone = (String) actionRequest.getParameter("phone");
String email = (String) actionRequest.getParameter("email");
String info="You entered the following information:"+phone+","+email;
actionResponse.setRenderParameter("info", info);
}
Also, Change doView method to:
public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
if(renderRequest.getParameter("info")==null){
renderRequest.setAttribute("message", "Please, enter your phone number and email");
include(viewJSP, renderRequest, renderResponse);
}else{
renderRequest.setAttribute("info",renderRequest.getParameter("info"));
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/html/portlettest/result.jsp");
prd.include(renderRequest, renderResponse);
}
}
Next, right click over the project. Select Run on Server and choose Liferay V.6 and click Finish.
The liferay server home page will be opened.
Sign in as user test@liferay.com with password test
Click on Add/more and lookup for PortletTest. Next click add.
The form will appear. Enter the data
Click Send Info
Interesantísima aportación. Enhorabuena por el post, la verdad es que me ha sido de gran utilidad.
ResponderEliminarGRACIAS
Hola, muy bueno el tema felicitaciones. Tengo que realizar lo siguiente: Tengo un Proyecto Roo con un par de entidades y la converti a gwt (uso el IDE STS de spring).
ResponderEliminar¿Como podria convertir esa aplicación web en un portlet para instalar en liferay?
mucho más completo que la guía oficial... pero tengo un problema: el asistente no me ha generado PortletTest.java, así que me he creado yo la clase y he copiado los métodos que describes aquí... claro, me faltan el init y el include! el init se ve en el pantallazo, pero el include no!!
ResponderEliminarpodrías incluirlo? o decirme pq no me ha generado la clase?
I'm sorry for the delay. Did you "check Create Custom portlet class"? you have to do this step when you create the project
ResponderEliminar