List of usage examples for org.apache.wicket.request Url getQueryString
public String getQueryString()
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 .jav 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); } } } }