Tuesday, December 13, 2011

Good links


Liferay Faces 3.1.0-ga1 Released

Liferay 6.1 simple cluster


Introducing the new ADT Framework


Using log4j to ensure each portlet has it's own log file 


Faceted Search in Liferay 6.1 

Implementing UpgradingProcess for your Liferay Portlets!!, mobile sites and responsive layouts

Wednesday, November 30, 2011

How to access custom portlet services in velocity template

By default we will have following property which won't allow us to use serviceLocator variable in velocity templates.

    # Input a comma delimited list of variables which are restricted from the
    # context in Velocity based Journal templates.

In order to access you need to change that property as below


Default findServce(serviceName)  method (what we normally use) searches @ portal level where as other one with extra parameter as shown here  findService(servletContextName, serviceName) searches @ particular portlet level

TO add more to it here are the method signatures & implementations in

        public Object findService(String serviceName) {
                Object bean = null;

                try {
                        bean = PortalBeanLocatorUtil.locate(_getServiceName(serviceName));
                catch (Exception e) {
                        _log.error(e, e);

                return bean;

        public Object findService(String servletContextName, String serviceName) {
                Object bean = null;

                try {
                        bean = PortletBeanLocatorUtil.locate(
                                servletContextName, _getServiceName(serviceName));
                catch (Exception e) {
                        _log.error(e, e);

                return bean;

HoW tO uSe

Suppose i have an custom Entity named MyEntity(defined through service.xml)

#set ($myEntityService = $serviceLocator.findService("", "com.rnd.common.portlet.service.MyEntityLocalService"))

I have a column named count under MyEntity, i can access as below

#set ($count =$myEntityService.getCount())


Hope that helps :)

Please feel free to add your comments. Cheers

Tuesday, November 29, 2011

How to open HSQL DB tables of Liferay in eclipse

Earlier i blogged about how to connect to HSQL DB from command prompt using HSQL Database Manager. Now as per request i have blogged to connect to HSQL DB form Eclipse

> Open Data source explorer in Eclipse

> Right click on Database Connections > New, you see screen looking like below as shown in Figure.1

> Type hsql as showing screen below & select HSQLDB - Give a name to your DB connection


> Do as described in Figure.2 below(Point to a Liferay DB which is using HSQL)

> You will see screen like below in Figure.3, once done close this window

NOTE : Here jar file you will using should point to the hsql.jar you have for Liferay installation under tomcat/lib/ext (Below is the screen shot for the same)

> Now you have to give proper Liferay DB name & Database location - Give DB connection other will be populated automatically. Check the save password check box. In my case DB location is


You change this path according to your Liferay instance DB running on HSQL

> You can test the connection as show below

 > Click on Next from above screen, you see below screen check for connection profile & click finish

> You will be redirect to Datasource Explorer, which looks like below

Please feel free to add comments.

Cheers :)

How to open HSQL DB tables of Liferay

Some times we may need come across vague where we have to check few things immediately. Need to make some new version of Liferay up & running quickly, have to check DB for reference

As we all know default DB that Liferay uses in HSQL DB.

Here are the quick steps to how to open HSQL DB table entries in Liferay

Step 1: Download HQSLDB from Extract into some folder (eg. D:\hsqldb)

Step 2: You can use the HSQLDB DatabaseManager to view this database. Run the following from the command line to invoke the tool.

    java -cp D:\hsqldb\lib\hsqldb.jar org.hsqldb.util.DatabaseManager

    In the "Connect" dialog, select the following options:
    Type: HSQL Database Engine Server
    Driver: org.hsqldb.jdbcDriver
    URL: jdbc:hsqldb: (In my case i have my Liferay installation @ D:\projects\liferay\lr523\liferay-portal-5.2.3\data\hsql so i have to give path as jdbc:hsqldb:D:/projects/liferay/lr523/liferay-portal-5.2.3/data/hsql/lportal for URL)
    User: sa

Please see the attached image for reference of settings we need to provide

That's it now you should be able to see all the tables. Database interface may not be quite intuitive as other commercial/open-source DB interfaces. Please check the below image for ref

UPDATE : Check the blog for how to connect to HSQL DB using Eclipse

Please feel free to provide feedback if any

Cheers :)

Thursday, November 24, 2011

Tuesday, September 20, 2011

Fckeditor second time access/set issue in Liferay 5.2.x

I have faced a typical issue while working with fckeditor & LR version 5.2 EE SP3 (i thought it might be helpful for somebody who will come across similar scenario)

I have a requirement where i need to show fckeditor in a popup - In popup I have a drop drop , depending upon the change in drop down/select box i need to show different contents in fckeditor & other form fields (I am using servceResource to get new content)

When i used fckeditor it was working fine for first time opened popup - on change of drop down/select box & submitting the form working fine, if close the popup after submitting the popup/onchange of select box & try to open popup again and change the dropdrop i was not able to set/get contents of fckeditor.

For getting value from editor using


doesn't work all the time.

My scenario was, in popup I wanted to show Editor, then read value, and afterwards post it using Ajax post. So First time it works well.
But second time when i try to get value it says "editor.getHTML function not exists".
So way around was using

Hope it helps someone.

Here is a good link for how to add fckeditor to portlet

Liferay new features 6.1

Indexer post processor hook in Liferay 6.1

Theme Settings and New Advanced Controls

Wednesday, July 27, 2011

Service Builder vague behavior

I came across a use case where i have to created Entity with columns which are reserved words in Databases. Initially i didn't observe those are reserved words. If our column name is equal to reserved word service builder tool starts throwing vague errors. I am not able to find where the problem was exactly. My service.xml contains around 20+ tables. Debugging the same sucks & tiresome.

<entity name="MyCustomEntity" table="MyTable" local-service="true" remote-service="false">
        <!-- PK fields -->
        <column name="name" db-name="Name" type="String" primary="true" />

        <!-- Audit fields -->
        <column name="company" db-name="Company" type="String" />
        <column name="default" db-name="Default" type="boolean" />
        <column name="locale" db-name="Locale" type="String" />
        <column name="message" db-name="Message" type="String" />
        <column name="senderAddress" db-name="SenderAddress" type="String" />
        <column name="subject" db-name="Subject" type="String" />
        <column name="type" db-name="Type" type="String" />
        <!-- Order -->
        <order by="desc">
            <order-column name="name" />

If you see above entity portion of my service.xml - the column colored in red is a reserved word that is the one causing the problem.

I have changed that portion to below

        <column name="default_" db-name="Default_" type="boolean" />

If the service builder is behaving in a vague manner & if you are sure about correctness of your entity portion's of service.xml then better have a look at following files
  1. bad_column_names.txt
  2. bad_table_names.txt 
  3. bad_alias_names.txt
Might be some of the column names/alias names/table names are handled separately by Service Builder Tool/Databases.

Please feel free to share your comments. Cheers :)

Friday, July 22, 2011

Entity caching disabling - custom portlet

In some cases we need to disable caching for some Entities in Liferay according to requirements. In one of my project i got a requirement where i got this use case for my plugin portlet

By default Liferay caches all the entities.

First Option : One way to do it is, at entity level in service.xml set cache-enabled attribute to false as below

    <entity name="MyModelEntity" table="MyModelEntity" local-service="true" remote-service="true" cache-enabled="false">

Second option:  You can disable the same @ portlet level by setting following properties, in your underr src folder of your portlet plugin add following porperties (I am not pretty much sure about below one);;

Colored in blue is path to your model entity

I hope it will helpful for some who is looking for similar stuff.

Please feel free to drop your comments

Friday, June 3, 2011

Getting context path in jsp

Some times while developing plugin portlets/hooking into existing liferay files we may need to get context path in jsps, either to make ajax calls/to navigate to different jsp in same or different folder. Here is how you will get context path in jsps

<%= request.getContextPath()%>

Comments are most welcome, if any body wants to dicuss more on this topic