Created
November 15, 2013 20:22
-
-
Save jamesfalkner/7490954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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> | |
<div id="rawdata"></div> | |
<script type="text/javascript"> | |
function ${pns}doit() { | |
Liferay.Service( | |
'/user/get-user-by-screen-name', | |
{ | |
companyId: '$getterUtil.getLong($companyId)', | |
screenName: 'test' | |
}, | |
function (user) { | |
document.getElementById('greeting').innerHTML = | |
'<h3>' + user.greeting + '</h3>'; | |
document.getElementById('rawdata').innerHTML = | |
'<pre>' + JSON.stringify(user) + '</pre>'; | |
}, function (err) { | |
console.log("uh oh!"); | |
} | |
); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment