Friday, 6 June 2014

Understanding some properties related to Liferay LDAP Import process

Liferay provides an easy way to integrate with LDAP. Using its control panel you can enable LDAP and also add the LDAP server.
There is pretty good documentation around that. Please refer to this wiki link http://goo.gl/7dqgj9

The two things I wanted to discuss in this post are regarding the usage of the following properties

ldap.import.lock.expiration.time and ldap.import.interval

Both these properties can be specified in the portal-ext.properties file.

But the confusion I had was what's the difference between these two.

I started looking at the Liferay Portal 6.2 source code and wanted to share my findings.

Tuesday, 15 April 2014

Resolving Service builder issues in Liferay

Recently I ran into some issues when trying to use Liferay service builder utility. Although I was working with Liferay CE 6.2 this post should be helpful for any Liferay version.

For the first time when I ran service builder it worked fine and generated the tables. But then I changed the namespace entry in service.xml file. This change did not update the database table. So I deleted the table and tried to run service builder again and redeploy the portlet. But this resulted in errors during portlet deployment.

Friday, 11 April 2014

Upload files and access form elements in a custom Portlet - Using multipart/form-data and UploadPortletRequest

This blog post will help you if you are looking to add form upload functionality to your JSP form and then access it in your controller, java class.

For this blog post I have used Liferay portal.

Lets get started. In your Portlet JSP please add enctype="multipart/form-data" to the form tag.

The complete JSP code is provided below for reference




Next lets go to our controller class. Once the form is submitted this class will come into picture.

First we need to get UploadPortletRequest object using the ActionRequest object. This is the object we will use to access all the form elements.

UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(request);

String docTitle = ParamUtil.getString(uploadRequest, "docTitle");
String comments= ParamUtil.getString(uploadRequest, "docComments");

I have used Liferay's ParamUtil which is a helper class. But you can directly get these parameters from the request object using request.getParameter();

Also you can extract file details using

String fileName = uploadRequest.getFileName("documentFile");
InputStream inputStream = uploadRequest.getFileAsStream("documentFile");

That's it.

Thursday, 10 April 2014

Understanding and using the Liferay Document Library - Part 2

In Part 1 of this blog post we saw some basic concepts around how document library can be used, also the database side of it like the tables being used and also the file structure.

In this post I will show you how to upload a document using Liferay's  document library API.

To get started create a MVC Portlet.

Understanding and using the Liferay Document Library - Part 1

In this two part blog post I will try to explain how to use the Liferay Document Library to store and manage your documents.

I will be using Liferay version 6.2 CE to illustrate this. Also I won't go into the meta-data details for the documents, for that you can refer to the user guide.

In the first part I will discuss some concepts related to the Document Library. Like the tables being used etc.

In the second part I will show you how to use the API from a Portlet. If you want to directly see that then here is the link.

Wednesday, 19 March 2014

Adding workflow to a custom portlet in Liferay 6.2

In this blog post I am going to give an overview on how you can integrate workflow feature in your portlet using Liferay API's.

Please Note: This blog will not be related to configuring out of the box Kaleo workflow portlet. By configuring I mean adding new workflows. For this please refer to the Liferay documentation.

In this post I will layout the basic steps to get workflow feature integrated in your custom portlet. I used Liferay v 6.2

Things have changed in the new Liferay version, especially the look and feel. We will discuss more about the new features in another article.

Here are the basic steps to get workflow integrated

Thursday, 5 December 2013

Implementing email functionality in a JSR portlet using Liferay API's

Many a times we have a requirement to implement email functionality in our Portlets.
A simple use case can be the contact us form on your website. When the user submits it, it should send an email to the concerned department.

I am going to explain how to implement this.

I am using Liferay Portal and a JSR compliant portlet. We will be using Liferay's SubscriptionSender class to do the job of sending emails.

Another important thing is we can either use the tmpl file(email template) to do this or use a web content to
create the email template.

The advantage with web content is that it can be localized, which is currently not possible with a tmpl file, at the time of writing this post.

Here are the steps

1. If using a tmpl file create one like email_body.tmpl

The content of  this file can be something like