JournalVmUtil in Liferay 6.1

11 Jul

Disclaimer – Following is not the best or optimal solution. If you have better suggestion please write in comments

JournalVmUtil was present upto Liferay 5.2 and then deprecated in Liferay 6.0 and then completed removed in Liferay 6.1. If you are upgrading to 6.1 and make extensive use of JournalVmUtil you can do the following.

Extend VelocityTemplateParser.java. Following code example is just a sample. Feel free to add any pre-processing or post-processing as required

package com.myexamples.mypackage;

import com.liferay.portal.kernel.templateparser.TemplateNode;
import com.liferay.portal.kernel.xml.Element;
import com.liferay.portlet.journal.util.VelocityTemplateParser;

import java.util.List;

/**
 * @author parasjain
 */
public class MyVelocityTemplateParserImpl extends VelocityTemplateParser{
    public List getNodes(Element element) throws Exception {
        return getTemplateNodes(element);
    }
}

Now inject MyVelocityTemplateParserImpl in your velocity templates and just call getNodes method like this

#set( $articleTemplateNodes = $myVelocityTemplateParser.getNodes($articleXmlDocument.getRootElement()) )
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: