Package org.apache.wicket.request

Examples of org.apache.wicket.request.Url

The Url class takes care of encoding and decoding of the segments and parameters. @author Matej Knopp @author Igor Vaynberg

   * ignored
   */
  @Test
  public void decodeUrlWithTrailingSlash()
  {
    Url url = Url.parse("name1/value1/name2/value2/");

    UrlPathPageParametersEncoder decoder = new UrlPathPageParametersEncoder();
    PageParameters parameters = decoder.decodePageParameters(url);

    assertEquals(2, parameters.getAllNamed().size());
View Full Code Here


   * ignored
   */
  @Test
  public void decodeUrlWithTrailingSlashAfterName()
  {
    Url url = Url.parse("name1/value1/name2/value2/name3");

    UrlPathPageParametersEncoder decoder = new UrlPathPageParametersEncoder();
    PageParameters parameters = decoder.decodePageParameters(url);

    assertEquals(2, parameters.getAllNamed().size());
View Full Code Here

   * Decode encoded parameters with a leading slash. The empty name segment should be ignored.
   */
  @Test
  public void decodeUrlWithLeadingSlash()
  {
    Url url = Url.parse("/name1/value1/name2/value2");

    UrlPathPageParametersEncoder decoder = new UrlPathPageParametersEncoder();
    PageParameters parameters = decoder.decodePageParameters(url);

    assertEquals(2, parameters.getAllNamed().size());
View Full Code Here

   * ignored.
   */
  @Test
  public void decodeUrlWithSlashesInTheMiddle()
  {
    Url url = Url.parse("name1/value1////name2/value2");

    UrlPathPageParametersEncoder decoder = new UrlPathPageParametersEncoder();
    PageParameters parameters = decoder.decodePageParameters(url);

    assertEquals(2, parameters.getAllNamed().size());
View Full Code Here

      }
    };

    when(provider.isNewPageInstance()).thenReturn(true);

    Url sameUrl = Url.parse("same");

    // needed for earlier checks
    when(urlRenderer.getBaseUrl()).thenReturn(sameUrl);
    when(requestCycle.mapUrlFor(eq(handler))).thenReturn(sameUrl);
View Full Code Here

   * ignored.
   */
  @Test
  public void decodeUrlWithSlashesInTheMiddleAndEmptyValue()
  {
    Url url = Url.parse("name1/value1////name2//");

    UrlPathPageParametersEncoder decoder = new UrlPathPageParametersEncoder();
    PageParameters parameters = decoder.decodePageParameters(url);

    assertEquals(2, parameters.getAllNamed().size());
View Full Code Here

  }

  @Override
  protected Url buildUrl(UrlInfo info)
  {
    Url url = new Url();
    url.getSegments().add(getContext().getNamespace());
    url.getSegments().add(getContext().getBookmarkableIdentifier());
    url.getSegments().add(info.getPageClass().getName());

    encodePageComponentInfo(url, info.getPageComponentInfo());

    return encodePageParameters(url, info.getPageParameters(), pageParametersEncoder);
  }
View Full Code Here

  @Override
  protected UrlInfo parseRequest(Request request)
  {
    if (matches(request))
    {
      Url url = request.getUrl();

      // try to extract page and component information from URL
      PageComponentInfo info = getPageComponentInfo(url);

      List<String> segments = url.getSegments();

      // load the page class
      String className;
      if (segments.size() >= 3)
      {
View Full Code Here

  }

  private boolean matches(final Request request)
  {
    boolean matches = false;
    Url url = request.getUrl();
    Url baseUrl = request.getClientUrl();
    String namespace = getContext().getNamespace();
    String bookmarkableIdentifier = getContext().getBookmarkableIdentifier();
    String pageIdentifier = getContext().getPageIdentifier();

    List<String> segments = url.getSegments();
    int segmentsSize = segments.size();

    if (segmentsSize >= 3 && urlStartsWithAndHasPageClass(url, namespace, bookmarkableIdentifier))
    {
      matches = true;
    }
    // baseUrl = 'wicket/bookmarkable/com.example.SomePage[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
    else if (baseUrl.getSegments().size() == 3 && urlStartsWith(baseUrl, namespace, bookmarkableIdentifier)
        && segmentsSize >= 2 && urlStartsWithAndHasPageClass(url, bookmarkableIdentifier))
    {
      matches = true;
    }
    // baseUrl = 'bookmarkable/com.example.SomePage', requestUrl = 'bookmarkable/com.example.SomePage'
    else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, bookmarkableIdentifier)
        && segmentsSize == 2 && urlStartsWithAndHasPageClass(url, bookmarkableIdentifier))
    {
      matches = true;
    }
    // baseUrl = 'wicket/page[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
    else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, namespace, pageIdentifier)
        && segmentsSize >= 2 && urlStartsWithAndHasPageClass(url, bookmarkableIdentifier))
    {
      matches = true;
    }
View Full Code Here

  {
    final String url = "./relative/path";

    ServletWebRequest webRequest = mock(ServletWebRequest.class);
    when(webRequest.isAjax()).thenReturn(Boolean.TRUE);
    Url baseUrl = Url.parse("./baseUrl");
    baseUrl.setProtocol("http");
    baseUrl.setHost("someHost");
    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(webRequest.getContainerRequest()).thenReturn(httpServletRequest);
    when(httpServletRequest.getCharacterEncoding()).thenReturn("UTF-8");
View Full Code Here

TOP

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

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.