Project

General

Profile

« Previous | Next » 

Revision ddb31e64

Added by Andreas Kohlbecker about 5 years ago

  • ID ddb31e64c51be1fd555999535863cebe68a6bd8d
  • Parent 77056dda

fix #8214 fixing required validation for WeaklyRelatedEntityCombobox and centralizing related messages

View differences:

src/main/java/eu/etaxonomy/vaadin/component/WeaklyRelatedEntityCombobox.java
14 14
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
15 15

  
16 16
import com.vaadin.data.Property;
17
import com.vaadin.data.Validator.InvalidValueException;
17 18
import com.vaadin.data.fieldgroup.FieldGroup;
18 19
import com.vaadin.data.util.converter.Converter.ConversionException;
20
import com.vaadin.server.AbstractErrorMessage.ContentMode;
21
import com.vaadin.server.ErrorMessage.ErrorLevel;
22
import com.vaadin.server.UserError;
19 23
import com.vaadin.ui.Button;
20 24
import com.vaadin.ui.Button.ClickListener;
21 25
import com.vaadin.ui.Component;
......
63 67
        addSizedComponents(lazySelect, container);
64 68
        buttonUpdater = new WeaklyRelatedEntityButtonUpdater(this);
65 69
        lazySelect.addValueChangeListener(buttonUpdater);
70
        lazySelect.setValidationVisible(true);
66 71
        lazySelect.addValueChangeListener(e -> {
67 72
            // update the itemContainer immediately so that the edit button acts on the chosen item
73
            // TODO compare with ToOneRelatedEntityCombobox where getValue() is overwritten to call
74
            //  commitSelect();; would this help in this class also?
75
            try {
68 76
            lazySelect.commit();
77
            } catch (InvalidValueException ie){
78
                /* Ignore here */
79
            }
69 80
        });
70 81
    }
71 82

  
......
172 183
        setValue(bean);
173 184
    }
174 185

  
175
    /**
176
     * Returns always currently selected item by
177
     *
178
     * {@inheritDoc}
179
     */
180
    @Override
181
    public String getValue() {
182
        lazySelect.commit();
183
        return lazySelect.getValue();
184
    }
185 186

  
186 187
    public UUID getIdForValue(){
187 188
        return filterablePagingProvider.idFor(getValue());
......
235 236
        }
236 237
    }
237 238

  
239

  
240
    @Override
241
    public void setRequired(boolean required) {
242
        super.setRequired(required);
243
        lazySelect.setRequired(required);
244
    }
245

  
246
    @Override
247
    public void setImmediate(boolean immediate){
248
        super.setImmediate(immediate);
249
        lazySelect.setImmediate(immediate);
250
    }
251

  
238 252
    @Override
239 253
    public void updateButtons(){
240 254
        buttonUpdater.updateButtons(getValue());
241 255
    }
242 256

  
257
    @Override
258
    public void commit() throws SourceException, InvalidValueException {
259
        lazySelect.commit();
260
    }
261

  
262
    /**
263
    *
264
    */
265
   public void commitSelect() {
266
       try {
267
           setComponentError(null);
268
           lazySelect.commit();
269
       } catch (InvalidValueException ex){
270
           UserError componentError = new UserError(ex.getHtmlMessage(), ContentMode.HTML, ErrorLevel.ERROR);
271
           lazySelect.setComponentError(componentError);
272
       }
273
   }
274

  
275

  
276

  
243 277
    /**
244 278
     * {@inheritDoc}
245 279
     * @deprecated NestedButtonStateUpdater should rather be instantiated in the RelatedEntityField instead of passing it as property
......
293 327
        }
294 328
    }
295 329

  
296

  
297

  
298 330
}

Also available in: Unified diff