Search in sources :

Example 1 with ContactsTableComponent

use of org.linkki.samples.playground.binding.components.ContactsTableComponent in project linkki by linkki-framework.

the class BindingSampleView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    removeAll();
    // can be switched with URL:
    // http://localhost:8080/linkki-sample-test-playground-vaadin23/binding/readOnly
    boolean readOnly = StringUtils.equals("readOnly", parameter);
    BindingManager bindingManager = new DefaultBindingManager(ValidationService.NOP_VALIDATION_SERVICE);
    // tag::property-behavior[]
    PropertyBehaviorProvider behaviorProvider = PropertyBehaviorProvider.with(PropertyBehavior.readOnly(() -> readOnly));
    // end::property-behavior[]
    // tag::property-behavior-binding-manager
    BindingContext context = bindingManager.createContext("binding-sample", behaviorProvider);
    // end::property-behavior-binding-manager
    ContactComponent contactComponent = new ContactComponent(p -> save(p, PERSON_STORAGE), context);
    ContactsTableComponent contactsTable = new ContactsTableComponent(PERSON_STORAGE, contactComponent::editContact, context);
    // Make ContactsTableComponent call uiUpdated explicitly to switch between label or table
    bindingManager.addUiUpdateObserver(contactsTable);
    SplitLayout panel = new SplitLayout(contactComponent, contactsTable);
    panel.setOrientation(Orientation.HORIZONTAL);
    panel.setSplitterPosition(50);
    panel.setSizeFull();
    add(panel);
    setSizeFull();
}
Also used : DefaultBindingManager(org.linkki.core.binding.manager.DefaultBindingManager) BindingManager(org.linkki.core.binding.manager.BindingManager) SplitLayout(com.vaadin.flow.component.splitlayout.SplitLayout) ContactsTableComponent(org.linkki.samples.playground.binding.components.ContactsTableComponent) ContactComponent(org.linkki.samples.playground.binding.components.ContactComponent) PropertyBehaviorProvider(org.linkki.core.binding.dispatcher.behavior.PropertyBehaviorProvider) BindingContext(org.linkki.core.binding.BindingContext) DefaultBindingManager(org.linkki.core.binding.manager.DefaultBindingManager)

Aggregations

SplitLayout (com.vaadin.flow.component.splitlayout.SplitLayout)1 BindingContext (org.linkki.core.binding.BindingContext)1 PropertyBehaviorProvider (org.linkki.core.binding.dispatcher.behavior.PropertyBehaviorProvider)1 BindingManager (org.linkki.core.binding.manager.BindingManager)1 DefaultBindingManager (org.linkki.core.binding.manager.DefaultBindingManager)1 ContactComponent (org.linkki.samples.playground.binding.components.ContactComponent)1 ContactsTableComponent (org.linkki.samples.playground.binding.components.ContactsTableComponent)1