Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Mohammad Azharuddin
Portlet URL
December 7, 2013 1:30 AM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

HI all
i'm creating actionURL via PortletURL myURL = PortletURLFactoryUtil.create(.......) ; Api....

In my application i'm creating new instance dynamically....and In new instance above URL is not working for the first time.....


What might be the problem
Andrew Jardine
RE: Portlet URL
December 8, 2013 8:27 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

What does the full set of your code look like? here is an example that I use --

 1
 2        Layout layout = LayoutLocalServiceUtil.getFriendlyURL( themeDisplay.getScopeGroupId(), false, "/your/url/here");
 3        long plid = layout.getPlid();
 4        String portletID = "[portletname]_WAR_[deploymentcontext]";   //eg. mybookmarks_WAR_mybookmarksportlet
 5
 6    PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletID, plid, PortletRequest.ACTION_PHASE);
 7    portletURL.setWindowState(WindowState.MAXIMIZED);
 8    portletURL.setPortletMode(PortletMode.VIEW);
 9        portletURL.setParameter("var1", "value1");
10        portletURL.setParameter("var2", "value2");
11        portletURL.setParameter("var3", "value3");
12...   


This is assuming that you don't want to use a portlet in the same layout. If you do then you can get the plid from the ThemeDisplay. The key here is the ACTION_PHASE which will tell the portlet to start there and not in the RENDER_PHASE.
Mohammad Azharuddin
RE: Portlet URL
December 8, 2013 10:17 PM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

Thanks for your reply emoticonemoticonemoticon

I'm using same logic to create the URL....As i mentioned it is not working for the first time when i create new instance dynamically....second time it is Working


Yes it is not in same layout..and i'm using correct layout id
Meera Prince
RE: Portlet URL
December 9, 2013 2:10 AM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

HI

If it is multiple instance portlet then portlet id will contains _INSTANCE_A2s

like we have some pastern

example:
p_p_id=PortletX_WAR_OpenPortletAuiDialgportlet_INSTANCE_NVvxP2fkEI9Z


URL as Follows

http://localhost:8080/web/guest/home?p_p_id=PortletX_WAR_OpenPortletAuiDialgportlet_INSTANCE_NVvxP2fkEI9Z&p_p_lifecycle=0&p_p_state=maximized&p_p_state_rcv=1&p_p_col_id=column-1&p_p_col_count=5

So you need create instance Id dynamically i think...

You have look at following link

http://www.liferaysavvy.com/2013/11/working-with-liferay-urls.html


Regards,

Meera Prince
http://www.liferaysavvy.com
Mohammad Azharuddin
RE: Portlet URL
December 9, 2013 9:27 AM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

HI prince

I'm creating new instance via liferay API dynamically....So when i create new instance, the URL is not working for the first time....I put SYSOUT in my action class to check wethr it is coming to ProcessAction method...But it is not coming..but it is redirecting to that layout


When i try for the second time it is working as expected...It is not going to processAction only at first try after creating new instance.....

My question is why it is not hitting processAction at very first time