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();
}
Aggregations