vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
620 stars 167 forks source link

Remove deprecated API and tools in Flow 24.0 #15665

Closed mshabarov closed 1 year ago

mshabarov commented 1 year ago

This ticket/PR has been released with Vaadin 24.2.0.alpha1 and is also targeting the upcoming stable 24.2.0 version.

MarcinVaadin commented 1 year ago

setDataProvider() is now deprecated (in Grid, Select, RadioButtonGroup, CheckboxGroup, ListBox and ComboBox) com.vaadin.flow.component.checkbox.CheckboxGroup.setDataProvider​(DataProvider<T, ?>) com.vaadin.flow.component.combobox.ComboBoxBase.setDataProvider​(DataProvider<TItem, String>) com.vaadin.flow.component.grid.Grid.setDataProvider​(DataProvider<T, ?>) com.vaadin.flow.component.listbox.ListBoxBase.setDataProvider​(DataProvider<ITEM, ?>) com.vaadin.flow.component.radiobutton.RadioButtonGroup.setDataProvider​(DataProvider<T, ?>) com.vaadin.flow.component.select.Select.setDataProvider​(DataProvider<T, ?>)

com.vaadin.flow.data.renderer.LitRenderer.getEventHandlers() com.vaadin.flow.data.renderer.LitRenderer.render​(Element, DataKeyMapper, Element) com.vaadin.flow.data.renderer.LitRenderer.withEventHandler​(String, SerializableConsumer) com.vaadin.flow.data.renderer.Renderer.getEventHandlers() com.vaadin.flow.data.renderer.Renderer.getValueProviders() com.vaadin.flow.data.renderer.Renderer.render​(Element, DataKeyMapper, Element) com.vaadin.flow.data.renderer.Renderer.setEventHandler​(String, SerializableConsumer) com.vaadin.flow.data.renderer.Renderer.setProperty​(String, ValueProvider<SOURCE, ?>) com.vaadin.flow.data.renderer.Rendering.getTemplateElement()

com.vaadin.flow.data.renderer.LocalDateRenderer​(ValueProvider<SOURCE, LocalDate>, DateTimeFormatter) com.vaadin.flow.data.renderer.LocalDateTimeRenderer​(ValueProvider<SOURCE, LocalDateTime>, DateTimeFormatter) com.vaadin.flow.data.renderer.Renderer​(String)

Are part of flow-components and will be removed as part of https://github.com/vaadin/flow-components/issues/4536

MarcinVaadin commented 1 year ago

Docs PR created https://github.com/vaadin/docs/pull/2036

MarcinVaadin commented 1 year ago

Documentation update: https://github.com/vaadin/docs/pull/2036

Projects to be checked after removing deprecated code:

vaithu commented 1 year ago
  • V24 upgrade instruction

Please let me know where I can find the equivalency for this image

I was told setItems is the equivalent but I do not see anything directly matches with the deprecated setDataProvider

vaithu commented 1 year ago

Also this page https://vaadin.com/docs/latest/upgrading/V23-V24-steps is missing. Getting 404 Not Found error

jouni commented 1 year ago

Fixed the link in the description (to point to https://vaadin.com/docs/latest/upgrading)

mshabarov commented 1 year ago
  • V24 upgrade instruction

Please let me know where I can find the equivalency for this image

I was told setItems is the equivalent but I do not see anything directly matches with the deprecated setDataProvider

@vaithu thanks for the question. Could you please describe what is your case? Do you use a DataProvider with a configured filter? I noticed that only for Grid we preserved setDataProvider as setItems cannot take DataProvider<T, F> if F is not Void. Seems like we miss that fact and changed public to private for ComboBox, which can be used with a filterable data provider as well. For other components, I think that setDataProvider can be replaced by setItems easily, because they are in memory data providers. So need you case to understand the problem better. Thanks!

vaithu commented 1 year ago

I'm working on V14 to V24 migration project. This is a framework https://github.com/holon-platform/holon-vaadin-flow written by someone else and now I'm trying to move them to V24.

The author has this

final DatastoreDataProvider<ITEM, ?> datastoreDataProvider = DatastoreDataProvider.create(datastore, target,
                getItemType());
        getComponent().setDataProvider(datastoreDataProvider);

and the error I'm getting is

image

If I change to setItems, the error is image

Note the component referred here ListBoxListDataView

mshabarov commented 1 year ago

@vaithu thanks for the example. So the component is ListBox. Your data provider has a generic type for filter (second type, which is a wildcard here): DatastoreDataProvider<ITEM, ?>. Do you use .setFilter() method of this data provider anywhere? If no, then you can replace the second type with Void and then you can use one of the existing setItems methods. If you do, then my question is what is the type of this data provider - in memory or callback (what is the extended class for it and what does isInMemory() returns) ?

vaithu commented 1 year ago

No. I do not see any setFilter there. DatastoreDataProvider<ITEM, ?> is extending vaadin interface DataProvider<T, F>. Also there is no isInMemory(). It is a call back method because I see some other example like

@Override
    public <FILTER> FilterableSingleSelectInputBuilder<T, ITEM> dataSource(DataProvider<ITEM, FILTER> dataProvider,
            SerializableFunction<String, FILTER> filterConverter) {
        getComponent().setDataProvider(dataProvider, filterConverter);
        return getConfigurator();
    }

Again this setDataProvider(dataProvider, filterConverter) is also not working.

mshabarov commented 1 year ago

I have a feeling that despite the DataView API is there and setItems methods are recommended methods to bind data items to components, we can’t completely get rid of DataProvider concept and API (DataView doesn’t fully overlap the API), thus, bringing back setDataProvider and getDataProvider as a public methods can be considered with preserving them@Deprecated with no removal flag, also saying that setItems is a recommended method, but setDataProvider is also an option when custom data provider has a filter and or one need to use data provider API directly, for instance, to add data provider listeners. I'll make a draft pull request to bring this API back.

vaithu commented 1 year ago

Thanks. That will help a lot because the previous versions heavily depends on this and there are 3rd party enhancements relies on this DataProvider. Also, just an idea/suggestion that if there is a way to redirect setDataProvider to setItems internally with same features/parameters that would be awesome. User will get same performance advantages with same setDataprovider