java Liferay以编程方式更改portlet列
我正在做一个Liferay门户,在Liferay布局中创建的不同列中有不同的Portlet
我的问题是:如何以编程方式(在java中)更改portlet所属的列
我试过这个:
long userId = themeDisplay.getUserId();
long groupId = themeDisplay.getLayout().getGroupId();
Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, true, currentFriendlyURL);
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
layoutTypePortlet.removePortletId(userId, iniPortletName);
String portletInstanceId = layoutTypePortlet.addPortletId(userId, iniPortletName, newColumn, position, true);
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings());
这是可行的,但使用这段代码,我删除了portlet,然后创建了一个新实例,我不希望这样
如何更新portlet的同一个实例的位置
谢谢
# 1 楼答案
好的,我找到了
如果希望保留相同的实例,可以使用movePortletId(userId、portletId、newColumn、position)方法
您需要使用portletId而不是portletName,它标识具有相同名称的所有Portlet
https://docs.liferay.com/portal/6.2/javadocs/src-html/com/liferay/portal/model/LayoutTypePortlet.html
谢谢