Beans & HasValue / Editing multiple types in Grid


I have two (conceptual) questions which arise from the same use case. Let me first briefly describe what I want to do.
In my application, I am dealing with variants of a particular thing at various places. For example, consider displaying several types of car components (tire, steering wheel, motor, …). What makes this difficult is that there hardly are any common properties to these objects, yet I have to display all of them in a list / grid environment. I solve this problem by case distinctions in the column component renderer (with a single column for actual representation + several columns for selection, deletion, reordering, etc.).

However, now I also want to edit these components (change the size of a tire, change the color of the wheel, etc.). The binder / Grid-editor approach doesn’t really work out of the box - the property of the “main” column is the whole bean (which could be of different types and require different editor components). I’m currently tinkering around with a “meta”-component which also implements HasValue and selects the editor representation based on the given bean. But this a) feels super hacky and b) brings its own problems.

It seems to me that the whole Binder / HasValue framework is only designed to work for a single type of bean with only immutable properties. For example, HasValue hard-codes “old value” which doesn’t make sense for bean properties. Dually, a Binder needs a mutable object.

I am quite certain that I am not the only one with this scenario, since it seems quite straightforward (for example, editing a bean containing a list of beans – in order to use a binder you’d need to have a HasValue<.., List<BEAN>> etc.). So the question is: Am I missing something? Vaadin is around for quite some time so there very likely is some sane reasoning behind the design choices which seem to elude me. Or the Binder / HasValue framework only is meant for simple cases and more advanced editing frameworks have to be built from the ground up? (Which sucks since I can’t really use the Grid-Editor then, since they are tied together so strongly. Or maybe it is possible to extend the Editor to simply ignore the binder related things.)



I’ve had a similar problem and ended up creating a Binder collection. Basically a Map of binders and their respective beans and it has methods for writeBeans, isValid etc. Somewhat crude but gets the job done when there are multiple beans and/or beans of different types. LMK if you need a copy.


In my apps I have had issues to edit also simple collections with static item type, so it might indeed be something where we have some gaps to fill. Would be nice to see the solution Martin has put together. Would you share that somehow?

I’m one of the product owners at Vaadin and I have had a dream about improving form binding in Vaadin now for two years, but hopefully we can get on it this year. I have a bunch of other enhancement we’ll probably tackle first, but this might be an issue to add to our TODO.