掲示板

[SOLVED] Adding Portlet, and get corresponding Resource

thumbnail
15年前 に Luc Pons によって更新されました。

[SOLVED] Adding Portlet, and get corresponding Resource

Junior Member 投稿: 70 参加年月日: 08/12/03 最新の投稿
Hi everyone,

I'm adding a portlet in liferay :


 LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
 String instanceId = layoutTypePortlet.addPortletId(themeDisplay.getUserId(), 
 LayoutLocalServiceUtil.updateLayout(layout);



This works fine.

But now, I want to get the corresponding Resource.
So i proceed this way :

 
Resource resource = ResourceLocalServiceUtil.getResource(ResourceLocalServiceUtil.getLatestResourceId());


This won't give me the corresponding resource, it will give me the resource corresponding to two portlets before.

In another way, if I create several portlets, it will go :


createPortlet ---> primary key : C
lastResource --> primary key : A

createPortlet ---> primary key : D
lastResource --> primary key : B

createPortlet ---> primary key : E
lastResource --> primary key : C

createPortlet ---> primary key : F
lastResource --> primary key : D

createPortlet ---> primary key : G
lastResource --> primary key : E


This is really annoying.
Plus, if I try to use the getResource(long companyId, java.lang.String name, int scope, java.lang.String primKey)
the problem is still there, ie, the ressource wont be availaible till i create two more portlets...


Is there anything i can do ?

Luc
thumbnail
15年前 に Luc Pons によって更新されました。

RE: Adding Portlet, and get corresponding Resource

Junior Member 投稿: 70 参加年月日: 08/12/03 最新の投稿
I found out something else....



Actually, the resource corresponding to the newly created portled is available in the database only after refreshing the page
(in my case, after adding another portlet)


Is there something to do to refresh the page in the code ?

The "updateLayout' doesnt seem to do any good....

u_u
thumbnail
15年前 に Luc Pons によって更新されました。

RE: Adding Portlet, and get corresponding Resource

Junior Member 投稿: 70 参加年月日: 08/12/03 最新の投稿
After adding a portlet, it is possible to get the corresponding resource available wihtout refreshing the page throug a web browser;

The needed method is


ResourceLocalService.addResources(long companyId, long groupId, long userId, String name, long primKey, boolean portletActions, boolean addCommunityPermissions, boolean addGuestPermissions)

15年前 に Jesús Alberto de los Bueis Fernández によって更新されました。

RE: Adding Portlet, and get corresponding Resource

New Member 投稿: 8 参加年月日: 09/01/13 最新の投稿
Very insteresting

I´m develop a tool for adding pages with portlets to Liferay communty. Could you share your code?

thx
thumbnail
15年前 に Luc Pons によって更新されました。

RE: Adding Portlet, and get corresponding Resource

Junior Member 投稿: 70 参加年月日: 08/12/03 最新の投稿
Well, almost everything is there, in the first message,

you have to use the last described method to manage the permissions...


Feel free to ask anything about it,

Good luck
thumbnail
13年前 に Amit Singh によって更新されました。

RE: Adding Portlet, and get corresponding Resource

Junior Member 投稿: 71 参加年月日: 10/10/12 最新の投稿
Hi Pons,

I am also looking for add portlet without refreshing the paage. Please provide me the sample code to add portlet without refreshing the page.

Thanks in advance.