Liferay.com

Tuesday, April 8, 2014

Alloy vs jQuery comparison links

Thursday, April 3, 2014

JSON object parameter passing

I came across a scenario where I need to use Liferay's JSON API for display certain no of documents under each folder depending upon configuration/preferences selected/set.

I need to display certain # of records order by modified date descending order

I didn't find a one workable example when I googled for certain time, here comes the savior - liferay documentation helped me in this regard to say frankly

https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/json-web-services

Here is the code snippet I used

        var groupId = '<%= themeDisplay.getLayout().getGroupId() %>';
        var folderNames = ["Folder 1", "Folder 2", "Folder 3"]; //The names of the folders you wish to pull from and display;
        var auth = "<%= AuthTokenUtil.getToken(request) %>"; //url to the file that prints out the p_auth token

        function ajax(url, func, type) {
            result = '';
            jQuery.ajax({
                type: 'GET',
                url: url,
                func: func,
                dataType: type,
                async: false,
                success: function (data) {
                    result = data;
                }
            });
            return result;
        }

        jQuery(document).ready(function () {
            var html = '';
            var quickHitshtml = '';
            var whitePapershtml = '';
            var noOfDocsToDisplay = '<%= noOfMarketCommentaryDocs %>'; // reading value from preferences
            jQuery.each(folders, function (i, item) {
                if (jQuery.inArray(item.name, folderNames) > -1) {
                    var files = ajax("/api/jsonws/dlapp/get-file-entries/repository-id/" + groupId + "/folder-id/" + item.folderId + "/start/0/end/" + noOfDocsToDisplay + "/+obc:com.liferay.portlet.documentlibrary.util.comparator.RepositoryModelModifiedDateComparator?p_auth=" + auth + "&callback=?", 'files', 'jsonp');
                }
            });
        });

please add relavent imports & porltet/theme should be loaded with jQuery

Liferay AUI 2.0 modules

Saturday, November 16, 2013

Some useful notes :)

p_p_lifecycle

p_p_lifecycle=0 > render url

p_p_lifecycle=1 > action url

p_p_lifecycle=2 > serveresource url



you might be have seen p_p_lifecycle in query string many times BUT might be not knowing exactly what is each value exactly mean

It is important to know what are the possible values for p_plifecycle & how they can be helpful, might be useful in forming friendly urls (of Freindly url routes feature of Liferay)

Liferay Sample plugins

For latest version of Liferay released you will have at

You will have plugins for other versions tagged appropriately here

Tuesday, November 12, 2013

Browsing through different Alloy UI versions documentation


As of writing this post we have 1.0.x, 15.x & 2.0.x Alloy UI versions available

For API documentation related to exach version you can browse as below

http://alloyui.com/api/ - This points to latest documentation always (which is 2.0.x)

http://alloyui.com/versions/1.0.x/api/

http://alloyui.com/versions/1.5.x/api/

How to navigate to different versions from http://alloyui.com/, you will some selectable kind of option at ALLOYUI as show below



Hope it helps some people who have hard time finding out AUI documentation

Using Liferay.provide - to add global java script function

An example function

Liferay.provide(window, 'existingUser', function(sessionId, buttonClicked) {
var A = AUI();

var hrefDefaultVal = A.one('#openServeyWindow').getAttribute('href');
var jsAtt = sessionId;
A.one('#openServeyWindow').setAttribute('href', hrefDefaultVal+jsAtt);

A.one('#openServeyWindow').setAttribute('onclick', "saveEntry('${count}','${newSessionIdPK}','${recentSessionIdPK}','"+buttonClicked+"' );");

if (navigator.appName == 'Microsoft Internet Explorer') {// as AUI simulate is not working in IE, handling through window.open
var elem = document.getElementById("openServeyWindow");
if (typeof elem.onclick == "function") {
   elem.onclick.apply(elem);
}
window.open(A.one('#openServeyWindow').getAttribute('href'));
}else{ // other browsers
// click working fine with below command for IE, redirect is not happening
A.one('#openServeyWindow').simulate('click');
}

closeRmiWindow();
window.location.replace('${lastAccessedPageUrl}'); // to redirect to previous page
},
['node-event-simulate']
);

Somehow this works well compared to (it seems because of lazy loading aui does with aui:script use attribute)
 
// whole function code from above

Wednesday, October 9, 2013

Fast Plugin Development (tomcat)


This is really useful when working on plugin development & making frequent changes to jsps/java files.

If you have Service builder as part of your plugin & you changed any of XXXLocalServiceImpl.java/XXXServiceImpl.java file(s) - after you re-run service builder, you may need to re-deploy/restart the server. Service builder re-run seems messes up context (with auto-reload)

I did used this setup long back though (5.2 EE sp3) BUT found this is very helpful

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Fast+Development+of+Liferay+Plugins+with+Tomcat

Njoy fast dev..ing