Tuesday, January 3, 2017

How to use orderbycomparator in liferay

Liferay provides one of the beautiful API is "orderbycomparator ", this api will work as "Order By" keyword in database, let see the example how to utilize this API.

import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;

//Fetching the DLFiles order by create date
OrderByComparator comparator = OrderByComparatorFactoryUtil.create("DLFileEntry", "createDate/modifiedDate", true/false);

Note :- createDate / modifiedDate should be your column name of your table.

 Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(),parentFolderId,-1, -1, comparator);

//Fetching the custom table vlaues order by title
OrderByComparator comparator = OrderByComparatorFactoryUtil.create(customModelImpl.TABLE_NAME, "title", true);


1 comment:

Avishek Priyadarshi said...

I really appreciate the information shared above. It’s of great help. MaxMunus provides Remote Support For Corporate and for Individuals. If anyone is facing any issue in his project of #LIFERAY we can support them remotely , kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Industry best Consultant on #LIFERAY. We provide end to end Remote Support on Projects. MaxMunus is successfully doing remote support for countries like India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain, and UAE etc.
Avishek Priyadarshi
MaxMunus
E-mail: avishek@maxmunus.com
Skype id: avishek_2.
Ph:(0) 8553177744 / 080 - 41103383
http://www.maxmunus.com

Liferay DXP JNDI Data Source Cofiguration

 This Blog will help us to learn about the JNDI Data Source Configuration in Liferay DXP. We have tested this with Liferay 7.3 with Tomcat. ...