use of io.jmix.ui.component.data.ConversionException in project jmix by jmix-framework.
the class CurrencyFieldImpl method convertToModel.
@Nullable
@Override
protected V convertToModel(@Nullable String componentRawValue) throws ConversionException {
String value = StringUtils.trimToNull(emptyToNull(componentRawValue));
Datatype<V> datatype = getDatatypeInternal();
if (datatype != null) {
try {
return datatype.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
try {
return propertyDataType.parse(componentRawValue, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
return super.convertToModel(componentRawValue);
}
use of io.jmix.ui.component.data.ConversionException in project jmix by jmix-framework.
the class MaskedFieldImpl method convertToModel.
@Nullable
@Override
protected V convertToModel(@Nullable String componentRawValue) throws ConversionException {
String value = emptyToNull(componentRawValue);
if (datatype != null) {
try {
return datatype.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessage(), e);
}
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
try {
return propertyDataType.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessage(), e);
}
}
return super.convertToModel(value);
}
use of io.jmix.ui.component.data.ConversionException in project jmix by jmix-framework.
the class AbstractTextArea method convertToModel.
@Nullable
@Override
protected V convertToModel(@Nullable String componentRawValue) throws ConversionException {
String value = emptyToNull(componentRawValue);
if (isTrimming()) {
value = StringUtils.trimToNull(value);
}
if (datatype != null) {
try {
return datatype.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
try {
return propertyDataType.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
return super.convertToModel(value);
}
use of io.jmix.ui.component.data.ConversionException in project jmix by jmix-framework.
the class TextFieldImpl method convertToModel.
@Nullable
@Override
protected V convertToModel(@Nullable String componentRawValue) throws ConversionException {
String value = emptyToNull(componentRawValue);
if (isTrimming()) {
value = StringUtils.trimToNull(value);
}
if (datatype != null) {
try {
return datatype.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
try {
return propertyDataType.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
return super.convertToModel(value);
}
Aggregations