Fórum
Portlet Instance ID
Preben Ludviksen, modificado 16 Anos atrás.
Portlet Instance ID
New Member Postagens: 7 Data de Entrada: 07/11/07 Postagens Recentes
I'm making a portlet with some properties stored in a xml-file. I want to have unique settings for each instance of my portlet. Each instance obviously have an instance id, so I was just wondering how I can get this id in my code, as I need it to read/write the right properties?
Roman Hoyenko, modificado 16 Anos atrás.
RE: Portlet Instance ID
Liferay Master Postagens: 878 Data de Entrada: 08/10/07 Postagens Recentes
String portletId = portletDisplay.getId();
Lester Chua, modificado 15 Anos atrás.
RE: Portlet Instance ID
New Member Postagens: 4 Data de Entrada: 30/11/06 Postagens RecentesRoman Hoyenko:
String portletId = portletDisplay.getId();
And may I know what is "portletDisplay"?
For all I know it can be a variable for any bean in the world with a getId() method.
Is there a more concrete answer?
François Cassin, modificado 15 Anos atrás.
RE: Portlet Instance ID
New Member Postagens: 8 Data de Entrada: 23/09/08 Postagens Recentes
Hi Lester,
Have you tried this :
ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String portletId = portletDisplay.getId();
Where req is a RenderRequest.
Hope this helps
Have you tried this :
ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String portletId = portletDisplay.getId();
Where req is a RenderRequest.
Hope this helps
Luc Pons, modificado 15 Anos atrás.
RE: Portlet Instance ID
Junior Member Postagens: 70 Data de Entrada: 03/12/08 Postagens RecentesFrançois Cassin:
Hi Lester,
Have you tried this :
ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String portletId = portletDisplay.getId();
Where req is a RenderRequest.
Hope this helps
Hi,
I'm not sure of they way you meant your code, but it seemed to me that it fit my requirements.
I'm trying to develop a portlet which would add another portlet on the layout. I want then to get it's instanceId
I'm doing ...
//get the layout
Layout layout = LayoutLocalServiceUtil.getLayout(11131);
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
//Add the portlet
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
layoutTypePortlet.addPortletId(themeDisplay.getUserId(), "9");
//"save" the changes
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),
layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings());
[b]
//Your code
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String portletId = portletDisplay.getId();
System.out.println("l'id trouvé est : " + portletId);
[/b]
In the end, the portledId is the empty string ""
From there, i have a question
If we add two portlets on the layout, how coul we get the instanceIds ? Or maybe the portletDisplay.getId() returns the id of the last instance?
:/
Thx
Luc
Bob Baird, modificado 13 Anos atrás.
RE: Portlet Instance ID
New Member Postagens: 2 Data de Entrada: 09/02/11 Postagens Recentes
Using Liferay 6.0, I am looking to retrieve the portlet instance id for an instanceable portlet. I know this thread is old, but thought I'd reply to it since I didn't find a direct answer to my question after checking several search results. I am trying to display the instance id in an event processing method (IPC) to verify which instance of the portlet is receiving a particular event. After several rounds in my eclipse debugger, the following code does the trick:
String s = (String) request.getAttribute("PORTLET_ID");
request is the EventRequest parameter from the @ProcessEvent method, but the same code works using the RenderRequest parameter in the doView method as well.
Resulting instance id is the fully qualified instance id (portletId from the portletpreferences table.
Example: catcherportlet_WAR_ipcbaseballcatcherportlet_INSTANCE_Zxu7
Thx
String s = (String) request.getAttribute("PORTLET_ID");
request is the EventRequest parameter from the @ProcessEvent method, but the same code works using the RenderRequest parameter in the doView method as well.
Resulting instance id is the fully qualified instance id (portletId from the portletpreferences table.
Example: catcherportlet_WAR_ipcbaseballcatcherportlet_INSTANCE_Zxu7
Thx
Jignesh Vachhani, modificado 13 Anos atrás.
RE: Portlet Instance ID
Liferay Master Postagens: 803 Data de Entrada: 10/03/08 Postagens RecentesHi Bob
You can get portletpreference object anf through that object you can get portlet instance id.
See below code :
PortletPreferences preferences = renderRequest.getPreferences();
String portletResource = ParamUtil.getString(request, "portletResource");
if (Validator.isNotNull(portletResource)) {
preferences = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
}
Subhash Pavuskar, modificado 11 Anos atrás.
RE: Portlet Instance ID
Regular Member Postagens: 234 Data de Entrada: 13/03/12 Postagens Recentes
Hi all ,
How to get the portlet instance id which is inside the nested portlet.
I have a Nested portlet which contains couple of portlets(like Asset Pubisher and KB article).
From the Lay out i'm able to get the Nested Portlet Information. But i don;t know how to get the children's information which is inside the Nested Portelt. Please help me on this. Below is the code snippet i used to get the Nested Portelt Info from the LayOut.
How to get the portlet instance id which is inside the nested portlet.
I have a Nested portlet which contains couple of portlets(like Asset Pubisher and KB article).
From the Lay out i'm able to get the Nested Portlet Information. But i don;t know how to get the children's information which is inside the Nested Portelt. Please help me on this. Below is the code snippet i used to get the Nested Portelt Info from the LayOut.
Layout l=LayoutLocalServiceUtil.getLayout(themeDisplay.getPlid());
LayoutTypePortlet articleLayoutTypePortlet = (LayoutTypePortlet)l.getLayoutType();
List<portlet> allPortlets = articleLayoutTypePortlet.getAllPortlets(column);
for (Portlet p: allPortlets)
{
//System.out.println("Portlet Id is"+p.getRootPortletId());
if(PortletKeys.NESTED_PORTLETS.equals(p.getRootPortletId()))
{
//I'm able to come up to here. But don't know how to get children's information from this onwards.
}
}</portlet>