如何从代码中以编程方式删除Liferay 6.1中的Portlet [英] How to delete a portlet in Liferay 6.1 programmatically from code
本文介绍了如何从代码中以编程方式删除Liferay 6.1中的Portlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Liferay 6.1
我想从代码中删除Liferay 6.1中的portlet.
到目前为止,我所做的是:
I'm working on Liferay 6.1
I want to delete a portlet in Liferay 6.1 from my code.
What I have done so far is:
<a onclick="Liferay.Portlet.close('#p_p_id_28_'); return false;">Remove</a>
以上代码运行正常.但是它仅在当前页面上起作用,即它可以删除仅在当前页面上存在的portlet.
Above code is working fine. But it is working on the current page only i.e. it can delete the portlet(s) which is there on the current page only.
但是我想使用其布局ID删除可能在门户菜单上某些位置的portlet.
But I want to delete the portlet(s) which could be some where on the menu of my portal using its layout id.
请提出一条出路. 预先感谢.
Please suggest a way out. Thanks in advance.
关于,
瓦伦·贾因(Varun Jain)
Regards,
Varun Jain
推荐答案
public void removePortlets(ActionRequest request, ActionResponse response)
throws PortletException {
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getScopeGroupId();
String friendlyURL = "/demochildpage";
boolean privateLayout = false;
long userId = themeDisplay.getUserId();
try {
Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(
groupId, privateLayout, friendlyURL);
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout
.getLayoutType();
layoutTypePortlet.removePortletId(userId, "28");
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),
layout.getPrivateLayout(), layout.getLayoutId(),
layout.getTypeSettings());
} catch (Exception e) {
e.printStackTrace();
}
}
这篇关于如何从代码中以编程方式删除Liferay 6.1中的Portlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文