Package org.apache.wicket.request

Examples of org.apache.wicket.request.UrlRenderer


    baseUrl.setProtocol("http");
    baseUrl.setHost("someHost");
    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    UrlRenderer renderer = new UrlRenderer(webRequest);

    RequestCycle requestCycle = mock(RequestCycle.class);
    ThreadContext.setRequestCycle(requestCycle);
    when(requestCycle.getUrlRenderer()).thenReturn(renderer);
View Full Code Here


    baseUrl.setProtocol("http");
    baseUrl.setHost("someHost");
    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    UrlRenderer renderer = new UrlRenderer(webRequest);

    RequestCycle requestCycle = mock(RequestCycle.class);
    ThreadContext.setRequestCycle(requestCycle);
    when(requestCycle.getUrlRenderer()).thenReturn(renderer);
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

        Request request = mock(Request.class);
        when(request.getCharset()).thenReturn(Charset.defaultCharset());
        when(requestCycle.getRequest()).thenReturn(request);

        UrlRenderer urlRenderer = mock(UrlRenderer.class);
        when(urlRenderer.renderContextRelativeUrl((any(String.class)))).thenReturn(RESOURCE_NAME);
        when(requestCycle.getUrlRenderer()).thenReturn(urlRenderer);

        ThreadContext.setRequestCycle(requestCycle);
    }
View Full Code Here

  @Override
  public String encodeRedirectURL(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.encodeRedirectURL(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

   * @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

    /*
     * 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())
View Full Code Here

  public void test10()
  {
    MockWebRequest request = new MockWebRequest(Url.parse("a/b/q/d/e"), "/contextPath",
      "/filterPath", "../");

    UrlRenderer r = new UrlRenderer(request);
    assertEquals("../../../../../", r.renderContextRelativeUrl(""));
    assertEquals("../../../../../", r.renderContextRelativeUrl("/"));
    assertEquals("../../../../../f", r.renderContextRelativeUrl("/f"));
    assertEquals("../../../../../../f", r.renderContextRelativeUrl("../f"));

    try
    {
      r.renderContextRelativeUrl(null);
      fail("Null 'url' is not allowed!");
    }
    catch (IllegalArgumentException iax)
    {
      assertTrue(true);
View Full Code Here

   * <a href="https://issues.apache.org/jira/browse/WICKET-3337">WICKET-3337</a>
   */
  @Test
  public void test11()
  {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("a")));
    assertEquals("./.", r1.renderUrl(Url.parse("")));
  }
View Full Code Here

   * <a href="https://issues.apache.org/jira/browse/WICKET-3567">WICKET-3567</a>
   */
  @Test
  public void test12()
  {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("?0")));
    assertEquals("./", r1.renderUrl(Url.parse("")));
  }
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.