掲示板

how to add portlet programmatically from java class?

12年前 に Dima Bershov によって更新されました。

how to add portlet programmatically from java class?

New Member 投稿: 1 参加年月日: 11/09/08 最新の投稿
I trying add portlet from java class but ids all portlets always equals 0(number). Am i doing anything wrong. please explain me. code:
ServiceContext serviceContext = new ServiceContext();
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
Layout layout;
LayoutTypePortlet layoutTypePortlet;

try {
layout = LayoutLocalServiceUtil.addLayout(Long.parseLong(actionRequest.getRemoteUser()), //userId
themeDisplay.getLayout().getGroupId(), //groupId
false, //privateLayout
0, //parentLayoutId
"main", //name
"title", //title
"descrioption", //description
"portlet", //type
false, //hidden
"/main", //friendlyURLs
serviceContext);
layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
for (Portlet portlet : PortletLocalServiceUtil.getPortlets()){
if (portlet.getDisplayName().equalsIgnoreCase("message")){
layoutTypePortlet.addPortletId(Long.parseLong(portlet.getId());
}
}
} catch ......