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

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

Introduction

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

Prototype

public void setPort(final Integer port) 

Source Link

Document

Sets the port of this url

Usage

From source file:com.mastfrog.acteur.wicket.adapters.RequestAdapter.java

License:Open Source License

@Inject
public RequestAdapter(HttpEvent evt, Locale locale, Charset charset, Settings settings) {
    this.evt = evt;
    this.locale = locale;
    this.charset = charset;
    String filterPrefix = settings.getString(PathFactory.BASE_PATH_SETTINGS_KEY, "");
    String uri = evt.getRequest().getUri();
    // Adapted from ServletWebRequest's constructor
    if (filterPrefix.length() > 0 && !filterPrefix.endsWith("/")) {
        filterPrefix += "/";
    }//  w ww. j  a  v a 2 s.  c o  m
    StringBuilder sb = new StringBuilder();
    uri = Strings.stripJSessionId(uri);
    String contextPath = "";
    final int start = contextPath.length() + filterPrefix.length() + 1;
    if (uri.length() > start) {
        sb.append(uri.substring(start));
    }

    Url url = Url.parse(sb.toString(), charset, false);
    url.setPort(settings.getInt(ServerModule.PORT));
    String host = evt.getHeader(Headers.HOST);
    if (host != null) {
        url.setHost(host);
    } else {
        url.setHost(settings.getString(PathFactory.HOSTNAME_SETTINGS_KEY, "localhost"));
    }
    url.setProtocol("http");
    this.url = url;
}

From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java

License:Apache License

private Url setParameters(Url url) {
    url.setPort(httpServletRequest.getServerPort());
    url.setHost(httpServletRequest.getServerName());
    url.setProtocol(httpServletRequest.getScheme());
    return url;/*w w  w.ja v a2 s  .  co  m*/
}