Project

General

Profile

« Previous | Next » 

Revision 1641827e

Added by Andreas Kohlbecker over 5 years ago

fix #7574 adding the ToOneRelatedEntityReloader to the TeamOrPerson and Person field directly

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
117 117
    protected Component initContent() {
118 118

  
119 119
        teamOrPersonSelect.addValueChangeListener(e -> {
120
            teamOrPersonSelect.refresh();
121 120
            setValue(teamOrPersonSelect.getValue(), false, true);
122 121
        });
123 122
        teamOrPersonSelect.setWidthUndefined();
......
348 347

  
349 348
    public void setFilterableTeamPagingProvider(CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> pagingProvider, CachingPresenter cachingPresenter){
350 349
        teamOrPersonSelect.loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
351
        ToOneRelatedEntityReloader<TeamOrPersonBase> teamOrPersonReloader = new ToOneRelatedEntityReloader<TeamOrPersonBase>(teamOrPersonSelect, cachingPresenter);
352
        teamOrPersonSelect.addValueChangeListener(teamOrPersonReloader );
350
        // NOTE:
351
        //   it is important to add the ToOneRelatedEntityReloader to the TeamOrPersonField directly
352
        //   since the value of the select will be immediately passed to the TeamOrPersonField
353
        ToOneRelatedEntityReloader<TeamOrPersonBase<?>> teamOrPersonReloader = new ToOneRelatedEntityReloader<TeamOrPersonBase<?>>(this, cachingPresenter);
354
        this.addValueChangeListener(teamOrPersonReloader);
353 355
    }
354 356

  
355 357
    public void setFilterablePersonPagingProvider(CdmFilterablePagingProvider<AgentBase, Person> pagingProvider, CachingPresenter cachingPresenter){
356 358

  
357
        teamOrPersonSelect.addValueChangeListener(new ToOneRelatedEntityReloader<TeamOrPersonBase>(teamOrPersonSelect, cachingPresenter));
358

  
359 359
        personsListEditor.setEntityFieldInstantiator(new EntityFieldInstantiator<PersonField>() {
360 360

  
361 361
            @Override
......
364 364
                f.setAllowNewEmptyEntity(true); // otherwise new entities can not be added to the personsListEditor
365 365
                f.getPersonSelect().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
366 366
                f.getPersonSelect().setCaptionGenerator(new TeamOrPersonBaseCaptionGenerator<Person>(cacheType));
367
                f.getPersonSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Person>(f.getPersonSelect(), cachingPresenter));
367
                // NOTE:
368
                //   it is important to add the ToOneRelatedEntityReloader to the PersonField directly
369
                //   since the value of the select will be immediately passed to the PersonField:
370
                f.addValueChangeListener(new ToOneRelatedEntityReloader<Person>(f, cachingPresenter));
368 371
                return f;
369 372
            }
370 373
        });

Also available in: Unified diff