Search in sources :

Example 1 with BindingManager

use of org.linkki.core.binding.BindingManager in project linkki by linkki-framework.

the class MessageUI method init.

@Override
protected void init(VaadinRequest request) {
    Page.getCurrent().setTitle("linkki Samples :: Validation Messages");
    VaadinSession.getCurrent().setConverterFactory(new LinkkiConverterFactory());
    MessagesPanel messagesPanel = new MessagesPanel();
    messagesPanel.setVisible(false);
    User user = new User();
    RegistrationSectionPmo registrationPmo = new RegistrationSectionPmo(user, u -> handleRegistration(messagesPanel, u));
    // tag::validation-service[]
    validationService = new RegistrationValidationService(registrationPmo);
    bindingManager = new RegistrationBindingManager(validationService, ml -> messagesPanel.updateMessages(ml));
    // end::validation-service[]
    DefaultPmoBasedSectionFactory sectionFactory = new DefaultPmoBasedSectionFactory();
    AbstractSection section = sectionFactory.createSection(registrationPmo, bindingManager.getExistingContextOrStartNewOne(getClass()));
    setContent(new VerticalLayout(messagesPanel, section));
}
Also used : MessagesPanel(org.linkki.samples.messages.components.MessagesPanel) ValoTheme(com.vaadin.ui.themes.ValoTheme) RegistrationSectionPmo(org.linkki.samples.messages.pmo.RegistrationSectionPmo) AbstractSection(org.linkki.core.ui.section.AbstractSection) ValidationMode(org.linkki.samples.messages.pmo.RegistrationValidationService.ValidationMode) VerticalLayout(com.vaadin.ui.VerticalLayout) DefaultPmoBasedSectionFactory(org.linkki.core.ui.section.DefaultPmoBasedSectionFactory) UI(com.vaadin.ui.UI) VaadinRequest(com.vaadin.server.VaadinRequest) BindingManager(org.linkki.core.binding.BindingManager) Theme(com.vaadin.annotations.Theme) MessagesPanel(org.linkki.samples.messages.components.MessagesPanel) User(org.linkki.samples.messages.model.User) VaadinSession(com.vaadin.server.VaadinSession) Notification(com.vaadin.ui.Notification) LinkkiConverterFactory(org.linkki.core.ui.converters.LinkkiConverterFactory) Page(com.vaadin.server.Page) RegistrationValidationService(org.linkki.samples.messages.pmo.RegistrationValidationService) RegistrationBindingManager(org.linkki.samples.messages.binding.RegistrationBindingManager) User(org.linkki.samples.messages.model.User) DefaultPmoBasedSectionFactory(org.linkki.core.ui.section.DefaultPmoBasedSectionFactory) RegistrationSectionPmo(org.linkki.samples.messages.pmo.RegistrationSectionPmo) LinkkiConverterFactory(org.linkki.core.ui.converters.LinkkiConverterFactory) AbstractSection(org.linkki.core.ui.section.AbstractSection) VerticalLayout(com.vaadin.ui.VerticalLayout) RegistrationBindingManager(org.linkki.samples.messages.binding.RegistrationBindingManager) RegistrationValidationService(org.linkki.samples.messages.pmo.RegistrationValidationService)

Example 2 with BindingManager

use of org.linkki.core.binding.BindingManager in project linkki by linkki-framework.

the class BindingSampleUI method init.

@Override
protected void init(VaadinRequest request) {
    Page.getCurrent().setTitle("linkki Sample :: Bindings");
    List<Contact> personStorage = new ArrayList<>();
    BindingManager bindingManager = new DefaultBindingManager(ValidationService.NOP_VALIDATION_SERVICE);
    BindingContext context = bindingManager.startNewContext("binding-sample");
    ContactComponent contactComponent = new ContactComponent(p -> save(p, personStorage), context);
    ContactsTableComponent contactsTable = new ContactsTableComponent(personStorage, contactComponent::editContact, context);
    bindingManager.addUiUpdateObserver(contactsTable);
    HorizontalSplitPanel panel = new HorizontalSplitPanel(contactComponent, contactsTable);
    panel.setLocked(true);
    setContent(panel);
}
Also used : DefaultBindingManager(org.linkki.core.binding.DefaultBindingManager) BindingManager(org.linkki.core.binding.BindingManager) ContactsTableComponent(org.linkki.samples.binding.components.ContactsTableComponent) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ArrayList(java.util.ArrayList) ContactComponent(org.linkki.samples.binding.components.ContactComponent) BindingContext(org.linkki.core.binding.BindingContext) DefaultBindingManager(org.linkki.core.binding.DefaultBindingManager) Contact(org.linkki.samples.binding.model.Contact)

Aggregations

BindingManager (org.linkki.core.binding.BindingManager)2 Theme (com.vaadin.annotations.Theme)1 Page (com.vaadin.server.Page)1 VaadinRequest (com.vaadin.server.VaadinRequest)1 VaadinSession (com.vaadin.server.VaadinSession)1 HorizontalSplitPanel (com.vaadin.ui.HorizontalSplitPanel)1 Notification (com.vaadin.ui.Notification)1 UI (com.vaadin.ui.UI)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 ArrayList (java.util.ArrayList)1 BindingContext (org.linkki.core.binding.BindingContext)1 DefaultBindingManager (org.linkki.core.binding.DefaultBindingManager)1 LinkkiConverterFactory (org.linkki.core.ui.converters.LinkkiConverterFactory)1 AbstractSection (org.linkki.core.ui.section.AbstractSection)1 DefaultPmoBasedSectionFactory (org.linkki.core.ui.section.DefaultPmoBasedSectionFactory)1 ContactComponent (org.linkki.samples.binding.components.ContactComponent)1 ContactsTableComponent (org.linkki.samples.binding.components.ContactsTableComponent)1 Contact (org.linkki.samples.binding.model.Contact)1 RegistrationBindingManager (org.linkki.samples.messages.binding.RegistrationBindingManager)1