Package org.apache.wicket.request

Examples of org.apache.wicket.request.UrlRenderer


    Url baseUrl = Url.parse("a/b/c/d"); // base url without context path and filter path
    Url encodedFullUrl = Url.parse("http://host:8080/filter/path/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setFilterPath("filter/path");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here


    Url baseUrl = Url.parse("a/b/c/d"); // base url without context path and filter path
    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("contextPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here

    Url baseUrl = Url.parse("a/b/c/d"); // base url without context path and filter path
    Url encodedFullUrl = Url.parse("http://host:8080/context/path/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("context/path");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here

    // here 'contextPath' is the actual context path and should be ignored
    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("contextPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here

    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("contextPath");
    request.setFilterPath("filterPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here

    // here 'filterPath' is the actual filter path and should be ignored
    Url encodedFullUrl = Url.parse("http://host:8080/filterPath/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setFilterPath("filterPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
  }
View Full Code Here

   * @return a new url renderer
   */
  protected UrlRenderer newUrlRenderer()
  {
    // All URLs will be rendered relative to current request (can be overridden afterwards)
    return new UrlRenderer(getRequest());
  }
View Full Code Here

  @Override
  public String encodeURL(CharSequence url)
  {
    Args.notNull(url, "url");

    UrlRenderer urlRenderer = getUrlRenderer();

    Url originalUrl = Url.parse(url);

    /*
      WICKET-4645 - always pass absolute url to the web container for encoding
      because when REDIRECT_TO_BUFFER is in use Wicket may render PageB when
      PageA is actually the requested one and the web container cannot resolve
      the base url properly
     */
    String fullUrl = urlRenderer.renderFullUrl(originalUrl);
    String encodedFullUrl = httpServletResponse.encodeURL(fullUrl);

    final String encodedUrl;
    if (originalUrl.isFull())
    {
      encodedUrl = encodedFullUrl;
    }
    else
    {
      if (fullUrl.equals(encodedFullUrl))
      {
        // no encoding happened so just reuse the original url
        encodedUrl = url.toString();
      }
      else
      {
        // get the relative url with the jsessionid encoded in it
        Url _encoded = Url.parse(encodedFullUrl);
        encodedUrl = urlRenderer.renderRelativeUrl(_encoded);
      }
    }
    return encodedUrl;
  }
View Full Code Here

  private UrlRenderer getUrlRenderer()
  {
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle == null)
    {
      return new UrlRenderer(webRequest);
    }
    return requestCycle.getUrlRenderer();
  }
View Full Code Here

    /*
     * since the passed in url is handled when the current url is form's action url and not the
     * current request's url we rerender the passed in url to be relative to the form's action
     * url
     */
    UrlRenderer renderer = getRequestCycle().getUrlRenderer();
    Url oldBase = renderer.getBaseUrl();
    try
    {
      Url action = Url.parse(getActionUrl().toString());
      renderer.setBaseUrl(action);
      url = renderer.renderUrl(Url.parse(url.toString()));
    }
    finally
    {
      renderer.setBaseUrl(oldBase);
    }

    Form<?> root = getRootForm();
    return new AppendingStringBuffer("document.getElementById('")
      .append(root.getHiddenFieldId()).append("').value='").append(url)
View Full Code Here

TOP

Related Classes of org.apache.wicket.request.UrlRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.