Tips & Tricks: include jsp into vm template

This tip&trick is dedicated to all developers who work with themes and vm’s. Probably you know that you have only little set of services from VelocityVariables class and some variables from init.vm. If you want call normal service method this is a huge problem. My question was: how can I include a jps file to vm file? Liferay has a lot of scriptlets and calls services from jsp. Why I can’t call it from VM? Many of you tell me: “I know how can you do it. Put this line of code and it’s ready”

#set ($categoriesService = $portal.getClass()
.forName("com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil")
.getMethod("getService", null).invoke(null, null))

My answer is: Yessss, it works. But I want use a jstl lib (e.g. <aui> or <ui>) as well. In my opinion the simpliest way to do it is include jsp file to themeServletContext. Put your file.jsp into your theme:
your-theme/docroot/path/to/your/jsp/file.jsp

and paste this piece of code into your vm (for example portal_normal.vm):

$theme.include($themeServletContext, "/path/to/your/jsp/file.jsp")

And enjoy all Liferay’s functionalities!

Advertisement

What is Liferay 6.1 release date

Answer is: today (today like in 21 september). At Wednesday we will see Liferay 6.1 EE and Marketplace. For those who can not attend Liferay West Coast Symposium there will be Live broadcast on Liferay.com/live so don’t miss it. We gonna prepare a lot of popcorn here at eo Networks.

Update: Well it look like it was only a presentation of upcoming version. betea release is scheduled for October 15 and stable release for Q4’2011.

Case study: East European Performing Arts Platform

The eepap.org service has been made by eo Networks S.A. for the Adam Mickiewicz Institute (Instytut Adama Mickiewicza) –  ‘a state cultural institution whose task is to promote Polish culture around the world and actively participate in international cultural exchange’. The aim of the project was to create the platform for East European artists and institutions to share the information and cooperate in form of arts network. The core of the site is presentation of artists, events and cultural institutions.

Interesting features that we added to standard Liferay 6.0.3 CE are:

  1. Event Calendar (based on Web Content Structure and modified Asset Publisher)
  2. Advanced Journal Search so you can easily find events or artists
  3. Ability to attach files in web form portlet

The event structure enables editors to set the start and end date of events, such as theatre premiere, show, workshops etc. After that Event Calendar portlet will display current month and will mark days when events take place – start, end and all days in between.

eepap.org - main page

eepap.org - main page

 

Web form with attachement

Web form with attachement

eepap.org - event calendar

eepap.org - event calendar