SlideShare a Scribd company logo
Paris Vaadin & GWT Meetup
Bio @nicolas_frankel
 Software Architect

 http://blog.frankel.ch & http://morevaadin.com

 Learning Vaadin

 Main interests:
      GUI
      Software quality
      Build automation
      New things!
Vaadin 7 revolutions

 SASS

 Connectors

 Client-side extensions

 …
Vaadin 7 evolutions

 Window API

 Javascript API

 FieldGroup

 Converter

 …
FieldGroup

 Remember the old Form?
   It coupled display & field handling
   It is deprecated

 Use FieldGroup
   And set the layout you want!
Data binding levels

1. Property
   Single value
     Birthdate

2. Item
   Connected properties
     First name, last name, birthdate

3. Container
   Collection of items
Example

Person person = new Person(1L);

person.setFirstName("John");

person.setLastName("Doe");

person.setBirthdate(new Date(0));

BeanItem<Person> item = new BeanItem<Person>(person);
Naive implementation

TextField id = new TextField (item.getItemProperty("id"));

TextField firstName = new TextField(item.getItemProperty("firstName"));

TextField lastName = new TextField(item.getItemProperty("lastName"));

DateField birthdate = new DateField(item.getItemProperty("birthdate"));

Layout layout = new FormLayout(id, firstName, lastName, birthdate);
Result
FieldGroup implementation

FieldGroup group = new FieldGroup(item);

Field<?> id = group.buildAndBind("id");

Field<?> firstName = group.buildAndBind("firstName");

Field<?> lastName = group.buildAndBind("lastName");

Field<?> birthdate = group.buildAndBind("birthdate");

Layout layout = new VerticalLayout(id, firstName, lastName, birthdate);
Result
Vaadin 7 FieldGroup & Converter
Custom FieldGroupFieldFactory
@Override
public <T extends Field> T createField(Class<?> dataType, Class<T>
fieldType) {
       if (dataType.isAssignableFrom(Date.class)) {
               return (T) new DateField();
       }
       return delegate.createField(dataType, fieldType);
}
Rework

group.setFieldFactory(new CustomFieldGroupFieldFactory());

Layout layout = new FormLayout(id, firstName, lastName, birthdate);
Result
Final rework

Field<?> id = group.buildAndBind(null, "id");

Field<?> firstName = group.buildAndBind("Given name", "firstName");

Field<?> lastName = group.buildAndBind("Family name", "lastName");
Result
Converters

 Separate model values from their String representations

 Provides ways to convert
   From String to model
   And back
Converter hierarchy
Requirements

 No side-effects, including GUI changes

 Method implementation need to be symmetric
Implementation

TextField tf = new TextField();

tf.setConverter(new StringToIntegerConverter());

int i = (Integer) tf.getConvertedValue();
@learnvaadin
Thanks… & questions?

More Related Content

DOCX
java experiments and programs
PDF
The Ring programming language version 1.5.2 book - Part 44 of 181
PPTX
Is2215 lecture8 relational_databases
PDF
The Ring programming language version 1.4.1 book - Part 18 of 31
PDF
The Ring programming language version 1.5.4 book - Part 42 of 185
PDF
The Ring programming language version 1.3 book - Part 83 of 88
PDF
The Ring programming language version 1.8 book - Part 43 of 202
PDF
Green dao
java experiments and programs
The Ring programming language version 1.5.2 book - Part 44 of 181
Is2215 lecture8 relational_databases
The Ring programming language version 1.4.1 book - Part 18 of 31
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.8 book - Part 43 of 202
Green dao

What's hot (20)

ODP
WorkingWithSlick2.1.0
PDF
The Ring programming language version 1.10 book - Part 22 of 212
PDF
The Ring programming language version 1.5 book - Part 8 of 31
PPTX
Introduction to JQuery
PDF
The Ring programming language version 1.2 book - Part 19 of 84
PDF
Experiment no 2
PDF
The Ring programming language version 1.5.1 book - Part 43 of 180
PDF
The Ring programming language version 1.7 book - Part 48 of 196
PDF
The Ring programming language version 1.7 book - Part 41 of 196
PDF
The Ring programming language version 1.5.3 book - Part 30 of 184
PDF
The Ring programming language version 1.4.1 book - Part 13 of 31
PDF
The Ring programming language version 1.4 book - Part 8 of 30
PDF
The Ring programming language version 1.5.2 book - Part 29 of 181
PDF
Green dao
PPTX
Hibernate online training
PDF
Sistema de ventas
PDF
The Ring programming language version 1.9 book - Part 54 of 210
PDF
The Ring programming language version 1.9 book - Part 53 of 210
PPT
Django Search
PPTX
MongoDB and Indexes - MUG Denver - 20160329
WorkingWithSlick2.1.0
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.5 book - Part 8 of 31
Introduction to JQuery
The Ring programming language version 1.2 book - Part 19 of 84
Experiment no 2
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.4.1 book - Part 13 of 31
The Ring programming language version 1.4 book - Part 8 of 30
The Ring programming language version 1.5.2 book - Part 29 of 181
Green dao
Hibernate online training
Sistema de ventas
The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 53 of 210
Django Search
MongoDB and Indexes - MUG Denver - 20160329
Ad

Similar to Vaadin 7 FieldGroup & Converter (20)

PDF
Vaadin 7
PDF
Vaadin 7 by Joonas Lehtinen
PDF
PDF
Rich Internet Applications con JavaFX e NetBeans
PPTX
PDF
Building complex UI on Android
KEY
Processing & Dataviz
PDF
Vaadin 8 - Data Binding with Binder
PDF
4.trasformers filters-adapters
PDF
Objects First With Java A Practical Introduction Using Bluej 1st Edition Davi...
PDF
MIDP GUI Development: Alert, List, Form, TextBox
PDF
Vaadin 7
PDF
Vaadin 7 CN
PPTX
Nokia Asha App Development - Part 2
PDF
Vaadin JPAContainer
PPTX
Java Data Migration with Data Pipeline
PPT
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
PDF
Introduction to Griffon
PDF
PDF
Rc085 010d-vaadin7
Vaadin 7
Vaadin 7 by Joonas Lehtinen
Rich Internet Applications con JavaFX e NetBeans
Building complex UI on Android
Processing & Dataviz
Vaadin 8 - Data Binding with Binder
4.trasformers filters-adapters
Objects First With Java A Practical Introduction Using Bluej 1st Edition Davi...
MIDP GUI Development: Alert, List, Form, TextBox
Vaadin 7
Vaadin 7 CN
Nokia Asha App Development - Part 2
Vaadin JPAContainer
Java Data Migration with Data Pipeline
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Introduction to Griffon
Rc085 010d-vaadin7
Ad

More from Nicolas Fränkel (20)

PPTX
SnowCamp - Adding search to a legacy application
PPTX
Un CV de dévelopeur toujours a jour
PPTX
Zero-downtime deployment on Kubernetes with Hazelcast
PDF
jLove - A Change-Data-Capture use-case: designing an evergreen cache
PPTX
BigData conference - Introduction to stream processing
PPTX
ADDO - Your own Kubernetes controller, not only in Go
PPTX
TestCon Europe - Mutation Testing to the Rescue of Your Tests
PPTX
OSCONF Jaipur - A Hitchhiker's Tour to Containerizing a Java application
PPTX
GeekcampSG 2020 - A Change-Data-Capture use-case: designing an evergreen cache
PPTX
JavaDay Istanbul - 3 improvements in your microservices architecture
PPTX
OSCONF Hyderabad - Shorten all URLs!
PPTX
Devclub.lv - Introduction to stream processing
PPTX
OSCONF Koshi - Zero downtime deployment with Kubernetes, Flyway and Spring Boot
PPTX
JOnConf - A CDC use-case: designing an Evergreen Cache
PPTX
London In-Memory Computing Meetup - A Change-Data-Capture use-case: designing...
PPTX
JUG Tirana - Introduction to data streaming
PPTX
Java.IL - Your own Kubernetes controller, not only in Go!
PPTX
vJUG - Introduction to data streaming
PPTX
London Java Community - An Experiment in Continuous Deployment of JVM applica...
PPTX
OSCONF - Your own Kubernetes controller: not only in Go
SnowCamp - Adding search to a legacy application
Un CV de dévelopeur toujours a jour
Zero-downtime deployment on Kubernetes with Hazelcast
jLove - A Change-Data-Capture use-case: designing an evergreen cache
BigData conference - Introduction to stream processing
ADDO - Your own Kubernetes controller, not only in Go
TestCon Europe - Mutation Testing to the Rescue of Your Tests
OSCONF Jaipur - A Hitchhiker's Tour to Containerizing a Java application
GeekcampSG 2020 - A Change-Data-Capture use-case: designing an evergreen cache
JavaDay Istanbul - 3 improvements in your microservices architecture
OSCONF Hyderabad - Shorten all URLs!
Devclub.lv - Introduction to stream processing
OSCONF Koshi - Zero downtime deployment with Kubernetes, Flyway and Spring Boot
JOnConf - A CDC use-case: designing an Evergreen Cache
London In-Memory Computing Meetup - A Change-Data-Capture use-case: designing...
JUG Tirana - Introduction to data streaming
Java.IL - Your own Kubernetes controller, not only in Go!
vJUG - Introduction to data streaming
London Java Community - An Experiment in Continuous Deployment of JVM applica...
OSCONF - Your own Kubernetes controller: not only in Go

Vaadin 7 FieldGroup & Converter