Foros de discusión

get portlet Id dynamically

neelam bhandari, modificado hace 12 años.

get portlet Id dynamically

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi ,
Is it possible to get portlet id dynamically by name or by some other way?

And if not , then is it possible to remove identifier from portlet name
for ex in the name propertyReceiver_WAR_Property_Reciever_INSTANCE_Im98 remove Im98 from the name

Neelam
thumbnail
srikanth a, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 144 Fecha de incorporación: 21/02/11 Mensajes recientes
Hi Neelam,
If you want get the portletId then i think you can try with getPortletId method of portalutil class.


regards
Sri
thumbnail
Raja Nagendra Kumar, modificado hace 12 años.

RE: get portlet Id dynamically

Expert Mensajes: 484 Fecha de incorporación: 2/03/06 Mensajes recientes
ThemeDisplay themeDisplay= (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay= themeDisplay.getPortletDisplay();
String portletId= portletDisplay.getId();

or


String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID);


or using PortalUtil..

You can instance ID from PortletRequest.getWindowID()

B.T.W for what are u suing this.. try to avoid it for building URL's on your own this way

Regards,
Raja Nagendra Kumar,
C,T.O
www,.tejasoft.com
-Liferay Adoption Excellence
neelam bhandari, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi,
Many thanks for your replies. I want the portlet id of one portlet on another page portlet. I am using PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(request),
"propertyReceiver_WAR_Property_Reciever_INSTANCE_Im98",plid, PortletRequest.RENDER_PHASE);

this url for redirection .But this identifier _Im98 will vary on different machine. On remote server again I will have to change the code.I am getting plid dynamically .But dont know
how to get portlet name.

Hope I have made myself clear.

Thanks
thumbnail
Pankaj Kathiriya, modificado hace 12 años.

RE: get portlet Id dynamically

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
Hi Neelam,

Do you want your custom portlet "Property_Reciever" as a instanciable.?

If no then you can make <instanceable>false </instanceable> in liferay-portlet.xml.
So it will not generate random post-fix to Portlet id like here in case its "lml8". and your portletid would remain only "propertyReceiver_WAR_Property_Reciever".

HTH,
Thanks,
Pankaj
neelam bhandari, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi Pankaj,
I have tried this approach. Portal adds this portlet id even if you make it instanceable false.

Is it possible in liferay to get portlet name from plid ?

Many thanks
Neelam Bhandari
thumbnail
srikanth a, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 144 Fecha de incorporación: 21/02/11 Mensajes recientes
Hi Neelam,
If there is no need to have your portlet instanceable then remove that configuration from the xml.
Try to get the portlet name and suffix with "_WAR_Property_Reciever".


regards
Sri
thumbnail
Raja Nagendra Kumar, modificado hace 12 años.

RE: get portlet Id dynamically

Expert Mensajes: 484 Fecha de incorporación: 2/03/06 Mensajes recientes
Did u try this

http://www.liferay.com/community/forums/-/message_boards/message/1557513

You can get PID from portlet ID like this..

long plid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletID);


Regards,
Nagendra
neelam bhandari, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi Nagendra,

I have got plid dynamically by using this line of code long plid=LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, "/results").getPlid();

but I want portlet id of another page portlet.

Thanks
Neelam
thumbnail
Raja Nagendra Kumar, modificado hace 12 años.

RE: get portlet Id dynamically

Expert Mensajes: 484 Fecha de incorporación: 2/03/06 Mensajes recientes
Could you explain the business need from what you would like to achieve..

Regards,
Nagendra
neelam bhandari, modificado hace 12 años.

RE: get portlet Id dynamically

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
I have page 1 which has Search portlet in it. and there is another page 2 which has results portlet.
When search is made in search portlet in page 1 results are displayed in results portlet on page 2 .
Previously I used Eventing for communication but that is creating trouble .
So in my controller, in search portlet, I am using code like this
PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(request),
"propertyReceiver_WAR_Property_Reciever_INSTANCE_Im98",plid, PortletRequest.RENDER_PHASE);
redirectURL.setParameter("region", request.getParameter("region"));
redirectURL.setParameter("startDate", startDate);
redirectURL.setParameter("endDate", endDate);
redirectURL.setParameter("rooms", request.getParameter("rooms"));
redirectURL.setParameter("days", Integer.toString(daysBetween(startCalendar.getTime(),endCalendar.getTime())));
response.sendRedirect(redirectURL.toString());


now i want this name of portlet to be dynamic.

Hope this makes sense.

Thanks
Neelam
thumbnail
Raja Nagendra Kumar, modificado hace 12 años.

RE: get portlet Id dynamically

Expert Mensajes: 484 Fecha de incorporación: 2/03/06 Mensajes recientes
Focusing on your business need.. you need IPC in the way, you would like to solve it.. My advise is don't invent new approaches as IPC is the standard way... then also it has issues..

To my knowledge, evening used with in the same page portlets and may be all the visible state portlets on a page.

When search portlet gets inputs from the user.. on what to search for.. such info should be stored in session or tread as public render parameter.. so that page 2 portlet can read this info and accordingly get the data from DB and present results.

See more about it at http://www.liferay.com/community/wiki/-/wiki/Main/portlet+to+portlet+communication

In my architectural view.. both search inputs and results display should happen by one portlet.. then only it can become a search portlet in complete.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
-Liferay Adoption Excellence
thumbnail
Murali Krishna, modificado hace 10 años.

RE: get portlet Id dynamically

Junior Member Mensajes: 47 Fecha de incorporación: 17/01/12 Mensajes recientes
neelam bhandari:
I have page 1 which has Search portlet in it. and there is another page 2 which has results portlet.
When search is made in search portlet in page 1 results are displayed in results portlet on page 2 .
Previously I used Eventing for communication but that is creating trouble .
So in my controller, in search portlet, I am using code like this
PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(request),
"propertyReceiver_WAR_Property_Reciever_INSTANCE_Im98",plid, PortletRequest.RENDER_PHASE);
redirectURL.setParameter("region", request.getParameter("region"));
redirectURL.setParameter("startDate", startDate);
redirectURL.setParameter("endDate", endDate);
redirectURL.setParameter("rooms", request.getParameter("rooms"));
redirectURL.setParameter("days", Integer.toString(daysBetween(startCalendar.getTime(),endCalendar.getTime())));
response.sendRedirect(redirectURL.toString());


now i want this name of portlet to be dynamic.

Hope this makes sense.

Thanks
Neelam


HI Neelam,

In portlet 1, you can set the public render parameter to share the object to portlet 2 and you also add the property of the render-weight of the portlet.

read the parameters in portlet 2 controller render method. I hope this helps.

Murali
thumbnail
Omkar Khandare, modificado hace 10 años.

RE: get portlet Id dynamically

Junior Member Mensajes: 49 Fecha de incorporación: 7/03/12 Mensajes recientes
neelam bhandari:
Hi Nagendra,

I have got plid dynamically by using this line of code long plid=LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, "/results").getPlid();

but I want portlet id of another page portlet.

Thanks
Neelam


Hi,

Have you any idea how to get plid in Velocity template (.vm) file.?

I have to get plid of my custom portlet for creating URL from menu link.
So i can open specific page of my portlet.

Please help.