List of usage examples for com.vaadin.data Binder Binder
public Binder()
From source file:org.jpos.qi.eeuser.UsersView.java
License:Open Source License
private Panel createPasswordPanel() { passwordPanel = new Panel(getApp().getMessage("changePassword")); passwordPanel.setIcon(VaadinIcons.LOCK); passwordPanel.addStyleName("color1"); passwordPanel.addStyleName("margin-top-panel"); VerticalLayout panelContent = new VerticalLayout(); panelContent.setSizeFull();// w w w . jav a 2s.co m panelContent.setMargin(true); panelContent.setSpacing(true); FormLayout form = new FormLayout(); form.setSizeFull(); panelContent.addComponent(form); panelContent.setExpandRatio(form, 1f); passwordBinder = new Binder<>(); passwordBinder.setReadOnly(true); binderIsReadOnly = true; if (selectedU.getId() != null) { currentPasswordField = new PasswordField(getApp().getMessage("passwordForm.currentPassword")); currentPasswordField.setWidth("80%"); passwordBinder.forField(currentPasswordField) .asRequired(getApp().getMessage("errorMessage.req", currentPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getCurrentPasswordMatchValidator()) .bind(string -> string, null); form.addComponent(currentPasswordField); } PasswordField newPasswordField = new PasswordField(getApp().getMessage("passwordForm.newPassword")); newPasswordField.setWidth("80%"); passwordBinder.forField(newPasswordField) .asRequired(getApp().getMessage("errorMessage.req", newPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getNewPasswordNotUsedValidator()) .bind(string -> string, null); form.addComponent(newPasswordField); repeatPasswordField = new PasswordField(getApp().getMessage("passwordForm.confirmPassword")); repeatPasswordField.setWidth("80%"); passwordBinder.forField(repeatPasswordField) .asRequired(getApp().getMessage("errorMessage.req", repeatPasswordField.getCaption())) .withValidator(((UsersHelper) getHelper()).getPasswordsMatchValidator(newPasswordField)) .bind(string -> string, null); form.addComponent(repeatPasswordField); passwordPanel.setVisible(forcePasswordChange); passwordPanel.setContent(panelContent); return passwordPanel; }
From source file:uk.q3c.krail.testapp.view.AccountsView.java
License:Apache License
public void fake() { Binder<Person> binder = new Binder<>(); TextField titleField = new TextField(); // Start by defining the Field instance to use binder.forField(titleField)//from w w w. ja v a2 s .co m // Finalize by doing the actual binding to the Person class .bind( // Callback that loads the title from a person instance Person::getTitle, // Callback that saves the title in a person instance Person::setTitle); TextField nameField = new TextField(); // Shorthand for cases without extra configuration binder.bind(nameField, Person::getName, Person::setName); }