use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class TextFieldImpl method getConversionErrorMessageInternal.
protected String getConversionErrorMessageInternal() {
String customErrorMessage = getConversionErrorMessage();
if (StringUtils.isNotEmpty(customErrorMessage)) {
return customErrorMessage;
}
Datatype<V> datatype = this.datatype;
if (datatype == null && valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
datatype = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
}
if (datatype != null) {
String msg = getDatatypeConversionErrorMsg(datatype);
if (StringUtils.isNotEmpty(msg)) {
return msg;
}
}
return applicationContext.getBean(Messages.class).getMessage("databinding.conversion.error");
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class DatePickerLoader method getJavaType.
protected Class getJavaType(DatePicker resultComponent) {
ValueSource valueSource = resultComponent.getValueSource();
if (valueSource instanceof EntityValueSource) {
MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty();
return metaProperty.getRange().asDatatype().getJavaClass();
}
Datatype datatype = resultComponent.getDatatype();
return datatype == null ? Date.class : datatype.getJavaClass();
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class WebTokenList method convertToModel.
@Override
protected Collection<V> convertToModel(Collection<V> componentRawValue) throws ConversionException {
ValueSource<Collection<V>> valueSource = getValueSource();
if (valueSource != null) {
Class<?> modelCollectionType = null;
if (valueSource instanceof EntityValueSource) {
MetaPropertyPath mpp = ((EntityValueSource) valueSource).getMetaPropertyPath();
modelCollectionType = mpp.getMetaProperty().getJavaType();
} else if (valueSource instanceof LegacyCollectionDsValueSource) {
CollectionDatasource datasource = ((LegacyCollectionDsValueSource) valueSource).getDatasource();
if (datasource instanceof NestedDatasource) {
MetaProperty property = ((NestedDatasource) datasource).getProperty().getInverse();
modelCollectionType = property == null ? null : property.getJavaType();
}
}
if (modelCollectionType != null) {
if (Set.class.isAssignableFrom(modelCollectionType)) {
return new LinkedHashSet<>(componentRawValue);
}
}
}
return new ArrayList<>(componentRawValue);
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class WebOptionsGroup method valueBindingConnected.
@SuppressWarnings("unchecked")
@Override
protected void valueBindingConnected(ValueSource<V> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupOptions(this, (EntityValueSource) valueSource);
}
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class WebOptionsList method valueBindingConnected.
@Override
protected void valueBindingConnected(ValueSource<V> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupOptions(this, (EntityValueSource) valueSource);
}
}
Aggregations