Project

General

Profile

« Previous | Next » 

Revision f9fb33d5

Added by Andreas Kohlbecker about 6 years ago

fix #7246 consitent implementation of LazySelect reloading of modified entity beans:

  • ReloadableSelect interface for select fields which support reloading the selected value from the persitent storage
  • EntitySupport interface to ship around equality problems of enitites which have modified data

View differences:

src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
8 8
*/
9 9
package eu.etaxonomy.vaadin.component;
10 10

  
11
import org.vaadin.viritin.fields.LazyComboBox;
12 11
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
13 12
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
14 13

  
......
27 26
 * @since May 24, 2017
28 27
 *
29 28
 */
30
public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCustomField<V> implements ToOneRelatedEntityField<V> {
29
public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCustomField<V>
30
    implements ToOneRelatedEntityField<V>, ReloadableSelect, EntitySupport<V> {
31 31

  
32 32
    private static final long serialVersionUID = 6277565876657520311L;
33 33

  
......
37 37

  
38 38
    private CssLayout container = new CssLayout();
39 39

  
40
    private LazyComboBox<V> lazySelect;
40
    private ReloadableLazyComboBox<V> lazySelect;
41 41

  
42 42
    private Button addButton = new Button(FontAwesome.PLUS);
43 43
    private Button editButton  = new Button(FontAwesome.EDIT);
......
45 45
    public ToOneRelatedEntityCombobox(String caption, Class<V> type){
46 46
        this.type = type;
47 47
        setCaption(caption);
48
        lazySelect = new LazyComboBox<V>(type);
48
        lazySelect = new ReloadableLazyComboBox<V>(type);
49 49
        addStyledComponents(lazySelect, addButton, editButton);
50 50
        addSizedComponents(lazySelect, container);
51 51
        lazySelect.addValueChangeListener(e -> {
......
93 93
    /**
94 94
     * @return the select
95 95
     */
96
    public LazyComboBox<V> getSelect() {
96
    public ReloadableLazyComboBox<V> getSelect() {
97 97
        return lazySelect;
98 98
    }
99 99

  
......
108 108
    /**
109 109
     * reload the selected entity from the persistent storage
110 110
     */
111
    @Override
111 112
    public void reload() {
112
        getSelect().refresh();
113
        getSelect().discard(); // reload from data source
114

  
113
        getSelect().reload();
115 114
    }
116 115

  
117 116
    /**
......
148 147
        editButton.addClickListener(listener);
149 148
    }
150 149

  
150

  
151 151
    @Override
152
    public void selectNewItem(V bean){
153
        lazySelect.refresh();
154
        lazySelect.setValue(bean);
155
        lazySelect.markAsDirty();
152
    public void replaceEntityValue(V bean){
153
        lazySelect.replaceEntityValue(bean);
156 154
    }
157 155

  
156
    @Override
157
    public void selectNewItem(V bean){
158
        setValue(bean);
159
    }
158 160

  
159 161
    /**
160 162
     * Returns always currently selected item by

Also available in: Unified diff