@Override public void onComponentEvent(AttachEvent event) { if (event.isInitialAttach()) { localize = true; } }
@Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); attachEvent.getUI().beforeClientResponse(this, context -> { drawChart(); if (configuration != null) { // Start listening to data series events once the chart has been // drawn. configuration.addChangeListener(changeListener); } }); }
AttachEvent attachEvent = new AttachEvent(component, initialAttach); component.onAttach(attachEvent); fireEvent(component, attachEvent);
@Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); UI ui = attachEvent.getUI(); elementTest.addClickListener(e -> { new Thread(new ElementAPI(ui)).start(); }); execJsTest.addClickListener(e -> { new Thread(new ExecJS(ui)).start(); }); ui.getPage().executeJavaScript( "$0.setText = function(text) {$0.innerText=text;}", label); callFunctionTest.addClickListener(e -> { new Thread(new CallFunction(ui)).start(); }); }
@Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); if (getLocale() == null) { setLocale(attachEvent.getUI().getLocale()); } initConnector(); }
if (event.isInitialAttach()) { LocalizationProvider.localize(localization).ifPresent(m -> operation.accept(m));
@Override protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); UI ui = attachEvent.getUI(); // Fallback transport is forced to websocket so that we either get a // websocket connection or no push connection at all ui.getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET); add(new NativeButton("Say hello", e -> { add(new Paragraph("Hello")); new Thread(new SayWorld(ui)).start(); })); } }
@Override public LocalDateTimeInputBuilder updateLocaleOnAttach(boolean updateLocaleOnAttach) { // unregister previous if (contextLocaleOnAttachRegistration != null) { contextLocaleOnAttachRegistration.remove(); contextLocaleOnAttachRegistration = null; } contextLocaleOnAttachRegistration = getComponent().addAttachListener(e -> { if (e.isInitialAttach()) { Locale componentLocale = getComponent().getLocale(); Locale currentLocale = LocalizationProvider.getCurrentLocale().orElse(null); if (currentLocale != null && !Objects.equals(currentLocale, componentLocale)) { getComponent().setLocale(currentLocale); } } }); return getConfigurator(); }
@Override public LocalDateInputBuilder updateLocaleOnAttach(boolean updateLocaleOnAttach) { // unregister previous if (contextLocaleOnAttachRegistration != null) { contextLocaleOnAttachRegistration.remove(); contextLocaleOnAttachRegistration = null; } contextLocaleOnAttachRegistration = getComponent().addAttachListener(e -> { if (e.isInitialAttach()) { Locale componentLocale = getComponent().getLocale(); Locale currentLocale = LocalizationProvider.getCurrentLocale().orElse(null); if (currentLocale != null && !Objects.equals(currentLocale, componentLocale)) { getComponent().setLocale(currentLocale); } } }); return getConfigurator(); }
@Override public Input<LocalDate> build() { final DatePicker component = getComponent(); // calendar localization if (localization != null) { if (isDeferredLocalizationEnabled()) { final CalendarLocalization localizationOnAttach = localization; component.addAttachListener(e -> { if (e.isInitialAttach()) { component.setI18n(localize(localizationOnAttach)); } }); } else { component.setI18n(localize(localization)); } } return Input.builder(component).requiredPropertyHandler((f, c) -> f.isRequired(), (f, c, v) -> f.setRequired(v)) .labelPropertyHandler((f, c) -> c.getLabel(), (f, c, v) -> c.setLabel(v)) .placeholderPropertyHandler((f, c) -> c.getPlaceholder(), (f, c, v) -> c.setPlaceholder(v)) .focusOperation(f -> f.focus()).hasEnabledSupplier(f -> f) .invalidChangeEventNotifierSupplier( f -> listener -> RegistrationAdapter.adapt(f.addInvalidChangeListener(e -> listener .onInvalidChangeEvent(new DefaultInvalidChangeEvent(e.isFromClient(), f))))) .withValueChangeListeners(valueChangeListeners).build(); }
final CalendarLocalization localizationOnAttach = localization; component.addAttachListener(e -> { if (e.isInitialAttach()) { component.setI18n(localize(localizationOnAttach));