Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2711

Wicket 1.4.5 + Websphere Portal Express 6.1: query string parameters are not forwarded through WicketPortlet

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 1.4.5
    • None
    • None
    • None
    • Windows XP SP3
      jdk1.5.0_15
      Wicket 1.4.5
      Spring 2.5.2
      Websphere Portal Express 6.1

    Description

      In my application, I am using portlet init parameter "viewPage" to define view page URL with query string parameter. For e.g.
      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
      <portlet>
      <description>My Test</description>
      <portlet-name>Test</portlet-name>
      <display-name>Test</display-name>
      <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
      <init-param>
      <name>wicketFilterPath</name>
      <value>/test</value>
      </init-param>
      <init-param>
      <name>viewPage</name>
      <value>/test?portletid=portlet1</value>
      </init-param>
      <supports>
      <mime-type>/</mime-type>
      <portlet-mode>VIEW</portlet-mode>
      </supports>
      <portlet-info>
      <title>Test Portlet</title>
      <keywords>Wicket</keywords>
      </portlet-info>
      </portlet>
      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      In my web.xml, I have filter mapping that maps "/test/*" to WicketFilter. The home page of my application displays appropriate contents on the basis of "portletid".

      This setup works fine with JBoss Portal 2.7.2, but with Websphere Portal Express 6.1, my home page never gets the "portletid" parameters.

      After investigation, it was realized that org.apache.wicket.protocol.http.portlet.PortletServletRequestWrapper has logic to obtain the querystring from wrapped request, but doesnt override methods getParameterMap / getParameters & getParameter to convert query string into parameters. I am not very sure whether Websphere Portal Server has any setting to do this conversion.

      Here is the workaround that I have used
      1. Created MyServletWebRequest that extends ServletWebRequest
      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
      public class MyServletWebRequest extends ServletWebRequest {
      private Map<String, String[]> paramMap;

      public MyServletWebRequest(HttpServletRequest httpServletRequest) {
      super(httpServletRequest);
      if (httpServletRequest instanceof PortletServletRequestWrapper) {
      String qs = this.getQueryString();
      if (StringUtil.hasLength(qs)) {
      paramMap = new HashMap<String, String[]>();
      StringTokenizer tokens = new StringTokenizer(qs, "&");
      while (tokens.hasMoreTokens()) {
      String tuple = tokens.nextToken();
      int index = tuple.indexOf("=");
      if (index != -1) {
      String key = tuple.substring(0, index);
      String value = tuple.substring(index + 1);
      paramMap.put(key, new String[]

      { value }

      );
      }
      }
      } else

      { paramMap = Collections.EMPTY_MAP; }

      }

      }

      @Override
      public Map getParameterMap()

      { Map<String, String[]> combinedMap = new HashMap<String, String[]>(super.getParameterMap()); combinedMap.putAll(paramMap); return combinedMap; }

      @Override
      public String getParameter(String key)

      { if (paramMap.containsKey(key)) return paramMap.get(key)[0]; return super.getParameter(key); }

      @Override
      public String[] getParameters(String key)

      { if (paramMap.containsKey(key)) return paramMap.get(key); return super.getParameters(key); }

      }
      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

      2. Then updated the MyWebApplication class (extends WebApplication) to override newWebRequest method
      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
      @Override
      protected WebRequest newWebRequest(HttpServletRequest servletRequest)

      { return new MyServletWebRequest(servletRequest); }

      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      That has solved the issue.

      I think PortletServletRequestWrapper should override getParameterMap / getParameters & getParameter methods.

      Attachments

        Issue Links

          Activity

            People

              ate Ate Douma
              uttam1105 Uttam Phalnikar
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 168h
                  168h
                  Remaining:
                  Remaining Estimate - 168h
                  168h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified