@Override public void afterNavigation(AfterNavigationEvent event) { // <2> /* handle the parameters value */ Notification.show("Parameter value: " + this.parameter); }
/** * Shows a notification in the current page with given text. * <p> * This is the convenience method for {@link #show(String, int, Position)} * which uses default web-component values for duration (which is 5000 ms) * and position ({@literal Position.BOTTOM_START}). * * * @param text * the text of the Notification * @return the notification */ public static Notification show(String text) { return show(text, DEFAULT_DURATION, DEFAULT_POSITION); }
@Override public void showError(CrudOperation operation, Exception e) { if (errorListener != null) { errorListener.accept(e); } else { if (CrudOperationException.class.isAssignableFrom(e.getClass())) { // FIXME no Notification.Type Notification.show(e.getMessage()); } else { Notification.show(e.getMessage()); throw new RuntimeException("Error executing " + operation.name() + " operation", e); } } }
@OnShow // <1> public void processParameters() { /* handle the parameters value */ Notification.show("Parameter value: " + this.parameter); }
@Override public void validationStatusChange(ValidationStatusEvent<S> statusChangeEvent) { if (statusChangeEvent.isInvalid()) { String error = showAllErrors ? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>")) : statusChangeEvent.getErrorMessage(); if (error == null || error.trim().equals("")) { error = "Validation error"; } if (notification != null) { notification.setText(error); notification.open(); } else { Notification.show(error); } } else { if (notification != null) { notification.close(); } } }
protected Button buildOperationButton(CrudOperation operation, T domainObject, ComponentEventListener<ClickEvent<Button>> clickListener) { if (clickListener == null) { return null; } String caption = buttonCaptions.get(operation); Icon icon = buttonIcons.get(operation); Button button = icon != null ? new Button(caption, icon) : new Button(caption); if (buttonStyleNames.containsKey(operation)) { buttonStyleNames.get(operation).stream().filter(styleName -> styleName != null).forEach(styleName -> button.addClassName(styleName)); } if (buttonThemes.containsKey(operation)) { button.getElement().setAttribute("theme", buttonThemes.get(operation)); } button.addClickListener(event -> { if (binder.writeBeanIfValid(domainObject)) { try { clickListener.onComponentEvent(event); } catch (Exception e) { showError(operation, e); } } else { Notification.show(validationErrorMessage); } }); return button; }
protected void findAllButtonClicked() { grid.asSingleSelect().clear(); refreshGrid(); Notification.show(String.format(rowCountCaption, grid.getDataProvider().size(new Query()))); }
public void listing28() { // tag::listing28[] PropertyListing.builder(SUBJECT) // .validationStatusHandler(event -> { // <1> if (event.isInvalid()) { Notification.show("Validation falied: " + event.getErrorMessage()); } }).validationStatusHandler(NAME, event -> { // <2> /* omitted */ }).build(); // end::listing28[] }
public void input36() { // tag::input36[] PropertyInputForm form = PropertyInputForm.formLayout(SUBJECT) // .validationStatusHandler(event -> { // <1> if (event.isInvalid()) { Notification.show("Validation falied: " + event.getErrorMessage()); } }).validationStatusHandler(NAME, event -> { // <2> /* omitted */ }).build(); // end::input36[] }
public void listing18() { // tag::listing18[] PropertyListing listing = PropertyListing.builder(SUBJECT) // .contextMenu() // <1> .withItem("Context menu item 1") // <2> .withClickListener(e -> { // <3> PropertyBox rowItem = e.getItem(); // <4> e.getItemListing(); // <5> Notification.show("Context menu item clicked on row id " + rowItem.getValue(ID)); }).add() // <6> .withItem("Context menu item 2", "item.message.code", e -> { /* do something */}) // <7> .withItem(new Button("Context menu item 3"), e -> { /* do something */}) // <8> .add() // <9> .build(); // end::listing18[] }
protected void showForm(CrudOperation operation, T domainObject, boolean readOnly, String successMessage, ComponentEventListener<ClickEvent<Button>> buttonClickListener) { Component form = crudFormFactory.buildNewForm(operation, domainObject, readOnly, cancelClickEvent -> { if (clickRowToUpdate) { grid.asSingleSelect().clear(); } else { T selected = grid.asSingleSelect().getValue(); crudLayout.hideForm(); grid.asSingleSelect().clear(); grid.asSingleSelect().setValue(selected); } }, operationPerformedClickEvent -> { crudLayout.hideForm(); buttonClickListener.onComponentEvent(operationPerformedClickEvent); Notification.show(successMessage); }); crudLayout.showForm(operation, form); }