Skip to main content

Posts

Showing posts from 2015

Dynamic Query with PortletClassLoader using PortletBeanLocatorUtil

Hello, Recently I faced some issue with dynamic query. Even though my service layer and Portlet are in the same war  I got class not found exception for the model class. Liferay could not able to load Model class while using the dynamic query So I used the Portlet Class loader like below.                Then my issue got resolved.

Checking in Liferay permissions for a User in JSON WS or in a normal Java Class

Hello, In this post we will see how to check if a user has a specific permission assigned to him. If you want to do it in a JSP you can use the below code. In JSP permissionChecker,layout and portletroot id objects are implicitly available. boolean showOwnerType = PortletPermissionUtil.contains(permissionChecker, layout, portletDisplay.getRootPortletId(), “your permission name”); Suppose if you want to do it in a class which does not have these implicit objects or it does not have access to HttpServletRequest or PortletRequest then you can use the below code. PermissionChecker permissionChecker =PermissionThreadLocal. getPermissionChecker (); boolean status = PortletPermissionUtil. contains ( permissionChecker , “your portlet root id”, “your permission” ); You can find the portlet root id from Liferay page. Goto the page where the portlet resides and click on Settings icon- > Look and Feel -> and goto Advanced Styling tab. There you can see the p...

Sending List and Map values to Liferay JSON WebService

If you want to pass a list object or map object to a Liferay JSON WebService use the below code Sending a List of String and getting it in the ServiceLayer: Use the below code in the ServiceImpl public List getList(List list ){        System. out .println( "list: " + list );        return list ; }        From browser use the link like below to send the list object http://localhost:8080/api/jsonws/MyPortlet.myview/get-list/list /["Liferay","WebSphere","SAP"] And you  can see the output like below Sending a Map of String,String object and getting it in the ServiceLayer: Use the below code in the ServiceImpl public Map getMap(Map map ){        System. out .println( map .size());        Set keySet = map .keySet();        Iterator itrtr = k...