use of com.haulmont.chile.core.datatypes.ValueConversionException in project cuba by cuba-platform.
the class WebAbstractTextArea method convertToModel.
@Override
protected V convertToModel(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 com.haulmont.chile.core.datatypes.ValueConversionException in project cuba by cuba-platform.
the class WebCurrencyField method convertToModel.
@Override
protected V convertToModel(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 com.haulmont.chile.core.datatypes.ValueConversionException in project cuba by cuba-platform.
the class WebMaskedField method convertToModel.
@Override
protected V convertToModel(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 com.haulmont.chile.core.datatypes.ValueConversionException in project cuba by cuba-platform.
the class WebGroupTable method distributeGroupAggregation.
@SuppressWarnings("unchecked")
protected boolean distributeGroupAggregation(AggregationInputValueChangeContext context) {
if (distributionProvider != null) {
String value = context.getValue();
Object columnId = context.getColumnId();
GroupInfo groupInfo = null;
try {
Object parsedValue = getParsedAggregationValue(value, columnId);
Collection<E> scope = Collections.emptyList();
if (context.isTotalAggregation()) {
TableItems<E> tableItems = getItems();
scope = tableItems == null ? Collections.emptyList() : tableItems.getItems();
} else if (context instanceof GroupAggregationInputValueChangeContext) {
Object groupId = ((GroupAggregationInputValueChangeContext) context).getGroupInfo();
if (groupId instanceof GroupInfo) {
groupInfo = (GroupInfo) groupId;
scope = ((GroupTableItems) getItems()).getChildItems(groupInfo);
}
}
GroupAggregationDistributionContext<E> aggregationDistribution = new GroupAggregationDistributionContext(getColumnNN(columnId.toString()), parsedValue, scope, groupInfo, context.isTotalAggregation());
distributionProvider.onDistribution(aggregationDistribution);
} catch (ValueConversionException e) {
showParseErrorNotification(e.getLocalizedMessage());
// rollback to previous value
return false;
} catch (ParseException e) {
showParseErrorNotification(messages.getMainMessage("validationFail"));
// rollback to previous value
return false;
}
}
return true;
}
use of com.haulmont.chile.core.datatypes.ValueConversionException in project cuba by cuba-platform.
the class WebTextField method convertToModel.
@Override
protected V convertToModel(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