Saturday 13 February 2016

Learn about the new Portlet Specification 3.0 or JSR 362

If you are into Portlet Development work you will be happy to learn about the new Portlet Spec Version 3.0, expected to release sometime in 2016.

You might be wondering why this new Specification ?

Continue Reading

Thursday 7 August 2014

Java - Can you find the sum of numbers in a String

Consider a String "abc67uty89ty". Now can you write a program to calculate the value of 6+7+8+9

There might be other better solutions but here is what I did using Regular expression, which makes this quite easy.

In Java you can use regular expression to search and get index of a pattern. The two primary classes used are Pattern and Matcher.

The expression "\d" I use below is to get numeric values.

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.