Showing posts with label Liferay. Show all posts
Showing posts with label Liferay. Show all posts

Friday, April 27, 2012

Liferay : Target "depoly" does not exist in the project "my-greeting-portlet"

After creating a portlet, as mentioned in liferay documentation.While deploying it to tomcat, below mentioned error was seen.

Target "depoly" does not exist in the project "my-greeting-portlet"

Please see the commands below.

C:\liferay-plugins-sdk-6.0.5\portlets>create.bat my-greeting "My Greeting"
Buildfile: C:\liferay-plugins-sdk-6.0.5\portlets\build.xml

create:
    [unzip] Expanding: C:\liferay-plugins-sdk-6.0.5\portlets\portlet.zip into C:
\liferay-plugins-sdk-6.0.5\portlets\my-greeting-portlet
    [mkdir] Created dir: C:\liferay-plugins-sdk-6.0.5\portlets\my-greeting-portl
et\docroot\WEB-INF\tld
     [copy] Copying 6 files to C:\liferay-plugins-sdk-6.0.5\portlets\my-greeting
-portlet\docroot\WEB-INF\tld

BUILD SUCCESSFUL
Total time: 4 seconds

C:\liferay-plugins-sdk-6.0.5\portlets>

While deploying using ant deploy command, below mentioned error was seen.

C:\liferay-plugins-sdk-6.0.5\portlets>cd my-greeting-portlet

C:\liferay-plugins-sdk-6.0.5\portlets\my-greeting-portlet>ant deploy
Buildfile: C:\liferay-plugins-sdk-6.0.5\portlets\my-greeting-portlet\build.xml

BUILD FAILED
Target "depoly" does not exist in the project "my-greeting-portlet".

C:\liferay-plugins-sdk-6.0.5\portlets\my-greeting-portlet>

Tuesday, April 24, 2012

How to create a form in Liferay

You may need to create a form in liferay. As you may be aware that in liferay every page consists of portlets, hence to create a form you need to create a portlet.
Below example shows how to create a form in liferay. In this example we have a view.jsp which contains form fields and the form is submitted to another jsp (i.e. submit.jsp)

To submit the form in liferay you need to create a renderURL as shown below. Please see the self explanatory example below.

view.jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>

<portlet:renderURL var="submitURL">
 <portlet:param name="jspPage" value="/submit.jsp" />
</portlet:renderURL>

<aui:form action="<%= submitURL %>" method="post">

 <aui:input label="First name" name="fName" type="text" value=""/>
 <aui:input label="Last name" name="lName" type="text" value=""/>
 <aui:input label="Password" name="password" type="password" value=""/>

 <b>Gender</b>
 <aui:input label="Male" name="gender" type="radio" value="Male"/>
 <aui:input label="Female" name="gender" type="radio" value="Female"/>

 <b>Language</b>
 <aui:input label="C" name="lang" type="checkbox" value="C"/>
 <aui:input label="Java" name="lang" type="checkbox" value="Java"/>
 <aui:input label="Perl" name="lang" type="checkbox" value="Perl"/>

 <aui:input name="hiddenValue" type="hidden" value="hide it"/>

 <aui:button type="submit" value="Submit Form"/>
 <aui:button type="reset" value="Reset Values"/>

</aui:form>

Monday, April 16, 2012

Liferay : How to call another portlet of another page

In Liferay you may need to call another portlet of another page. Lets see how we can communicate between pages and portlets.

Please follow below mentioned steps for portlet communication accross pages.

1. Add tag library as shown below

<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>

2. Import below mentioned classes

<%@ page import='com.liferay.portal.theme.PortletDisplay' %>
<%@ page import='com.liferay.portal.theme.ThemeDisplay' %>
<%@ page import='com.liferay.portal.kernel.util.WebKeys'%>


3. Get portlet id and portlet name of the JSP which need to be called. Add below codes to the JSP which need to be called.

Note : You may need to save portlet id and portlet name in session, property file etc and pass those values in calling JSP.

<%
 ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
 PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
 long portletId = themeDisplay.getPlid();
 String portletName = portletDisplay.getId();

%>


4.  Create renderURL. Get portlet id and portlet name from stored session, property file etc and pass here for creating render url.

<liferay-portlet:renderURL var="URLName" plid="<%= portletId %>" portletName="<%= portletName %>" >
<liferay-portlet:param name="jspPage" value="/html/portletName/jspFile.jsp" />
<liferay-portlet:param name="param1" value="<%= param1 %>"></liferay-portlet:param>
<liferay-portlet:param name="param2" value="<%= param2 %>"></liferay-portlet:param>
</liferay-portlet:renderURL>


<a href="<%= URLName %>">Click Here</a>