Form : we must set itemDataSource before VisibleItemProperties ???

I don’t know if it’s a bug but in a Form if I setItemDataSource() AFTER setVisibleItemProperties() , the fields do not appear in correct order (depending the bean, but with an empty BeanItem that don’t work).
however, if i override setItemDataSource like that :

public void setItemDataSource(Item newDataSource) {
super.setItemDataSource(newDataSource, getVisibleItemProperties());

everything works fine !

I don’t like that solution, could you help me ?

note that I use Form with FormFieldFactory, and I extend Form class, and setVisibleItemProperties in the constructor.


Form.setItemDataSource(Item dataSource) resets the visible property ids:

public void setItemDataSource(Item newDataSource) {
            newDataSource != null ? newDataSource.getItemPropertyIds()
                    : null);

It can happen that the type of the new item is different from the old type, and the set of available properties differs. Therefore, Vaadin resets visible item properties when setting the data source.

It is true that in many/most cases, a Form is only used for items of one type. For these cases, it would be convenient to try to preserve the set of visible fields, but Vaadin cannot really know if this is the case for a particular call to setItemDataSource().