List of usage examples for org.apache.wicket Page getPageParameters
@Override
public PageParameters getPageParameters()
From source file:com.doculibre.constellio.wicket.panels.header.BaseSearchHistoryPageHeaderPanel2.java
License:Open Source License
public BaseSearchHistoryPageHeaderPanel2(String id, final Page owner) { super(id, owner); add(new LinkHolder("backLinkHolder", new StringResourceModel("back", this, null)) { @Override//from w ww.ja va 2 s. co m protected WebMarkupContainer newLink(String id) { return new Link(id) { @Override public void onClick() { String collectionName = owner.getPageParameters().getString(SimpleSearch.COLLECTION_NAME); List<SimpleSearch> searchHistory = ConstellioSession.get().getSearchHistory(collectionName); PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class); int sizeHistory = searchHistory.size(); if (sizeHistory > 0) { // Relaunches last search SimpleSearch simpleSearch = searchHistory.get(sizeHistory - 1); SimpleSearch clone = simpleSearch.clone(); setResponsePage(pageFactoryPlugin.getSearchResultsPage(), SearchResultsPage.getParameters(clone)); } else { setResponsePage(pageFactoryPlugin.getSearchFormPage(), new PageParameters(SimpleSearch.COLLECTION_NAME + "=" + collectionName)); } } }; } }); add(new LinkHolder("newSearchLinkHolder", new StringResourceModel("newSearch", this, null)) { @Override protected WebMarkupContainer newLink(String id) { PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class); String collectionName = owner.getPageParameters().getString(SimpleSearch.COLLECTION_NAME); return new BookmarkablePageLink(id, pageFactoryPlugin.getSearchFormPage(), new PageParameters(SimpleSearch.COLLECTION_NAME + "=" + collectionName)); } }); add(new AdminLinkHolder("adminLinkHolder")); add(new SignInLinkHolder("signInLinkHolder").setVisible(isSignInVisible())); add(new SignOutLinkHolder("signOutLinkHolder")); add(new SwitchLocaleLinkHolder("switchLocaleLinkHolder")); }
From source file:com.github.javawithmarcus.wicket.cdi.AbstractCdiContainer.java
License:Apache License
/** * Removes conversation marker from the page instance which prevents the conversation from * propagating to the page. This method should usually be called from page's {@code onDetach()} * method./* w ww . j ava 2 s . c o m*/ * * @param page */ public void removeConversationMarker(Page page) { Args.notNull(page, "page"); page.setMetaData(ConversationIdMetaKey.INSTANCE, null); page.getPageParameters().remove(ConversationPropagator.CID_ATTR); }
From source file:guru.mmp.application.web.template.navigation.NavigationLink.java
License:Apache License
/** * Returns <code>true</code> if the page is in the navigation item's hierarchy or * <code>false</code> otherwise. * * @param page the page//from w w w. j av a 2 s . c o m * * @return <code>true</code> if the page is in the navigation item's hierarchy or * <code>false</code> otherwise */ public boolean isPageInNavigationHierarchy(Page page) { if (!pageClass.equals(page.getClass())) { return false; } if (pageParameters.isEmpty()) { return true; } else { for (String namedKey : pageParameters.getNamedKeys()) { List<StringValue> pageParameterValues = pageParameters.getValues(namedKey); List<StringValue> tmpPageParameterValues = page.getPageParameters().getValues(namedKey); if (pageParameterValues.size() != tmpPageParameterValues.size()) { return false; } for (int i = 0; i < pageParameterValues.size(); i++) { if (!pageParameterValues.get(i).toString().equals(tmpPageParameterValues.get(i).toString())) { return false; } } } return true; } }
From source file:guru.mmp.application.web.template.navigation.NavigationState.java
License:Apache License
/** * Returns <code>true</code> if the specified page is the last page that was accessed in the * navigation hierarchy or <code>false</code> otherwise. * * @param page the page/*from w ww. jav a2s .co m*/ * * @return <code>true</code> if the specified page is the last page that was accessed in the * navigation hierarchy or <code>false</code> otherwise */ public boolean isLastPageAccessedInNavigationHierarchy(Page page) { // If we do not have a last page that was accessed in the navigation hierarchy if (lastPageAccessedInNavigationHierarchyClass == null) { return false; } /* * If the page classes don't match then this can't be the last page that was accessed in * the navigation hierarchy. */ if (lastPageAccessedInNavigationHierarchyClass != page.getPageClass()) { return false; } /* * If the page does not have parameters then this must be the last page that was accessed in * the navigation hierarchy. */ if (page.getPageParameters().isEmpty()) { return true; } /* * If we get here we check the page parameters since we might be dealing with the same * type of page but it might have different parameters. */ PageParameters pageParameters = page.getPageParameters(); for (String namedKey : pageParameters.getNamedKeys()) { List<StringValue> pageParameterValues = pageParameters.getValues(namedKey); List<StringValue> lastPageAccessedInNavigationHierarchyParameterValues = lastPageAccessedInNavigationHierarchyParameters .getValues(namedKey); if (pageParameterValues.size() != lastPageAccessedInNavigationHierarchyParameterValues.size()) { return false; } for (int i = 0; i < pageParameterValues.size(); i++) { if (!pageParameterValues.get(i).toString() .equals(lastPageAccessedInNavigationHierarchyParameterValues.get(i).toString())) { return false; } } } return true; }
From source file:guru.mmp.application.web.template.navigation.NavigationState.java
License:Apache License
/** * Set the last page that was accessed that was part of the navigation hierarchy. * * @param page the last page that was accessed that was part of the navigation hierarchy *//* w w w.j av a 2 s . c o m*/ public void setLastPageAccessedInNavigationHierarchy(Page page) { lastPageAccessedInNavigationHierarchyClass = page.getPageClass(); lastPageAccessedInNavigationHierarchyParameters = page.getPageParameters(); }
From source file:name.martingeisse.admin.navigation.NavigationUtil.java
License:Open Source License
/** * Obtains the navigation path for the specified page. This tries to use the page * as an {@link INavigationLocationAware} and also attempts to find page parameters * set by a {@link NavigationMountedRequestMapper}. * /*from w w w.ja v a2s. c o m*/ * @param page the page to return the navigation path for * @return the navigation path, or null if not found */ public static String getNavigationPathForPage(final Page page) { // try INavigationLocator if (page instanceof INavigationLocationAware) { final INavigationLocationAware aware = (INavigationLocationAware) page; final String result = aware.getNavigationPath(); if (result != null) { return result; } } // try the implicit page parameter return getParameterValue(page.getPageParameters()); }
From source file:name.martingeisse.wicket.component.misc.PageParameterDrivenTabPanel.java
License:Open Source License
/** * //from ww w.j a v a 2 s .c o m */ private final PageParameters createTabLinkPageParameters(Page page, String selector) { PageParameters parameters = new PageParameters(page.getPageParameters()); parameters.remove(parameterName).add(parameterName, selector); return parameters; }
From source file:ontopoly.pages.InternalErrorPageWithException.java
License:Apache License
public InternalErrorPageWithException(Page page, final RuntimeException e) { super(page == null ? null : page.getPageParameters()); createTitle();/*from w ww . j a va2s. c o m*/ add(new BookmarkablePageLink<Page>("link", StartPage.class)); add(new Label("java_version") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", System.getProperty("java.vm.vendor") + ", " + System.getProperty("java.vm.version")); } }); add(new Label("os_version") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", System.getProperty("os.name") + ", " + System.getProperty("os.version") + " (" + System.getProperty("os.arch") + ")"); } }); add(new Label("oks_version") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", Ontopia.getVersion()); } }); HttpServletRequest request = getWebRequestCycle().getWebRequest().getHttpServletRequest(); final String serverName = request.getServerName(); add(new Label("server_name") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", serverName); } }); /*add(new Label("server_info") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); if(request != null && request.getSession(true) != null && request.getSession(true).getServletContext() != null) { tag.put("value", request.getSession(true).getServletContext().getServerInfo()); } } });*/ final String serverPort = Integer.toString(request.getServerPort()); add(new Label("server_port") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", serverPort); } }); final String remoteAddr = request.getRemoteAddr(); add(new Label("remote_address") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", remoteAddr); } }); final String remoteHost = request.getRemoteHost(); add(new Label("remote_host") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", remoteHost); } }); final String stackTrace; if (e == null) { stackTrace = "unknown"; } else { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); stackTrace = sw.toString(); } add(new Label("stack_trace") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", stackTrace); } }); add(new Label("error_message") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("value", e.getMessage()); } }); add(new Label("stackTrace", stackTrace)); }
From source file:org.artifactory.webapp.wicket.page.browse.home.RememberPageBehavior.java
License:Open Source License
private String getPageUrl(Page page) { Class<? extends Page> pageClass = page.getClass(); String pageUrl = RequestCycle.get().urlFor(pageClass, page.getPageParameters()).toString(); if (!keepParameters) { pageUrl = HttpUtils.stripQuery(pageUrl); }/* w w w .j a va 2s . co m*/ try { return new URL(WicketUtils.toAbsolutePath(pageUrl)).getFile(); } catch (MalformedURLException e) { return null; } }
From source file:org.devgateway.eudevfin.dim.NavbarInitializer.java
License:Open Source License
@WicketNavbarComponentInitializer(position = Navbar.ComponentPosition.RIGHT, order = 10) public static Component newLanguageNavbarButton(final Page page) { final NavbarDropDownButton languageDropDown = new NavbarDropDownButton( new StringResourceModel("navbar.lang", page, null, null)) { private static final long serialVersionUID = 2866997914075956070L; @Override//ww w.java 2s.c o m public boolean isActive(final Component item) { return false; } @SuppressWarnings("Convert2Diamond") @Override protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) { final List<AbstractLink> list = new ArrayList<>(); list.add(new MenuHeader(new StringResourceModel("navbar.lang.header", this, null, null))); list.add(new MenuDivider()); // TODO: get available languages final List<Locale> langs = new ArrayList<>(); langs.add(new Locale("en")); langs.add(new Locale("hr")); langs.add(new Locale("cs")); langs.add(new Locale("bg")); langs.add(new Locale("hu")); langs.add(new Locale("lv")); langs.add(new Locale("lt")); langs.add(new Locale("pl")); langs.add(new Locale("ro")); langs.add(new Locale("sl")); for (final Locale l : langs) { final PageParameters params = new PageParameters(page.getPageParameters()); params.set(Constants.LANGUAGE_PAGE_PARAM, l.getLanguage()); list.add(new MenuBookmarkablePageLink<Page>(page.getPageClass(), params, Model.of(l.getDisplayName()))); } return list; } }; languageDropDown.setIconType(IconType.flag); languageDropDown.add(new DropDownAutoOpen()); return languageDropDown; }