Examples of UrlRenderer


Examples of org.apache.wicket.request.UrlRenderer

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

Examples of org.apache.wicket.request.UrlRenderer

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

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

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

Examples of org.apache.wicket.request.UrlRenderer

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

Examples of org.apache.wicket.request.UrlRenderer

        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

Examples of org.apache.wicket.request.UrlRenderer

  @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

Examples of org.apache.wicket.request.UrlRenderer

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

Examples of org.apache.wicket.request.UrlRenderer

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

Examples of org.apache.wicket.request.UrlRenderer

  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
TOP
Copyright © 2018 www.massapi.com. 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.