Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin8 Use binder without pojo object

Giovanni Adobati
5 years ago Apr 04, 2017 8:45am

Hi, 

what is the best way to use the Binder without a pojo class in vaadin8 ?

In my case, i do not use pojo because my crud are meta-data driven.

For instance:
Metadata: FieldName, FieldType, IsMandatory.......
Data: LinkedHashMap of Key / Value

Bind a TextField with FieldName , the value get and set are from the LinkedHashMa get(FieldName) put(FieldName)

Thankx for the help

Giovanni Adobati
5 years ago Apr 05, 2017 1:53pm
David Marko
5 years ago Apr 07, 2017 4:42pm
Jean-Christophe Gueriaud
5 years ago Apr 07, 2017 5:33pm
Giovanni Adobati
5 years ago Apr 08, 2017 7:31am
David Marko
5 years ago Apr 10, 2017 6:28am
uros kristan
4 years ago Jul 03, 2017 10:44am
Ilia Motornyi
4 years ago Jul 25, 2017 7:46am
Ilia Motornyi
4 years ago Jul 25, 2017 7:51am

David Marko: In documentation there is PropertysetItem option https://vaadin.com/vaadin-documentation-portlet/framework/datamodel/datamodel-items.html   ... but my project cant find such class in Vaadin 8.

Unfortunately, you run into old part of the documentation specific to Vaadin 7. We will remove the pages, most probably.

Old, Vaadin7-compatible API still exists in Vaadin 8, in legacy packages (maven artifacts named vaadin-compatibility-server etc), but all that API is moved to com.vaadin.v7.* packages, and you can use the API if you still need that for some reason.

Robert Carnecky
4 years ago Aug 02, 2017 11:25pm
@Ilia

: I think we lost the track - the question starting the thread was how to dynamically bind data without POJO, when Field type, converter, validators etc. are not known at compile time. It is possible, but IMO it's a huge step back compared with Vaadin7. For example, you replaced the Property interface by the HasValue interface, that can be parametrized. But you removed the getType() API method that I need if the types are not known at compile time. You replaced the API by Java 8 compiler features. But that's not the same!

Looking at your examples in the documentation, everything I see is a TextField bound with a String POJO property. Nice, simple Hello World example, all types are known at compile time, lambdas work as expected, we are writing less code compared to Vaadin7. In such a simple case yes. But the real code is typically more complex. For example, I do not save anything if I need to declare repeatedly a converter for all my non-string fields. Years ago we were advised from Vaadin consultancy to use a ConverterFactory. Introduced in Vaadin7, the API was removed without any replacement in Vaadin8. Now we have in our framework more than 100 Converters (not so bad, the V8 Converters are very similar) and we need to write our own Converter Factory mechanism. We save nothing. Neither money nor time. And who knows, maybe in Vaadin 9 you will replace the Binder with a SuperBinder changing again everything.

Changing public API without a workaround is always a bad idea.