Skip to content

Instantly share code, notes, and snippets.

@eduardolundgren
Created December 11, 2012 18:08
Show Gist options
  • Save eduardolundgren/4260723 to your computer and use it in GitHub Desktop.
Save eduardolundgren/4260723 to your computer and use it in GitHub Desktop.
Liferay JSON Web Services (Object Composition)

Liferay JSON Web Services

JSON RPC

/jsonws/calendar-portlet/calendar/get-calendar/calendar-id/10466

Simple JavaScript API

Liferay.Service('/calendar-portlet/calendar/get-calendar', { calendarId: 10466 });

Liferay JSON Web Services Object Composition

A simple Invoker call (recommended)

Basic request

Liferay.Service({
	'/calendar-portlet/calendar/get-calendar': {
		calendarId: 10466
	}
});

Nested requests

Liferay.Service({
	'$calendar = /calendar-portlet/calendar/get-calendar': {
		calendarId: 10466,

		'$bookings = /calendar-portlet/calendarbooking/get-calendar-bookings': {
			'@calendarId': '$calendar.calendarId',
			startDate: -1,
			endDate: -1
		}
	}
});

Filtering keys

Liferay.Service({
	'$calendar[calendarId, nameCurrentValue] = /calendar-portlet/calendar/get-calendar': {
		calendarId: 10466,

		'$bookings[titleCurrentValue] = /calendar-portlet/calendarbooking/get-calendar-bookings': {
			'@calendarId': '$calendar.calendarId',
			startDate: -1,
			endDate: -1
		}
	}
});

For more information, check http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/json-web-services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment