public class AddressFormExample extends TestBase {
@Override
protected void setup() {
getMainWindow().setLocale(Locale.ENGLISH);
Address address = new Address("Ruukinkatu 2-4", 20540, "Turku");
final AddressField field = new AddressField();
field.setValue(address);
field.setRequired(true);
addComponent(field);
Button commitButton = new Button("Save", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
field.commit();
Address address = field.getValue();
Notification.show("Address saved: "
+ address.getStreetAddress() + ", "
+ address.getPostalCode() + ", " + address.getCity());
}
});
addComponent(commitButton);
}