diff --git a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopCheckBox.java b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopCheckBox.java index e7025b7f1c..23ac2e66b4 100644 --- a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopCheckBox.java +++ b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopCheckBox.java @@ -51,6 +51,7 @@ public class DesktopCheckBox extends DesktopAbstractField implements ); } + @SuppressWarnings("unchecked") @Override public T getValue() { return (T) (Boolean) impl.isSelected(); @@ -63,6 +64,10 @@ public class DesktopCheckBox extends DesktopAbstractField implements return; } + if (value == null) { + value = false; + } + if (!ObjectUtils.equals(prevValue, value)) { updateComponent(value); updateInstance(); @@ -84,6 +89,7 @@ public class DesktopCheckBox extends DesktopAbstractField implements return metaProperty; } + @SuppressWarnings("unchecked") @Override public void setDatasource(Datasource datasource, String property) { this.datasource = datasource; @@ -95,12 +101,10 @@ public class DesktopCheckBox extends DesktopAbstractField implements final MetaClass metaClass = datasource.getMetaClass(); metaPropertyPath = metaClass.getPropertyPath(property); - try { - metaProperty = metaPropertyPath.getMetaProperty(); - } - catch (ArrayIndexOutOfBoundsException e) { - throw new RuntimeException("Metaproperty name is possibly wrong: " + property, e); + if (metaPropertyPath == null) { + throw new RuntimeException("Metaproperty name is possibly wrong: " + property); } + metaProperty = metaPropertyPath.getMetaProperty(); datasource.addListener( new DsListenerAdapter() { @@ -109,6 +113,10 @@ public class DesktopCheckBox extends DesktopAbstractField implements if (updatingInstance) return; Boolean value = InstanceUtils.getValueEx(item, metaPropertyPath.getPath()); + if (value == null) { + value = false; + } + updateComponent(value); fireChangeListeners(value); } @@ -118,6 +126,10 @@ public class DesktopCheckBox extends DesktopAbstractField implements if (updatingInstance) return; if (property.equals(metaPropertyPath.toString())) { + if (value == null) { + value = false; + } + updateComponent(value); fireChangeListeners(value); }