Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: action phase render parameter gets overwritten
Philippe Thibault, modificado hace 7 años.
Junior Member
Mensajes: 46
Fecha de incorporación: 11/09/12
Mensajes recientes
Hi,
I have come up with a situation where a parameter I set in action phase to go to render is overwritten back to the value previously set in the request that called the action. Here is an example of what I'm saying:
In my view.jsp I create the actionURL with a parameter:
In the portlet code action method I set this parameter to another value for the render phase :
What I get in render phase after action phase is that parameter named "P" value is "from_view_jsp", when I expected it to be "from_action" as set in action.
Are my expectation wrong, or is it a bug? Are request parameter copied back after action phase for render and overwritting my parameter setting?
thanks for your help
Phil
I have come up with a situation where a parameter I set in action phase to go to render is overwritten back to the value previously set in the request that called the action. Here is an example of what I'm saying:
In my view.jsp I create the actionURL with a parameter:
<portlet:actionurl name="myaction" var="myactionURL">
<portlet:param name="P" value="from_view_jsp" />
</portlet:actionurl>
In the portlet code action method I set this parameter to another value for the render phase :
public void myaction (ActionRequest actionRequest, ActionResponse actionResponse) {
actionResponse.setRenderParameter("P", "from_action");
}
What I get in render phase after action phase is that parameter named "P" value is "from_view_jsp", when I expected it to be "from_action" as set in action.
Are my expectation wrong, or is it a bug? Are request parameter copied back after action phase for render and overwritting my parameter setting?
thanks for your help
Phil
asha ramoliya, modificado hace 7 años.
New Member
Mensajes: 5
Fecha de incorporación: 24/05/18
Mensajes recientes
Hi,
Did you try following code to get value in render method?
1)renderRequest.getParameter("P");
2)If you can access ParamUtil,try ParamUtil.getString(renderRequest,"P");
Did you try following code to get value in render method?
1)renderRequest.getParameter("P");
2)If you can access ParamUtil,try ParamUtil.getString(renderRequest,"P");
Philippe Thibault, modificado hace 7 años.
Junior Member
Mensajes: 46
Fecha de incorporación: 11/09/12
Mensajes recientes
Hi asha,
Yes I am looking at request parameter in render method. I am looking at the complete map like this :
As for using ParamUtil.getString() it is the same as expected since this is just a wrapper around renderRequest.getParameter().
So, any idea why my parameters are overwritten after action phase? Is there any "behind the scene" copying of request parameter back to render phase going on?
Yes I am looking at request parameter in render method. I am looking at the complete map like this :
@Override
public void doView (RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException
{
System.err.println ("renderRequest parameter map:");
Map<string, string[]> pmap = renderRequest.getParameterMap ();
for (Map.Entry<string, string[]> entry : pmap.entrySet ())
{
System.err.println (String.format ("renderRequest parametermap %s -- %s", entry.getKey (), Arrays.toString (entry.getValue ())));
}
super.doView (renderRequest, renderResponse);
}
</string,></string,>As for using ParamUtil.getString() it is the same as expected since this is just a wrapper around renderRequest.getParameter().
So, any idea why my parameters are overwritten after action phase? Is there any "behind the scene" copying of request parameter back to render phase going on?
Philippe Thibault, modificado hace 7 años.
Junior Member
Mensajes: 46
Fecha de incorporación: 11/09/12
Mensajes recientes
anyone have a guess at why a request paramater I change value with setRenderparameter() gets overwritten back to the request original value?
Minhchau Dang, modificado hace 7 años.
Liferay Master
Mensajes: 598
Fecha de incorporación: 22/10/07
Mensajes recientes
Philippe Thibault:anyone have a guess at why a request paramater I change value with setRenderparameter() gets overwritten back to the request original value?
If your portlet class extends Liferay's MVCPortlet, it has code that
specifically copies
action parameters, if the init-param
copy-request-parameters is not explicitly set to false
(default
is true).
Philippe Thibault, modificado hace 7 años.
Junior Member
Mensajes: 46
Fecha de incorporación: 11/09/12
Mensajes recientes
Thanks Minhchau that's the answer I was looking for. Another pitfall for me to fall into ...
Community
Company
Feedback