Help With Crud

I trying to create an sample with VaadinCrud

so I create this class:


@Slf4j
public class ParteCrud {


    public static CrudEditor<Parte> createCrudForm() {
        Binder<Parte> binder = new Binder<>(Parte.class);
        FormLayout form = new FormLayout();
        TextField nome = new TextField("Nome");
        form.add(nome);
        binder.forField(nome).asRequired(UIUtils.CAMPO_OBRIGATORIO_ERROR_MESSAGE).bind(Parte::getNome, Parte::setNome);
        return new BinderCrudEditor<>(binder, form);
    }
    @Slf4j
    public static class ParteDataProvider implements DataProvider<Parte, Long>{

        private Long id;
        private List<Parte> partes = new ArrayList<>();
        private boolean inMemory = true;
        private RestClient restClient;

        public ParteDataProvider() {
            partes.add(Parte.builder().nome("aaa").build());
            partes.add(Parte.builder().nome("bbb").build());
        }

        public ParteDataProvider(Long id) {
            this.id = id;
            this.inMemory = false;
        }

        public void save(Parte parte){
            log.info("save");
            if(inMemory)
                partes.add(parte);
        }


        @Override
        public boolean isInMemory() {
            log.info("isInMemory");
            return inMemory;
        }

        @Override
        public int size(Query<Parte, Long> query) {
            log.info("size");
            return this.partes.size();
        }

        @Override
        public Stream<Parte> fetch(Query<Parte, Long> query) {
            log.info("fetch");
            return partes.stream();
        }

        @Override
        public void refreshItem(Parte parte) {
            log.info("refresh");
        }

        @Override
        public void refreshAll() {
            log.info("refreshAll");
            if(!inMemory)
                try {
                    Response retorno = restClient.get("/processo/" + id + "/parte", null);
                    this.partes.addAll(retorno.readEntity(new GenericType<List<Parte>>() {}));
                }catch (RestClientException e){
                    e.printStackTrace();
                }
        }

        @Override
        public Registration addDataProviderListener(DataProviderListener<Parte> dataProviderListener) {
            return null;
        }
    }
}

and add with this code:

crud = new Crud<>(Parte.class, ParteCrud.createCrudForm());
        ParteCrud.ParteDataProvider dataProvider = new ParteCrud.ParteDataProvider();
        crud.setDataProvider(dataProvider);
        crud.addSaveListener(evt->dataProvider.save(evt.getItem()));
        add(crud);

Why my crud don’t update when I insert an item?

Tip to vaadin: create an better documentation. I have looked for entire site and don`t find anything about how create a custom dataProvider.

tks

In my code, the DataProvider extends AbstractBackEndDataProvider because that’s how it’s done in the documentation. But I created a generic data provider that I use for 7 different crud views so that I wouldn’t have to create 7 different data providers. The code is [here]
(https://vaadin.com/forum/thread/18217660/here-s-a-generic-data-provider-for-the-crud-component).

Tip to vaadin: create an better documentation. I have looked for entire site and don`t find anything about how create a custom dataProvider.

[here]
(https://vaadin.com/components/vaadin-crud/java-examples) is an example how to create a custom dataprovider for a crud in vaadins documentation. Just saying…