@Override public void popstate(String uri) { getPage().updateLocation(uri, true, true); } };
@Override public void resize(int viewWidth, int viewHeight, int windowWidth, int windowHeight) { // TODO We're not doing anything with the view dimensions getPage().updateBrowserWindowSize(windowWidth, windowHeight, true); }
/** * Gets the Page to which the current uI belongs. This is automatically * defined when processing requests to the server. In other cases, (e.g. * from background threads), the current uI is not automatically defined. * * @see UI#getCurrent() * * @return the current page instance if available, otherwise * <code>null</code> */ public static Page getCurrent() { UI currentUI = UI.getCurrent(); if (currentUI == null) { return null; } return currentUI.getPage(); }
/** * Shows a notification message. * * @see Notification * @see #showNotification(String) * @see #showNotification(String, int) * @see #showNotification(String, String) * @see #showNotification(String, String, int) * * @param notification * The notification message to show * * @deprecated As of 7.0, use Notification.show instead */ @Deprecated public void showNotification(Notification notification) { getPage().showNotification(notification); }
@Override public void setState(String state) { StringBuilder sb = new StringBuilder(ui.getUiRootPath()); if (!ui.getUiRootPath().endsWith("/")) { // make sure there is a '/' between the root path and the // navigation state. sb.append('/'); } sb.append(state); URI location = ui.getPage().getLocation(); if (location != null) { ui.getPage().pushState(location.resolve(sb.toString())); } else { throw new IllegalStateException( "The Page of the UI does not have a location."); } } }
/** * Creates a navigation state manager for given UI. This method should take * into account any navigation related annotations. * * @param ui * the ui * @return the navigation state manager * * @since 8.2 */ protected NavigationStateManager createNavigationStateManager(UI ui) { if (ui.getClass().getAnnotation(PushStateNavigation.class) != null) { return new PushStateManager(ui); } // Fall back to old default return new UriFragmentManager(ui.getPage()); }
@Override public String getState() { // Get the current URL URI location = ui.getPage().getLocation(); String path = location.getPath(); if (ui.getUiPathInfo() != null && path.contains(ui.getUiPathInfo())) { // Split the path from after the UI PathInfo path = path.substring(path.indexOf(ui.getUiPathInfo()) + ui.getUiPathInfo().length()); } else if (path.startsWith(ui.getUiRootPath())) { // Use the whole path after UI RootPath String uiRootPath = ui.getUiRootPath(); path = path.substring(uiRootPath.length()); } else { throw new IllegalStateException(getClass().getSimpleName() + " is unable to determine the view path from the URL."); } if (path.startsWith("/")) { // Strip leading '/' path = path.substring(1); } return path; }
/** * Shows a notification consisting of a bigger caption and a smaller * description. The position and behavior of the message depends on the * type, which is one of the basic types defined in {@link Notification} , * for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to avoid XSS vulnerabilities if html content is * allowed. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message caption * @param description * The message description * @param type * The type of message * @param htmlContentAllowed * Whether html in the caption and description should be * displayed as html or as plain text * * @deprecated As of 7.0, use new Notification(...).show(Page). */ @Deprecated public void showNotification(String caption, String description, Notification.Type type, boolean htmlContentAllowed) { getPage().showNotification(new Notification(caption, description, type, htmlContentAllowed)); }
sharedParameterActionNameMap.put(actionKey, name); sharedParameterActionValueMap.put(actionKey, value); uI.getPage().setLocation(actionUrl.toString()); } else {
/** * Shows a notification message on the middle of the UI. The message * automatically disappears ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption is * rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message * * @deprecated As of 7.0, use Notification.show instead but be aware that * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption) { Notification notification = new Notification(caption); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification consisting of a bigger caption and a smaller * description on the middle of the UI. The message automatically disappears * ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The caption of the message * @param description * The message description * * @deprecated As of 7.0, use new Notification(...).show(Page) instead but * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description) { Notification notification = new Notification(caption, description); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
eventActionDestinationMap.put(actionKey, name); eventActionValueMap.put(actionKey, value); uI.getPage().setLocation(actionUrl.toString()); } else {
/** * Shows a notification message the UI. The position and behavior of the * message depends on the type, which is one of the basic types defined in * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to to avoid XSS vulnerabilities as the caption is * rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message * @param type * The message type * * @deprecated As of 7.0, use Notification.show instead but be aware that * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption, Notification.Type type) { Notification notification = new Notification(caption, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification consisting of a bigger caption and a smaller * description. The position and behavior of the message depends on the * type, which is one of the basic types defined in {@link Notification} , * for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The caption of the message * @param description * The message description * @param type * The message type * * @deprecated As of 7.0, use new Notification(...).show(Page) instead but * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description, Notification.Type type) { Notification notification = new Notification(caption, description, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
@Override public void setNavigator(Navigator navigator) { if (popStateListenerRegistration != null) { popStateListenerRegistration.remove(); popStateListenerRegistration = null; } if (navigator != null) { popStateListenerRegistration = ui.getPage().addPopStateListener( event -> navigator.navigateTo(getState())); } }
/** * Load and initialize the mobile drag-drop-polyfill if needed and not yet * done so. */ private void loadMobileHtml5DndPolyfill() { if (mobileHtml5DndPolyfillLoaded) { return; } if (!getPage().getWebBrowser().isTouchDevice()) { return; } mobileHtml5DndPolyfillLoaded = true; String vaadinLocation = getSession().getService().getStaticFileLocation( VaadinService.getCurrentRequest()) + "/VAADIN/"; getPage().addDependency(new Dependency(Type.JAVASCRIPT, vaadinLocation + ApplicationConstants.MOBILE_DND_POLYFILL_JS)); getRpcProxy(PageClientRpc.class).initializeMobileHtml5DndPolyfill(); }
dependencies.addAll(ui.getPage().getPendingDependencies()); dependencies.addAll(Dependency.findDependencies(newConnectorTypes, manager, new FilterContext(session)));
Page page = getPage();
@Override public void attach(AttachEvent attachEvent) { getUI().getPage().getStyles().add(".preview { width:225px; }"); } });