Commits

plightbo  committed da2663c

WW-671: includeParams works when value is not specified

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@600573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits aee23b7

Comments (0)

Files changed (2)

File src/java/com/opensymphony/webwork/views/jsp/URLTag.java

 
         //no explicit url set so attach params from current url, do
         //this at start so body params can override any of these they wish.
-        if (value == null) {
-            try {
-                if (params == null) {
-                    params = new HashMap();
-                }
+        try {
+            if (params == null) {
+                params = new HashMap();
+            }
 
-                String includeParams = null;
+            String includeParams = null;
 
-                if (includeParamsAttr != null) {
-                    includeParams = findString(includeParamsAttr);
-                }
-
-                if ((includeParams == null) || includeParams.equals(GET)) {
-                    // Parse the query string to make sure that the parameters come from the query, and not some posted data
-                    HttpServletRequest req = ((HttpServletRequest) pageContext.getRequest());
-                    String query = req.getQueryString();
+            if (includeParamsAttr != null) {
+                includeParams = findString(includeParamsAttr);
+            }
 
-                    if (query != null) {
-                        // Remove possible #foobar suffix
-                        int idx = query.lastIndexOf('#');
+            if ((includeParams == null && value == null) || GET.equals(includeParams)) {
+                // Parse the query string to make sure that the parameters come from the query, and not some posted data
+                HttpServletRequest req = ((HttpServletRequest) pageContext.getRequest());
+                String query = req.getQueryString();
 
-                        if (idx != -1) {
-                            query = query.substring(0, idx - 1);
-                        }
+                if (query != null) {
+                    // Remove possible #foobar suffix
+                    int idx = query.lastIndexOf('#');
 
-                        params.putAll(HttpUtils.parseQueryString(query));
+                    if (idx != -1) {
+                        query = query.substring(0, idx - 1);
                     }
-                } else if (includeParams.equals(ALL)) {
-                    params.putAll(pageContext.getRequest().getParameterMap());
-                } else if (!includeParams.equals(NONE)) {
-                    LOG.warn("Unknown value for includeParams parameter to URL tag: " + includeParams);
+
+                    params.putAll(HttpUtils.parseQueryString(query));
                 }
-            } catch (Exception e) {
-                LOG.warn("Unable to put request parameters (" + ((HttpServletRequest) pageContext.getRequest()).getQueryString() + ") into parameter map.", e);
+            } else if (ALL.equals(includeParams)) {
+                params.putAll(pageContext.getRequest().getParameterMap());
+            } else if (!NONE.equals(includeParams)) {
+                LOG.warn("Unknown value for includeParams parameter to URL tag: " + includeParams);
             }
+        } catch (Exception e) {
+            LOG.warn("Unable to put request parameters (" + ((HttpServletRequest) pageContext.getRequest()).getQueryString() + ") into parameter map.", e);
         }
 
         return EVAL_BODY_BUFFERED;

File src/test/com/opensymphony/webwork/views/jsp/URLTagTest.java

     public void testAddParameters() {
         request.setAttribute("webwork.request_uri", "/Test.action");
 
-        jspWriter.setExpectedData("/TestAction.action?param2=value2&param1=value1");
+        jspWriter.setExpectedData("/TestAction.action?param2=value2&param0=value0&param1=value1");
         request.setAttribute("webwork.request_uri", "/TestAction.action");
-        request.setQueryString("TestAction.action");
+        request.setQueryString("param0=value0");
 
         try {
             tag.doStartTag();