[jbossseam-issues] [JBoss JIRA] Assigned: (JBSEAM-1719) UrlBuilder doesnt construct a correct url when the base url already has request params in place.

Pete Muir (JIRA) jira-events at lists.jboss.org
Wed Jul 25 17:45:47 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBSEAM-1719?page=all ]

Pete Muir reassigned JBSEAM-1719:
---------------------------------

    Assignee: Pete Muir

> UrlBuilder doesnt construct a correct url when the base url already has request params in place.
> ------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-1719
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1719
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0.BETA1
>            Reporter: Chris Rudd
>         Assigned To: Pete Muir
>
> Given the following test case :
> @Test
> public void testBaseUrlAlreadyHasParams()
> {
>    UrlBuilder url = new UrlBuilder("/someurl?arg1=a", "");
>    url.addParameter("foo", "bar");
>    String encodedUrl = url.getEncodedUrl();
>    Assert.assertEqual( encodedUrl, "/someurl?arg1=a&foo=bar" );
> }
> The following patch fixes the issue.
> UrlBuilder.java line 62
> protected String getParametersAsString()
> {
>      String params = "";
>      for (String key : parameters.keySet())
>      {
>          params += "&" + key + "=" + parameters.get(key);
>      }
> -   if (!"".equals(params))
> +  // repace the first "&" with a "?" if there are parameters and the url doesnt already contain a "?"
> +  if (!".equals(params) && (url!=null && !url.contains("?")))
>      {
>          params = "?" + params.substring(1);
>      }
>      return params;
> }
> NOTE: This condition occurs when using <s:link/> in a portlet, as the portlet returns a url with parameters already added to the url.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list