Java Liferay-以编程方式更改portlet列
我正在做一个Liferay门户,在Liferay布局中创建的不同列中有不同的portlet 我的问题是:如何以编程方式(在java中)更改portlet所属的列 我试过这个:Java Liferay-以编程方式更改portlet列,java,liferay,portlet,Java,Liferay,Portlet,我正在做一个Liferay门户,在Liferay布局中创建的不同列中有不同的portlet 我的问题是:如何以编程方式(在java中)更改portlet所属的列 我试过这个: long userId = themeDisplay.getUserId(); long groupId = themeDisplay.getLayout().getGroupId(); Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId
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的相同实例的位置
谢谢。好的,我找到了
如果希望保留相同的实例,可以使用movePortletId(userId、portletId、newColumn、position)方法
您需要使用portletId而不是portletName,它标识具有相同名称的所有Portlet
谢谢。我觉得太宽了。作为一个问题,您只是在问XYZ是否可行。很可能是这样。你有代码给我们看吗?有错误信息吗?你试过什么?(不仅仅是理论上的工作)对不起。我希望现在已经清楚了。
String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID);
layoutTypePortlet.movePortletId(userId, portletId, finColumn, position);