List of usage examples for com.vaadin.tests.data.bean Country USA
Country USA
To view the source code for com.vaadin.tests.data.bean Country USA.
Click Source Link
From source file:com.mycompany.vaadinviews.FieldBinderWithBeanValidation.java
public FieldBinderWithBeanValidation() { //addComponent(log); //this.//w w w .j av a 2s. c om //getContent(). Layout layout = new VerticalLayout(); final BeanFieldGroup<PersonWithBeanValidationAnnotations> fieldGroup = new BeanFieldGroup<PersonWithBeanValidationAnnotations>( PersonWithBeanValidationAnnotations.class); fieldGroup.buildAndBindMemberFields(this); //fieldGroup. //Layout hlayout = new HorizontalLayout(); layout.addComponent(firstName); //layout.addComponent(hlayout); layout.addComponent(lastName); layout.addComponent(email); layout.addComponent(age); layout.addComponent(sex); layout.addComponent(deceased); Button commitButton = new Button("Commit", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String msg = "Commit succesful"; try { fieldGroup.commit(); } catch (CommitException e) { msg = "Commit failed: " + e.getMessage(); } Notification.show(msg); //log.log(msg); } }); Button discardButton = new Button("Discard", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { fieldGroup.discard(); //log.log("Discarded changes"); } }); Button showBean = new Button("Show bean values", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Notification.show(getPerson(fieldGroup).toString()); } }); layout.addComponent(commitButton); layout.addComponent(discardButton); layout.addComponent(showBean); sex.setPageLength(0); PersonWithBeanValidationAnnotations p = new PersonWithBeanValidationAnnotations("John", "Doe", "john@doe.com", 64, Sex.MALE, new Address("John street", 11223, "John's town", Country.USA)); fieldGroup.setItemDataSource(new BeanItem<PersonWithBeanValidationAnnotations>(p)); setContent(layout); }