#TOC
- Invoking Liferay Services -
Liferay.Service
#TOC
Liferay.ServiceLiferay.Service(
'/user/get-user-by-email-address',
{
companyId: Liferay.ThemeDisplay.getCompanyId(),
emailAddress: '[email protected]'
},
function(obj) {
console.log(obj);
},
function(ex) {
console.log('exception: ' + ex);
}
);or
Liferay.Service(
{ '/user/get-user-by-email-address': {companyId: Liferay.ThemeDisplay.getCompanyId(),
emailAddress: '[email protected]'}
},
function(obj) {
console.log(obj);
},
function(ex) {
console.log('exception: ' + ex);
}
);Liferay.Service(
[
{
'/user/get-user-by-email-address': {
companyId: Liferay.ThemeDisplay.getCompanyId(),
emailAddress: '[email protected]'
}
},
{
'/role/get-user-roles': {
userId: Liferay.ThemeDisplay.getUserId()
}
}
],
function(obj) {
// obj is now an array of response objects
// obj[0] == /user/get-user-by-email-address data
// obj[1] == /role/get-user-roles data
console.log(obj);
},
function(ex) {
console.log('exception: ' + ex);
}
);Liferay.Service(
{
"$user = /user/get-user-by-id": {
"userId": Liferay.ThemeDisplay.getUserId(),
"$contact = /contact/get-contact": {
"@contactId": "$user.contactId"
}
}
},
function(obj) {
console.log(obj);
},
function(ex) {
console.log('exception: ' + ex);
}
);Not recommend to use on main thread.
Liferay.Service(
{'/user/get-user-by-email-address': {companyId: Liferay.ThemeDisplay.getCompanyId(),
emailAddress: '[email protected]'},
'io': {'sync': true}
},
function(obj) {
console.log(obj);
},
function(ex) {
console.log('exception: ' + ex);
}
);