29 December, 2014

Create UUID using ajax call

Below code represents, How to create UUID using  Liferay API with AJAX call :

In JSP File :
<portlet:resourceURL var="generateUUID" id="generateUUID"/>
<a href="javascript:void(0);" onclick="javascript:loadUUID();"> Generate UUID </a>

In JSP File (<aui:script>) :
var generateUUID = loadUUID();
    function loadUUID(){
     var uuid = "";
     A.io.request('${generateUUID}', {
                 method: 'POST',
                 dataType: 'json',
                 data: {
                     generateUUID: true
                 sync: true,
                 on: {
                     success: function() {
                     var test = this.get('responseData');
         uuid = test.uuid;  
                     failure: function() {
     return uuid;

In Controller Class :
 private String generateUUID()
        return UUID.randomUUID().toString();
In Controller Class  (ServeResource Method):
boolean generateUUID = ParamUtil.getBoolean(aResourceRequest, "generateUUID");
        if (generateUUID)
                    JSONFactoryUtil.createJSONObject().put("uuid", generateUUID().toString()));

Rate Me:

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...