diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebAbstractField.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebAbstractField.java index 5e7d8c0ffa..f9a5bf218c 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebAbstractField.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebAbstractField.java @@ -169,12 +169,16 @@ public abstract class WebAbstractField final Object value = getValue(); Object newValue = fireValueChanging(prevValue, value); - fireValueChanged(prevValue, newValue); + + final Object oldValue = prevValue; prevValue = newValue; - if (!ObjectUtils.equals(value, newValue)) + if (!ObjectUtils.equals(value, newValue)) { WebAbstractField.this.component.setValue(newValue); + fireValueChanged(oldValue, newValue); + } + settingValue = false; } }); diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebFieldGroup.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebFieldGroup.java index 7018fd88db..71bc24188d 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebFieldGroup.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebFieldGroup.java @@ -14,14 +14,10 @@ import com.haulmont.cuba.gui.data.CollectionDatasource; import com.haulmont.cuba.gui.data.Datasource; import com.haulmont.cuba.gui.data.DsContext; import com.haulmont.cuba.web.gui.WebWindow; -import com.haulmont.cuba.web.gui.data.ItemWrapper; -import com.haulmont.cuba.web.gui.data.PropertyWrapper; import com.haulmont.cuba.web.toolkit.ui.CubaCheckBox; import com.haulmont.cuba.web.toolkit.ui.CubaFieldGroup; import com.haulmont.cuba.web.toolkit.ui.CubaFieldGroupLayout; import com.haulmont.cuba.web.toolkit.ui.CubaFieldWrapper; -import com.vaadin.data.Item; -import com.vaadin.data.util.converter.Converter; import org.apache.commons.lang.StringUtils; import org.dom4j.Element; @@ -51,8 +47,6 @@ public class WebFieldGroup protected int cols = 1; - protected Item itemWrapper; - protected Security security = AppBeans.get(Security.class); protected MessageTools messageTools = AppBeans.get(MessageTools.class); @@ -302,8 +296,6 @@ public class WebFieldGroup } if (datasource != null) { - itemWrapper = createDatasourceWrapper(datasource, fieldsMetaProps); - if (!this.fields.isEmpty()) { //Removes custom fieldsMetaProps from the list. We shouldn't to create components for custom fieldsMetaProps for (MetaPropertyPath propertyPath : new ArrayList<>(fieldsMetaProps)) { @@ -696,10 +688,6 @@ public class WebFieldGroup f.setCaption(caption); } - protected ItemWrapper createDatasourceWrapper(Datasource datasource, Collection propertyPaths) { - return new FieldGroupItemWrapper(datasource, propertyPaths); - } - @Override public void postInit() { } @@ -718,6 +706,8 @@ public class WebFieldGroup public void validate() throws ValidationException { final Map problems = new HashMap<>(); + // todo use cuba fields for validation + for (FieldConfig field : getFields()) { com.vaadin.ui.Field f = component.getField(field.getId()); if (f != null && f.isVisible() && f.isEnabled() && !f.isReadOnly()) { @@ -772,52 +762,6 @@ public class WebFieldGroup } } - public class FieldGroupItemWrapper extends ItemWrapper { - - private static final long serialVersionUID = -7877886198903628220L; - - public FieldGroupItemWrapper(Datasource datasource, Collection propertyPaths) { - super(datasource, propertyPaths); - } - - public Datasource getDatasource() { - return (Datasource) item; - } - - @Override - protected PropertyWrapper createPropertyWrapper(Object item, MetaPropertyPath propertyPath) { - return new PropertyWrapper(item, propertyPath) { - @Override - public boolean isReadOnly() { - FieldConfig field = fields.get(propertyPath.toString()); - return !isEditable(field); - } - - @Override - public void setValue(Object newValue) throws ReadOnlyException, Converter.ConversionException { - if (newValue instanceof String) { - newValue = ((String) newValue).trim(); - } - super.setValue(newValue); - } - - @Override - public String getFormattedValue() { - Object value = getValue(); - if (value == null) { - return ""; - } - - FieldConfig field = fields.get(propertyPath.toString()); - if (field.getFormatter() != null) { - return field.getFormatter().format(value); - } - return super.getFormattedValue(); - } - }; - } - } - protected class WebFieldGroupFieldFactory extends com.haulmont.cuba.web.gui.components.AbstractFieldFactory { @Override diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebLookupPickerField.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebLookupPickerField.java index 990592d466..7978f0b626 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebLookupPickerField.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebLookupPickerField.java @@ -52,6 +52,7 @@ public class WebLookupPickerField extends WebLookupField implements LookupPicker }; pickerField = new WebPickerField(picker); + // Required for custom components in fieldgroup initValueSync(selectComponent, picker); } diff --git a/modules/web/src/com/haulmont/cuba/web/gui/components/WebSearchPickerField.java b/modules/web/src/com/haulmont/cuba/web/gui/components/WebSearchPickerField.java index 7f91d2807f..3c1522540e 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/components/WebSearchPickerField.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/components/WebSearchPickerField.java @@ -38,6 +38,7 @@ public class WebSearchPickerField extends WebSearchField implements SearchPicker }; pickerField = new WebPickerField(picker); + // Required for custom components in fieldgroup initValueSync(selectComponent, picker); }