passing URL parameter using command Button in jsf portal using Jsr 168

1.3k Views Asked by At

I am not able to receive parameter from the URl when I am calling another portlet using Command Button in Jsf in JSR 168. Actually I am calling the method of my manageBean from the Command Button where I am generating the URL, and calling another Portlet. But I am not able to receive the parameter in my another manageBean of the Called Portlet.

Can anyone please tell me where I go wrong.

1

There are 1 best solutions below

0
On

To retrieve JSR 168 Portlet URL Parameters; you have one of three choices (as far as I know):

  1. Creating a filter on Websphere Application Server level and configuring Dynamic Cache to store the query string then you will be able to get any parameter attached to any portlet generated link even without using URL mapping with taking in consideration the size of the Dynamic cache.

  2. You have to capture the parameter in the early portlet lifecycle phase which is called "doView" and by casting the RenderRequest to HttpServletRequest then you will be able to retrieve them from getQueryString() method (you will not be able to capture them from getParameter method of RenderRequest even though the specification mentioned that) and after that you can dispatch to any page in your application.

  3. The third way, if you try to generate a link to a portlet using URL Generation tags, you are allowed to add the parameter to that link and capture it in doView by the same way as below:

<wps:urlGeneration contentNode="MyApp.app"  portletWindowState="Maximized"  newWindow="True">
    <wps:urlParam name="MyParam"  value="Hi There"/> 
    <a href="<% wpsURL.write(out); %>" target="_blank" >My Link</a> 
</wps:urlGeneration>

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { 
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    System.out.println("The parameter is:  "+httpServletRequest.getQueryString());
    super.doView(request, response);    
}

Note: The complete code of your portlet lifecycle by default will be in a package com.ibm.{your project name} and RSA will ask you if you want it to be available or not at the beginning of the project creation and if you did not make it available you still can create it by overriding your <portlet-class> of your portlet in portlet.xml.