"Directly" inserting and removing rows in a V8 Grid

I’ve been struggling with this since I saw the 1st news about Vaadin 8 and I have yet to see a satisfactory answer.

I don’t want to write a class for every data I want to display in a listing. My app has tens of reports of “simple” data coming mainly from database queries; most of them even have their database View in order to customize some attributes like column names or derivated columns. Why in do world would I want to have to write a class for each of those?? It goes against the principle of automation, genericism and reusing code.

I have nothing against the new data providing mechanism for grids and tables, but there should be other ways. I think that, at least, directly adding and removing “items” the old way, in memory, should have been kept. It’s a basical feature that any framework does allow, otherwise limiting functionality severely.

This is the main reason that is preventing my organization from updating to v8, and I understand we can’t be forever stuck in an obsolete version.

I’ve seen some recomendations here and there on how to accomplish this, but I find all of them more or less cumbersome to a certain degree, and the extra paraphernalia needed to get them working is really keeping me away from attempting them.

If you are looking for something that is roughly equivalent to old GeneratedPropertyColumn, you give ValueProvider to addColumn(…) method as a lambda expression, like

grid.addColumn(address->address.getStreet()).setCaption(“Street”);

But in most cases it is better to create e.g. DTO bean and use that.

Vaadin Grid doesn’t neccessarely need to be backed by Java Beans. It all comes down to the column value provider implementation. Here’s an example of a HashMap backed Grid, where columns and rows are added dynamically:



See the full sample on vaadinfiddle.com

Also note that if you want, you can still use the v7 type of data binding with the compatibility package. This applies to Grid as well, just as long as you use the one from the .v7 package.

-Olli