Hi All,
If we set url parameter value in normal jsp page like $some_url$?abc=ok. Then normally we can get value using request.getParameter("abc"); very simple.But in liferay I tried it was not working, then how to do in liferay?? not as simple as
request.getParameter("abc"); but little more code. Taking above example
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
String abc = httpReq.getParameter("abc");
So we will get desired result.
Hope this helps others.
9 comments:
For Struts potlet You can use:
ActionContext ctx = ActionContext.getContext();
PortletRequest req = (PortletRequest) ctx.get("struts.portlet.request");
return HttpServletRequest request = PortalUtil.getHttpServletRequest(req);
request.getParameter("id");
And "id" value will return.
Thanks to kamalkant.
Thanks, it's really helpful.
By the way, how do we return a specific page with some params (e.g: /some_page?param=abc) on a processAction?
e.g.
....
public void processAction(
ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
....
//bring me back to my profile with my uid with path as:
// /user-profile?uid=15
//setForward(actionRequest,"xxxx");
}
...
Hi HungPK,
have tried using actionResponse.setRenderParameter("abc", "abc"); this parameter once set u will get in render method like this String abc = renderRequest.getParameter("abc");
Hope this helps you
KamalKant
Thanks thanks!! Finally i find what i search :-))
Thanks! It works...
Thank you. Simple and it works :-)
Thank you. Simple and it works :-)
Thank you. Simple and it works! :-)
Thanks kamalkant rajput, it really help me :)
Post a Comment