Example usage for org.apache.wicket.request Url resolveRelative

List of usage examples for org.apache.wicket.request Url resolveRelative

Introduction

In this page you can find the example usage for org.apache.wicket.request Url resolveRelative.

Prototype

public void resolveRelative(final Url relative) 

Source Link

Document

Makes this url the result of resolving the relative url against this url.

Usage

From source file:de.alpharogroup.wicket.base.util.url.WicketUrlExtensions.java

License:Apache License

/**
 * Gets the url as string from the given WebPage class object.
 * //from   ww  w . ja va 2 s .c  o m
 * @param pageClass
 *            the page class
 * @return the url as string
 */
public static String getUrlAsString(final Class<? extends Page> pageClass) {
    final Url pageUrl = getPageUrl(pageClass);
    final Url url = getBaseUrl(pageClass);
    url.resolveRelative(pageUrl);
    final String contextPath = getContextPath();
    return String.format("%s/%s", contextPath, url);
}

From source file:org.jaulp.wicket.base.util.url.WicketUrlUtils.java

License:Apache License

/**
 * Gets the url as string from the given WebPage class object.
 * /*w w  w.j ava  2 s . c  o m*/
 * @param pageClass
 *            the page class
 * @return the url as string
 */
public static String getUrlAsString(Class<? extends WebPage> pageClass) {
    Url pageUrl = getPageUrl(pageClass);
    Url url = getBaseUrl(pageClass);
    url.resolveRelative(pageUrl);
    String contextPath = getContextPath();
    return String.format("%s/%s", contextPath, url);
}

From source file:org.opensingular.lib.wicket.util.application.HttpsOnlyUrlRenderer.java

License:Apache License

@SuppressWarnings("deprecation")
public String renderFullUrl(final Url url) {
    if (url instanceof IUrlRenderer) {
        IUrlRenderer renderer = (IUrlRenderer) url;
        return renderer.renderFullUrl(url, getBaseUrl());
    }// w w w . j a v a  2  s  .  co  m

    final String protocol = "https";
    final String host = resolveHost(url);

    final String path;
    if (url.isContextAbsolute()) {
        path = url.toString();
    } else {
        Url base = new Url(getBaseUrl());
        base.resolveRelative(url);
        path = base.toString();
    }

    StringBuilder render = new StringBuilder();
    if (!Strings.isEmpty(protocol)) {
        render.append(protocol);
        render.append(':');
    }

    if (!Strings.isEmpty(host)) {
        render.append("//");
        render.append(host);
    }

    if (!url.isContextAbsolute()) {
        render.append(request.getContextPath());
        render.append(request.getFilterPath());
    }
    return Strings.join("/", render.toString(), path);
}