Example usage for com.vaadin.v7.data.util.converter ConverterUtil convertToModel

List of usage examples for com.vaadin.v7.data.util.converter ConverterUtil convertToModel

Introduction

In this page you can find the example usage for com.vaadin.v7.data.util.converter ConverterUtil convertToModel.

Prototype

public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(PRESENTATIONTYPE presentationValue,
        Class<MODELTYPE> modelType, Converter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
        throws Converter.ConversionException 

Source Link

Document

Convert the given value from the presentation (UI) type to model (data source) type.

Usage

From source file:org.vaadin.viritin.v7.fields.MTextField.java

License:Apache License

protected void doEagerValidation() {
    final boolean wasvalid = eagerValidationStatus;
    eagerValidationStatus = true;//from w w w  .  ja va  2  s. c  o  m
    eagerValidationError = null;
    try {
        if (isRequired() && getLastKnownTextContent().isEmpty()) {
            throw new Validator.EmptyValueException(getRequiredError());
        }
        validate(getLastKnownTextContent());
        if (!wasvalid) {
            markAsDirty();
        }
        // Also eagerly pass content to backing bean to make top level
        // validation eager, but do not listen the value back in value change
        // event
        if (getPropertyDataSource() != null) {
            skipValueChangeEvent = true;
            Object convertedValue = ConverterUtil.convertToModel(getLastKnownTextContent(),
                    getPropertyDataSource().getType(), getConverter(), getLocale());
            getPropertyDataSource().setValue(convertedValue);
            skipValueChangeEvent = false;
        }
    } catch (Validator.InvalidValueException e) {
        eagerValidationError = e;
        eagerValidationStatus = false;
        markAsDirty();
    }
}