List of usage examples for org.apache.wicket.request Url getPath
public String getPath()
From source file:com.evolveum.midpoint.web.util.ExactMatchMountedMapper.java
License:Apache License
/** * 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/*from w ww.j a v a2 s . co m*/ * @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; }
From source file:org.onexus.website.api.utils.panels.ConnectionsPanel.java
License:Apache License
@Override protected void onBeforeRender() { super.onBeforeRender(); String urlPath = ""; Website website = findParent(Website.class); if (!connections.isEmpty()) { PageParameters params = new PageParameters(); if (website != null) { WebsiteStatus status = website.getStatus(); status.encodeParameters(params, true); }// w w w . j a v a2s .c o m Url url = getRequestCycle().mapUrlFor(getPage().getClass(), params); urlPath = url.getPath() + url.getQueryString(); int firstSlash = urlPath.indexOf('/'); urlPath = urlPath.substring(firstSlash); } RepeatingView connectionsView = new RepeatingView("projects"); for (Connection connection : connections) { WebMarkupContainer connectionItem = new WebMarkupContainer(connectionsView.newChildId()); if (connection.getActive() != null && connection.getActive()) { connectionItem.add(new AttributeModifier("class", "active")); } ExternalLink link = new ExternalLink("url", connection.getUrl() + urlPath); link.add(new Label("title", connection.getTitle())); connectionItem.add(link); connectionsView.add(connectionItem); } addOrReplace(connectionsView); WebMarkupContainer divider = new WebMarkupContainer("divider"); addOrReplace(divider); RepeatingView userProjects = new RepeatingView("user"); addOrReplace(userProjects); // Add private projects divider.setVisible(false); if (WebsiteSession.get().isSignedIn()) { List<Project> projects = resourceManager.getProjects(); for (Project project : projects) { String projectUrl = project.getURL(); String userName = LoginContext.get().getUserName(); if (projectUrl.startsWith("private://" + userName)) { WebMarkupContainer connectionItem = new WebMarkupContainer(userProjects.newChildId()); if (website.getConfig().getORI().getProjectUrl().equals(projectUrl)) { connectionItem.add(new AttributeModifier("class", "active")); } String projectName = project.getName(); String projectTitle = projectName.substring(projectName.indexOf('/') + 1); ExternalLink link = new ExternalLink("url", "/web/" + projectName + "/v01" + urlPath); link.add(new Label("title", projectTitle)); connectionItem.add(link); userProjects.add(connectionItem); divider.setVisible(true); } } } }
From source file:sf.wicklet.ext.ui.mappers.MultiplePageMapper.java
License:Apache License
@Override protected UrlInfo parseRequest(final Request request) { final Url url = request.getUrl(); // when redirect to buffer/render is active and redirectFromHomePage returns true // check mounted class against the home page class. if it matches let wicket redirect // to the mounted URL if (redirectFromHomePage() && checkHomePage(url)) { return new UrlInfo(null, getContext().getHomePageClass(), newPageParameters()); } else if (url.getPath().startsWith(mountPath)) { // check if the URL starts with the proper segments // try to extract page and component information from URL final PageComponentInfo info = getPageComponentInfo(url); final Class<? extends IRequestablePage> pageClass = getpageclass(getrpath(url.getPath())); if (pageClass != null) { final PageParameters pageParameters = extractPageParameters(request, url); return new UrlInfo(info, pageClass, pageParameters); }/*w w w .j a v a2s. c om*/ } return null; }
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.//w w w . j a v a2 s. c o 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; }