You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Skip Dever (JIRA)" <ji...@apache.org> on 2013/06/12 00:33:19 UTC

[jira] [Created] (OFBIZ-5220) request-redirect does not pass all parameters if none are specified with response-parameter

Skip Dever created OFBIZ-5220:
---------------------------------

             Summary: request-redirect does not pass all parameters if none are specified with response-parameter
                 Key: OFBIZ-5220
                 URL: https://issues.apache.org/jira/browse/OFBIZ-5220
             Project: OFBiz
          Issue Type: Bug
          Components: ALL APPLICATIONS
    Affects Versions: Release Branch 12.04
         Environment: All
            Reporter: Skip Dever


The xsd documentation says "Automatically redirect all current request parameters to the new request or only redirected ..."

This is broken.  If you specify a request-redirect from a form (where the parameters are not in the url), these parameters are not passed on to the redirected url. 

Included here is a re-written function in RequestHandler.java is a solution that fixes things (Note that I did not modify the javadoc which describes how this new function actually works).  I commented out the old code and added there new stuff under the comment:

    /**
     * Creates a query string based on the redirect parameters for a request response, if specified, or for all request parameters if no redirect parameters are specified.
     *
     * @param request the Http request
     * @param requestResponse the RequestResponse Object
     * @return return the query string
     */
    public String makeQueryString(HttpServletRequest request, ConfigXMLReader.RequestResponse requestResponse) {
        if (requestResponse == null ||
                (requestResponse.redirectParameterMap.size() == 0 && requestResponse.redirectParameterValueMap.size() == 0)) {
			/* Modified by skipd to include all parameters if none are specified with redirect-parameter
            Map<String, Object> urlParams = UtilHttp.getUrlOnlyParameterMap(request);
            String queryString = UtilHttp.urlEncodeArgs(urlParams, false);
            if(UtilValidate.isEmpty(queryString)) {
                return queryString;
            }
			*/
            StringBuilder queryString = new StringBuilder();
            Map<String, Object> parameters = UtilHttp.getParameterMap(request);
            for (String parameterName: parameters.keySet()) {
                Object value = parameters.get(parameterName);

                addNameValuePairToQueryString(queryString, parameterName, (String) value);
            }
            return "?" + queryString;
        } else {
            StringBuilder queryString = new StringBuilder();
            queryString.append("?");
            for (Map.Entry<String, String> entry: requestResponse.redirectParameterValueMap.entrySet()) {
                String name = entry.getKey();
                String value = entry.getValue();

                addNameValuePairToQueryString(queryString, name, (String) value);
            }
            return queryString.toString();
        }
    }


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira