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

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

Introduction

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

Prototype

public List<QueryParameter> getQueryParameters() 

Source Link

Document

Returns query parameters of the URL.

Usage

From source file:fiftyfive.wicket.resource.SimpleCDN.java

License:Apache License

/**
 * If the {@code requestHandler} is a {@link ResourceReferenceRequestHandler}, delegate to
 * Wicket's default mapper for creating an appropriate URL, and then prepend the CDN
 * {@code baseUrl} that was provided to the {@code SimpleCDN} constructor.
 *
 * @return a rewritten Url to the resource, or {@code null} if {@code requestHandler} is
 *         not for a resource reference//  ww w  .ja v  a  2s  .co m
 */
public Url mapHandler(IRequestHandler requestHandler) {
    // CDN doesn't apply to non-resources
    if (!(requestHandler instanceof ResourceReferenceRequestHandler))
        return null;

    // Prevent infinite recursion in case this SimpleCDN is also contained within the delegate
    if (this.delegated)
        return null;

    Url url = null;
    try {
        this.delegated = true;
        url = this.delegate.mapHandler(requestHandler);
        if (url != null && url.getQueryParameters().isEmpty()) {
            url = Url.parse(Strings.join("/", this.baseUrl, url.toString()));
        }
    } finally {
        this.delegated = false;
    }
    return url;
}

From source file:jp.xet.uncommons.wicket.utils.SimpleCDN.java

License:Apache License

/**
 * If the {@code requestHandler} is a {@link ResourceReferenceRequestHandler}, delegate to
 * Wicket's default mapper for creating an appropriate URL, and then prepend the CDN
 * {@code baseUrl} that was provided to the {@code SimpleCDN} constructor.
 *
 * @return a rewritten Url to the resource, or {@code null} if {@code requestHandler} is
 *         not for a resource reference// w w w .  j  av a  2  s .co  m
 */
@Override
public Url mapHandler(IRequestHandler requestHandler) {
    // CDN doesn't apply to non-resources
    if (!(requestHandler instanceof ResourceReferenceRequestHandler)) {
        return null;
    }

    // Prevent infinite recursion in case this SimpleCDN is also contained within the delegate
    if (delegated) {
        return null;
    }

    Url url = null;
    try {
        delegated = true;
        url = delegate.mapHandler(requestHandler);
        if (url != null && url.getQueryParameters().isEmpty()) {
            url = Url.parse(Strings.join("/", baseUrl, url.toString()));
        }
    } finally {
        delegated = false;
    }
    return url;
}

From source file:org.hippoecm.frontend.plugins.login.LoginPlugin.java

License:Apache License

@Override
protected void onBeforeRender() {
    super.onBeforeRender();

    Request request = RequestCycle.get().getRequest();

    /**/*from   w w  w. j a v a  2s .  c  o m*/
     * Strip the first query parameter from URL if it is empty
     * Copied from {@link AbstractComponentMapper#removeMetaParameter}
     */
    Url urlCopy = new Url(request.getUrl());
    if (!urlCopy.getQueryParameters().isEmpty()
            && Strings.isEmpty(urlCopy.getQueryParameters().get(0).getValue())) {
        String pageComponentInfoCandidate = urlCopy.getQueryParameters().get(0).getName();
        if (PageComponentInfo.parse(pageComponentInfoCandidate) != null) {
            urlCopy.getQueryParameters().remove(0);
        }
    }

    parameters = new PageParametersEncoder().decodePageParameters(urlCopy);
}

From source file:org.jabylon.rest.ui.wicket.CustomExceptionMapper.java

License:Open Source License

@Override
public IRequestHandler map(Exception e) {
    if (e instanceof ObjectNotFoundException) {
        //see https://github.com/jutzig/jabylon/issues/175
        Request request = RequestCycle.get().getRequest();
        Url url = request.getUrl();
        List<QueryParameter> parameters = url.getQueryParameters();
        boolean redirected = false;
        for (QueryParameter queryParameter : parameters) {
            if (queryParameter.getValue().isEmpty() && queryParameter.getName().matches("\\d+")) {
                url.removeQueryParameters(queryParameter.getName());
                LOG.error("Detected request to expired CDO ID. Attempting redirect to " + url.toString(), e);
                Session.get().error("Sorry, this page content has expired. Please try again");
                redirected = true;/*  w  ww  . j  av  a 2 s  .  c o m*/
                break;
            }
        }
        if (redirected)
            return new RedirectRequestHandler("/" + url.toString());
    }
    return super.map(e);
}

From source file:sf.wicklet.ext.ui.mappers.MultiplePageMapper.java

License:Apache License

/**
 * Check if the URL is for home page and the home page class match mounted class. If so,
 * redirect to mounted URL./*from w  w  w. j  a v  a 2 s. co m*/
 *
 * @param url
 * @return request handler or <code>null</code>
 */
private boolean checkHomePage(final Url url) {
    if (url.getSegments().isEmpty() && url.getQueryParameters().isEmpty()) {
        // this is home page
        final Class<? extends IRequestablePage> page = getpageclass(getrpath(url.getPath()));
        if (page != null && page.equals(getContext().getHomePageClass()) && redirectFromHomePage()) {
            return true;
        }
    }
    return false;
}