Skip to content

Instantly share code, notes, and snippets.

View jamesfalkner's full-sized avatar

James Falkner jamesfalkner

View GitHub Profile
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## Super-simple example of a WCM app
#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
<em>Demo 1: Super-simple example of a WCM app</em>
<h1>Hello, Liferay!</h1>
<img src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
<h3>User Count: $userLocalService.getUsersCount()</h3>
<h3>Config Setting: $appconfig1.data</h3>
## Long-running process hanging render
<em>Demo 2: Long-running process that hangs the rendering for about 10 seconds</em>
<h1>Hello, Liferay!</h1>
<img src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
## long-running process
#set ($start = $dateUtil.newDate())
#foreach ($i in [1..15000000])
#end
## Portlet lifecycle: long-running process in RESOURCE_PHASE
#if ($request.lifecycle == "RENDER_PHASE")
<em>Demo 2: Long-running process that doesn't hang</em>
<h1>Hello, Liferay!</h1>
<img src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
<h3>Didn't take very long, did it?</h3>
#elseif ($request.lifecycle == "RESOURCE_PHASE")
## Passing parameters
#set ($pns = $request.portlet-namespace)
#if ($request.lifecycle == "RENDER_PHASE")
<p><em>Demo 3: Resource phase concepts and simple parameter passing to WCM app</em></p>
<h4><a href="${request.resource-url}">1. See what WCM App's RESOURCE_PHASE emits</a></h4>
<img style="float:right;" src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
## AJAXification with AUI and JSON parameters
#set ($pns = $request.portlet-namespace)
#if ($request.lifecycle == "RENDER_PHASE")
<body onload="${pns}doit()">
<p><em>Demo 4: AlloyUI AJAX call to WCM App, JSON parameters</em></p>
<p>
<a href="${request.resource-url}">See what WCM App's RESOURCE_PHASE emits</a>
## AJAXification with well-formed JSON result construction
## AJAXification with AUI and JSON parameters
#set ($pns = $request.portlet-namespace)
#if ($request.lifecycle == "RENDER_PHASE")
<body onload="${pns}doit()">
<p><em>Demo 5: AlloyUI AJAX call to WCM App, JSON parameters construcuted with JSONFactory</em></p>
## AJAXification with well-formed JSON result construction and parameter passing
#set ($pns = $request.portlet-namespace)
#if ($request.lifecycle == "RENDER_PHASE")
<body onload="${pns}doit()">
<img
src="http://www.liferay.com/osb-community-theme/images/custom/heading.png"
style="float:right;width:20%">
## AJAXification with well-formed JSON result construction and parameter passing
## Calling a Liferay JSON Web Service
#set ($pns = $request.portlet-namespace)
<body onload="${pns}doit()">
<p><em>Demo 7: Using Liferay JavaScript APIs</em></p>
<img src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
<div id="greeting"></div>
<p><em>Expando Demo 1: Creating and Reading Expando Data</em></p>
## get the static field constant for Expando String type.
## In freemarker, this is much easier:
## <#assign DATE = staticUtil["java.util.Calendar"].DATE>
#set ($expandoConstants = $portal.getClass().forName("com.liferay.portlet.expando.model.ExpandoColumnConstants"))
#set ($expandoConstantsInstance = $expandoConstants.newInstance())
#set ($stringType = $expandoConstants.getField("STRING").get($expandoConstantsInstance))
## create table