Saturday, February 25, 2017

Resource URL in Instantiable portlet

When ever we are using the Resource URL in Instantiable portlet, we face an issue that the parameters of  resource URL will be overrided that means last loaded portlet parameters will be overrides in all the portlets (Instantiable portlets)  to avoid this issue the below code will be help full for you.

Code :-

<portlet:resourceURL id="loadValues" var="myReourceURL" cacheability="cacheLevelPortlet" />

Below are the parameter for cacheability :-

FULL – The resource URL does not need to contain the current state of the page or the current render parameters, portlet mode, or window state of the portlet. Thus the portlet should not access the portlet mode, window state, or render parameters in the serveResource call.URLs of the type FULL have the highest cacheability in the browser as they do not depend on any state of the portlet or page.

PORTLET – The serveResource call triggered by a PORTLET resource URL does have access to the portlet state consisting of the render parameters, portlet mode and window state.URLs of the type PORTLET are cacheable on the portlet level in the browser and can be served from the browser cache for as long as the state of this portlet does not change

PAGE – The resource URL may contain artifacts that require knowledge of the state of the complete page, like PortletURLs, or resource URLs of type PAGE. The markup returned by such a resource URL may contain any portlet URL. Resource URLs of the type PAGE are only cacheable on the page level and can only be served from the browser cache as long as no state on the page changes.

Monday, January 9, 2017

How to get rid of no-reply@liferay.com in Liferay Kaleo workflow

When ever we work with Kaleo workflow in liferay, we will have a mail configuration in that. In Kaleo workflow it adds automatically 'no-reply@liferay.com' as the sender the email.If you want to change that, you can't... at least not directly through the UI of control panel.

The only way to change that email is modifying the XML file, you have to go to the workflow XML and change some things there. In the actions element, and above the notification element add a new action element like this:

<action>
    <name>setNotificationStuff onEntry</name>
    <script>

workflowContext.put(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"inthiyaz@liferay.com");  

workflowContext.put(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"IMTHU");

    </script>
    <script-language>javascript</script-language>
    <execution-type>onEntry</execution-type>
</action>

Thursday, January 5, 2017

Category checking to particular DLFile in liferay

This blog will help you to check the particular categorie assigned to DLFile or not, and also helps to fectch all the categories from database,

import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;

 List categoryList = null;
//Using dynamic query to fetch all the categories with the name "IMTHIYAZ"
DynamicQuery query = DynamicQueryFactoryUtil.forClass(AssetCategory.class).add(PropertyFactoryUtil.forName("name").eq("IMTHIYAZ"));
               categoryList = AssetCategoryLocalServiceUtil.dynamicQuery(query, 0,1);
//Result list contains all the list of AssetCategory Objects with the Name "IMTHIYAZ"

import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.asset.model.AssetEntry;

AssetEntry assetentry = null;
DLFileEntry fileEntryObj ; Assuming this object conatins file
//getting assetentry of particular file
 assetentry = AssetEntryLocalServiceUtil.getEntry( DLFileEntry.class.getName(), fileEntryObj.getPrimaryKey());
//fetching all categories of particular assetentry
long assetCategoryId[] = assetentry.getCategoryIds();
List assetCategories = assetentry.getCategories();
 if(assetCategories.contains(categoryList.get(0))){
//This file contains IMTHIYAZ category
}

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);


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. ...