本文整理汇总了Java中org.apache.wicket.request.Url类的典型用法代码示例。如果您正苦于以下问题:Java Url类的具体用法?Java Url怎么用?Java Url使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Url类属于org.apache.wicket.request包,在下文中一共展示了Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: respond
import org.apache.wicket.request.Url; //导入依赖的package包/类
/** {@inheritDoc} */
public void respond(final IRequestCycle requestCycle)
{
String location = requestCycle.getUrlRenderer().renderRelativeUrl(Url.parse(getRedirectUrl()));
WebResponse response = (WebResponse)requestCycle.getResponse();
if (status == HttpServletResponse.SC_MOVED_TEMPORARILY)
{
response.sendRedirect(location);
}
else
{
response.setStatus(status);
response.setHeader("Location", location);
}
}
示例2: getUrlString
import org.apache.wicket.request.Url; //导入依赖的package包/类
@Override
public String getUrlString(Class<? extends Page> pageClass, QueryFacetsSelection selection, SolrDocument document) {
final PageParameters params = new PageParameters();
if (selection != null) {
params.mergeWith(paramsConverter.toParameters(selection));
}
if (document != null) {
params.add(VloWebAppParameters.DOCUMENT_ID, document.getFirstValue(FacetConstants.FIELD_ID));
}
final String style = Session.get().getStyle();
if (style != null) {
params.add(VloWebAppParameters.THEME, style);
}
final CharSequence url = RequestCycle.get().urlFor(pageClass, params);
final String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url));
return absoluteUrl;
}
示例3: getPath
import org.apache.wicket.request.Url; //导入依赖的package包/类
@Override
public String getPath(Charset charset) {
StringBuilder path = new StringBuilder();
boolean slash = false;
for (String segment : getSegments()) {
if (slash) {
path.append('/');
}
if (segment.indexOf('/') != -1) {
Url url = new Url(Splitter.on('/').splitToList(segment), Charsets.UTF_8);
path.append(url.getPath());
} else {
path.append(UrlEncoder.PATH_INSTANCE.encode(segment, charset));
}
slash = true;
}
return path.toString();
}
示例4: urlStartsWithMountedSegments
import org.apache.wicket.request.Url; //导入依赖的package包/类
/**
* We want to fully match url path. Parent class is OK with partial match and then
* marking other path element as page parameters.
*
* @param url
* @return
*/
@Override
protected boolean urlStartsWithMountedSegments(Url url) {
if (url == null) {
return false;
}
if (!(pageParametersEncoder instanceof PageParametersEncoder)) {
LOG.trace("Matching using standard mounted mapper for '{}'", url);
return super.urlStartsWithMountedSegments(url);
}
String mountUrl = StringUtils.join(mountSegments, "/");
boolean matched = url.getPath().equals(mountUrl);
LOG.trace("Matched: {} for '{}' with mount url '{}'", matched, url, mountUrl);
return matched;
}
示例5: decodePageParameters
import org.apache.wicket.request.Url; //导入依赖的package包/类
@Override
public PageParameters decodePageParameters(Url url) {
PageParameters parameters = new PageParameters();
List<String> segments = url.getSegments();
if (!segments.isEmpty()) {
String value = segments.get(0);
parameters.add(PARAMETER, value);
}
if (url.getQueryParameters() != null) {
for (Url.QueryParameter qp : url.getQueryParameters()) {
parameters.add(qp.getName(), qp.getValue());
}
}
return parameters.isEmpty() ? null : parameters;
}
示例6: encodePageParameters
import org.apache.wicket.request.Url; //导入依赖的package包/类
@Override
protected Url encodePageParameters(Url url, PageParameters pageParameters, IPageParametersEncoder encoder) {
//get special page parameter that encodes the page fragment/anchor
final StringValue fragment = pageParameters.get(FRAGMENT_PAGE_PARAMETER);
if (fragment.isEmpty()) {
//business as usual
return super.encodePageParameters(url, pageParameters, encoder);
} else {
//we have a fragment parameter, remove from normal parameters and do post-processing
pageParameters.remove(FRAGMENT_PAGE_PARAMETER);
final Url result = super.encodePageParameters(url, pageParameters, encoder);
//set the fragment on the resulting URL
result.setFragment(fragment.toString());
return result;
}
}
示例7: getWsUrl
import org.apache.wicket.request.Url; //导入依赖的package包/类
private static String getWsUrl(Url reqUrl) {
final boolean insecure = "http".equalsIgnoreCase(reqUrl.getProtocol());
String delim = ":";
String port = reqUrl.getPort() == null || reqUrl.getPort() < 0 ? "" : String.valueOf(reqUrl.getPort());
if (!port.isEmpty() && ((insecure && 80 == reqUrl.getPort()) || (!insecure && 443 == reqUrl.getPort()))) {
port = "";
}
if (port.isEmpty()) {
delim = "";
}
return String.format("%s://%s%s%s;"
, insecure ? "ws" : "wss"
, reqUrl.getHost()
, delim
, port);
}
示例8: randomizeOncePerRequestCycle
import org.apache.wicket.request.Url; //导入依赖的package包/类
private void randomizeOncePerRequestCycle() {
if (lastRandomizedRequestCycle != RequestCycle.get()) {
lastRandomizedRequestCycle = RequestCycle.get();
Assertions.assertThat(lastRandomizedRequestCycle == RequestCycle.get())
.as("RequestCycle.get() always returns a different instance?!?")
.isTrue(); //sanity check
final List<ICarouselImage> imgs = new ArrayList<ICarouselImage>();
for (int i = 1; i <= 5; i++) {
final String path = "FrameworkSlogan_" + i + ".jpg";
final PackageResourceReference resource = new PackageResourceReference(getClass(), path);
final Url url = RequestCycle.get().mapUrlFor(resource, null);
imgs.add(new CarouselImage(url.toString()));
}
Collections.shuffle(imgs);
frameworkSloganImgs = imgs;
}
}
示例9: setDefaultResponsePageIfNecessary
import org.apache.wicket.request.Url; //导入依赖的package包/类
private void setDefaultResponsePageIfNecessary()
{
// This does not work because it was Spring Security that intercepted the access, not
// Wicket continueToOriginalDestination();
String redirectUrl = getRedirectUrl();
if (redirectUrl == null || redirectUrl.contains(".IBehaviorListener.")
|| redirectUrl.contains("-logoutPanel-")) {
log.debug("Redirecting to welcome page");
setResponsePage(getApplication().getHomePage());
}
else {
log.debug("Redirecting to saved URL: [{}]", redirectUrl);
if (isNotBlank(form.urlfragment) && form.urlfragment.startsWith("!")) {
Url url = Url.parse("http://dummy?" + form.urlfragment.substring(1));
UrlRequestParametersAdapter adapter = new UrlRequestParametersAdapter(url);
LinkedHashMap<String, StringValue> params = new LinkedHashMap<>();
for (String name : adapter.getParameterNames()) {
params.put(name, adapter.getParameterValue(name));
}
Session.get().setMetaData(SessionMetaData.LOGIN_URL_FRAGMENT_PARAMS, params);
}
throw new NonResettingRestartException(redirectUrl);
}
}
示例10: fixSimpleRepoBrowsingUrl
import org.apache.wicket.request.Url; //导入依赖的package包/类
private void fixSimpleRepoBrowsingUrl(Request request, Url url) {
RepoPath repoPath = RequestUtils.getRepoPath((HttpServletRequest) request.getContainerRequest());
if (repoPath != null) {
/*ArrayList<String> prefix = new ArrayList<String>();
String path = repoPath.getPath();
if (StringUtils.isNotEmpty(path)) {
int nesting = new StringTokenizer(path, "/").countTokens() + 1;
while (nesting > 0) {
prefix.add("..");
nesting--;
}
} else {
prefix.add("..");
}
*/
List<String> prefix = Lists.newArrayList("..");
String filterPath = request.getFilterPath();
if (StringUtils.isNotEmpty(filterPath) && filterPath.startsWith("/")) {
prefix.add(filterPath.substring(1));
}
url.prependLeadingSegments(prefix);
}
}
示例11: ArtifactoryWebRequest
import org.apache.wicket.request.Url; //导入依赖的package包/类
/**
* Construct.
*
* @param httpServletRequest
* @param filterPrefix contentPath + filterPath, used to extract the actual {@link Url}
* @param url
*/
public ArtifactoryWebRequest(HttpServletRequest httpServletRequest, String filterPrefix, Url url) {
super(httpServletRequest, filterPrefix, null);
Args.notNull(httpServletRequest, "httpServletRequest");
Args.notNull(filterPrefix, "filterPrefix");
this.httpServletRequest = httpServletRequest;
this.filterPrefix = filterPrefix;
errorAttributes = ErrorAttributes.of(httpServletRequest);
forwardAttributes = ForwardAttributes.of(httpServletRequest);
if (url != null) {
this.url = url;
} else {
this.url = getContextRelativeUrl(httpServletRequest.getRequestURI(), filterPrefix);
}
}
示例12: getContextRelativeUrl
import org.apache.wicket.request.Url; //导入依赖的package包/类
private Url getContextRelativeUrl(String uri, String filterPrefix) {
if (filterPrefix.length() > 0 && !filterPrefix.endsWith("/")) {
filterPrefix += "/";
}
StringBuilder url = new StringBuilder();
uri = Strings.stripJSessionId(uri);
final int start = httpServletRequest.getContextPath().length() + filterPrefix.length() + 1;
url.append(uri.substring(start));
if (errorAttributes == null) {
String query = httpServletRequest.getQueryString();
if (!Strings.isEmpty(query)) {
url.append('?');
url.append(query);
}
}
return setParameters(Url.parse(url.toString(), getCharset()));
}
示例13: onBeginRequest
import org.apache.wicket.request.Url; //导入依赖的package包/类
@Override
public void onBeginRequest(RequestCycle cycle) {
StringValue directBuyParameterValue = cycle.getRequest().getRequestParameters().getParameterValue(DIRECT_BUY_PARAMETER);
if (!directBuyParameterValue.isEmpty()) {
try {
ProductInfo productInfo = productService.findByQuery(ProductQuery.create().withUrlname(directBuyParameterValue.toString()));
if (productInfo != null) {
cart.addItem(productInfo);
} else {
ShopSession.get().error(String.format("Das Product '%s' konnte nicht gefunden werden.", directBuyParameterValue));
}
Url urlWithoutDirectBuy = removeDirectBuyFromUrl(cycle);
redirectTo(cycle, urlWithoutDirectBuy);
} catch (Exception e) {
ShopSession.get().error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE);
LOGGER.error(DIRECT_BUY_PROCESSING_FAILED_MESSAGE, e);
}
}
}
示例14: prepareRequest
import org.apache.wicket.request.Url; //导入依赖的package包/类
/**
* Prepares request that triggers AJAX behavior and contains parameter with given name and value.
*
* @param tester the wicket tester which triggers behavior
* @param behavior the behavior that should be triggered
* @param parameterName the name of parameter
* @param parameterValue the value of parameter
* @return mock HTTP request that triggers given behavior
*/
protected MockHttpServletRequest prepareRequest(WicketTester tester, AbstractAjaxBehavior behavior,
String parameterName, String parameterValue) {
MockHttpServletRequest request = new MockHttpServletRequest(tester.getApplication(), tester.getHttpSession(), tester.getServletContext());
Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding()));
// make url suitable for wicket tester use. usually this involves stripping any leading ..
// segments to make the url absolute
for (Iterator<String> segments = url.getSegments().iterator(); segments.hasNext();) {
String segment = segments.next();
if (segment.equals("..") || segment.equals(".")) {
segments.remove();
}
}
request.addHeader("Wicket-Ajax", "true");
request.addHeader("Wicket-Ajax-BaseURL", url.toString());
request.setUrl(url);
request.setParameter(parameterName, parameterValue);
return request;
}
示例15: getAbsoluteContextPath
import org.apache.wicket.request.Url; //导入依赖的package包/类
/**
* Examples: https://www.projectforge.org/demo or https://www.acme.com/ProjectForge.
* @return Absolute context path of the web application.
*/
public static String getAbsoluteContextPath()
{
if (absoluteContextPath == null) {
final RequestCycle requestCycle = RequestCycle.get();
final String url = requestCycle.getUrlRenderer().renderFullUrl(Url.parse(requestCycle.urlFor(LoginPage.class, null).toString()));
final String basePath = "/" + WICKET_APPLICATION_PATH;
final int pos = url.indexOf(basePath);
if (pos < 0) {
log.warn("Couln't get base url of '" + url + "'. Sub string '" + basePath + "' expected.");
return url;
}
absoluteContextPath = url.substring(0, pos);
}
return absoluteContextPath;
}