List of usage examples for org.apache.wicket.request Url toString
@Override
public String toString()
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.AbstractMultiAjaxBehavior.java
License:Apache License
/** * @see org.apache.wicket.behavior.AbstractAjaxBehavior#renderHead(Component, * org.apache.wicket.markup.head.IHeaderResponse) *//*from w ww . ja v a 2s . com*/ @Override public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); CoreLibrariesContributor.contributeAjax(component.getApplication(), response); final RequestCycle requestCycle = component.getRequestCycle(); final Url baseUrl = requestCycle.getUrlRenderer().getBaseUrl(); final CharSequence ajaxBaseUrl = Strings.escapeMarkup(baseUrl.toString()); response.render(JavaScriptHeaderItem.forScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl + "\";", "wicket-ajax-base-url")); renderExtraHeaderContributors(component, response); }
From source file:com.evolveum.midpoint.web.util.MidPointPageParametersEncoder.java
License:Apache License
/** * Encodes a URL in the form://from w w w . j a va 2 s .c o m * <p/> * /mountpoint/paramName1/paramValue1/paramName2/paramValue2 * <p/> * (i.e. a URL using the pre wicket 1.5 Hybrid URL strategy) */ @Override public Url encodePageParameters(PageParameters pageParameters) { Url url = new Url(); for (PageParameters.NamedPair pair : pageParameters.getAllNamed()) { url.getSegments().add(pair.getKey()); url.getSegments().add(pair.getValue()); } if (LOGGER.isTraceEnabled() && !pageParameters.isEmpty()) { LOGGER.trace("Parameters '{}' encoded to: '{}'", pageParameters, url.toString()); } return url; }
From source file:com.evolveum.midpoint.web.util.MidPointPageParametersEncoder.java
License:Apache License
/** * Decodes a URL in the form://www . jav a2 s . c om * <p/> * /mountpoint/paramName1/paramValue1/paramName2/paramValue2 * <p/> * (i.e. a URL using the pre wicket 1.5 Hybrid URL strategy) */ @Override public PageParameters decodePageParameters(Url url) { PageParameters parameters = new PageParameters(); for (Iterator<String> segment = url.getSegments().iterator(); segment.hasNext();) { String key = segment.next(); if (segment.hasNext()) { String value = segment.next(); if (value != null) { parameters.add(key, value); } } } if (LOGGER.isTraceEnabled()) { LOGGER.trace("Parameters '{}' encoded from: '{}'", parameters, url.toString()); } return parameters.isEmpty() ? null : parameters; }
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//w w w . ja va 2 s.com */ 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:fiftyfive.wicket.util.HttpUtils.java
License:Apache License
/** * Returns the entire URL that was used to render the current page, * which should match what the user sees in the browser location bar. * Includes protocol, host, port absolute path and query string. * <p>/*from w ww . j a v a 2s. c o m*/ * <b>If the current request is an ajax one, this URL will not match * the actual ajax HTTP request being handled by the server.</b> Instead * this URL will be most recent non-ajax request, as observed in the * browser location bar. * * @see org.apache.wicket.request.Request#getClientUrl * @since 3.0 */ public static String getAbsolutePageUrl() { String absolute = null; RequestCycle rc = RequestCycle.get(); Url url = rc.getRequest().getClientUrl(); HttpServletRequest http = getHttpServletRequest(); if (url != null && http != null) { ServletWebRequest webRequest = (ServletWebRequest) rc.getRequest(); String port = ":" + http.getServerPort(); if (http.getServerPort() == 80 && http.getScheme().equals("http")) { port = ""; } absolute = Strings.join("/", http.getScheme() + "://" + http.getServerName() + port, http.getServerName(), http.getContextPath(), webRequest.getFilterPrefix(), url.toString()); } return absolute; }
From source file:guru.mmp.application.web.WebSphereAbsoluteUrlRenderer.java
License:Apache License
/** * Overrides the normal relative URL rendering to render an absolute URL that is compatible with * WebSphere.//from w w w. j av a 2 s. c om * * @param url the URL to render * * @return the WebSphere compatible absolute URL */ @Override public String renderRelativeUrl(Url url) { if (url == null) { throw new WebApplicationException("Fail to render relative URL for null URL"); } // If this is already a context absolute or full URL then stop here if (url.isContextAbsolute() || url.isFull()) { return url.toString(); } else { return contextPath + "/" + url.toString(); } }
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// ww w . j a v a 2 s . c om */ @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.artifactory.common.wicket.util.WicketUtils.java
License:Open Source License
/** * Get the absolute bookmarkable path of a page * * @param pageClass Page/*ww w .j av a2 s . com*/ * @param pageParameters Optional page parameters * @return Bookmarkable path */ public static String absoluteMountPathForPage(Class<? extends Page> pageClass, PageParameters pageParameters) { HttpServletRequest req = getHttpServletRequest(); RequestCycle requestCycle = RequestCycle.get(); Url url = requestCycle.mapUrlFor(pageClass, pageParameters); String renderedUrl = url.toString(); renderedUrl = Strings.isEmpty(renderedUrl) ? "." : renderedUrl; return RequestUtils.toAbsolutePath(HttpUtils.getWebappContextUrl(req), requestCycle.getOriginalResponse().encodeURL(renderedUrl)); }
From source file:org.brixcms.web.BrixRequestMapper.java
License:Apache License
@Override public IRequestHandler mapRequest(Request request) { final Url url = request.getClientUrl(); // TODO: This is just a quick fix if (url.getSegments().size() > 0) { if (url.getSegments().get(0).equals("webdav") || url.getSegments().get(0).equals("jcrwebdav")) { return null; }//from w ww . j a v a 2 s .c om } Path path = new Path("/" + url.toString()); // root path handling if (path.isRoot()) { if (handleHomePage) { final BrixNode node = getNodeForUriPath(path); return SitePlugin.get().getNodePluginForNode(node).respond(new BrixNodeModel(node), request.getRequestParameters()); } else { return null; } } IRequestHandler handler = null; try { while (handler == null) { final BrixNode node = getNodeForUriPath(path); if (node != null) { handler = SitePlugin.get().getNodePluginForNode(node).respond(new BrixNodeModel(node), request.getRequestParameters()); } if (handler != null || path.toString().equals(".")) { break; } path = path.parent(); if (path.isRoot()) { break; } } } catch (JcrException e) { logger.warn("JcrException caught due to incorrect url", e); } return handler; }
From source file:org.cast.cwm.mediaplayer.MediaPlayerPanel.java
License:Open Source License
protected String toSiteAbsolutePath(ResourceReference rr) { if (rr == null) return null; // mapUrlFor should return the whole path after the context directory Url url = RequestCycle.get().mapUrlFor(rr, null); if (url == null) { log.error("Could not determine URL for media {}", rr); return ""; }/* w ww .j ava2 s .com*/ return toSiteAbsolutePath(url.toString()); }