I have a liferay portlet instance created dynamically and added to the layout programatically as follows
String portletId = objUtil.addPortlet("/prj/reports", "XYZPortlet_WAR_ecpmportlet", "column-2",groupId, "type: " + getSelectedType());
So it adds a portlet to the /reports
page.
I want to add a button below the portlet called send to dashboard on clicking the button I want to install this portlet to the user dashboard permanently.
Note: There can any number of portlet instances added to the /report
s page.
As you see XYZPortlet is the id of the portlet defined in liferay-portlet.xml, liferay-display.xml which remains same for all the portlets I add to the reports page.
I want to dynamically assign a new Id to the portlet instance and install it permanently to the dashboard layout.
Can anyone please suggest a way to do this?
Thanks
Simple get the global portletId and add it to user home page:
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) userlayout.getLayoutType();
String portletInstanceId = layoutTypePortlet.addPortletId(0, portletId, columnId, -1, false);
LayoutLocalServiceUtil.updateLayout(userlayout.getGroupId(), userlayout.isPrivateLayout(), userlayout.getLayoutId(), userlayout.getTypeSettings());