liferayliferay-6portletjsr286

Liferay 6.2 PortletURL.setParameter() prepends underscores to parameter names


I am working on a project using Liferay 6.2 on JBoss ES 6.2. I need to be able to create a action URL inside an action method. The action method is looking up some data, building a JSONArray, and then setting an attribute equal to the resulting JSON string. Part of that JSON data needs an action url to another action within the same portlet.

The problem I am running into is that the generated URL seems to force any parameters I set include two underscores to the parameter name.

For instance:

PortletURL actionUrl = PortletURLFactoryUtil.create(actionRequest, portletId, plid, PortletRequest.ACTION_PHASE);
actionUrl.setPortletMode(LiferayPortletMode.VIEW);
actionUrl.setWindowState(WindowState.NORMAL);
actionUrl.setParameter("guid", guid);
actionUrl.setParameter("javax.portlet.action", "myAction");

Ends up generating something like:

http://localhost:8000/group/mySite/myPortlet?p_auth=fsdweD2&p_p_id=p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&__guid=1234567890&__javax.portlet.action=myAction

Notice the __guid and __javax.portlet.action. As a result, the portlet ends up running the doView() instead of myAction().

I have also tried to create a friendly url to solve the issue, but then I run into the issue of how to generate the friendly url with the proper site context AND the required p_auth value.


Solution

  • URL generated doesn't have portlet ID set properly as I see p_p_id is empty in URL. Please check if you are passing correct portlet ID.