mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
PL-1202 Разработать механизм работы с динамическими атрибутами
support required attributes #PL-1202
This commit is contained in:
parent
12bd06bf57
commit
d8a1c18f47
@ -31,6 +31,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
|
|||||||
private MetaClass metaClass;
|
private MetaClass metaClass;
|
||||||
private transient Range range;
|
private transient Range range;
|
||||||
private Class javaClass;
|
private Class javaClass;
|
||||||
|
private Boolean mandatory;
|
||||||
|
|
||||||
private AnnotatedElement annotatedElement = new FakeAnnotatedElement();
|
private AnnotatedElement annotatedElement = new FakeAnnotatedElement();
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
|
|||||||
this.javaClass = DynamicAttributesUtils.getAttributeClass(attribute);
|
this.javaClass = DynamicAttributesUtils.getAttributeClass(attribute);
|
||||||
this.metaClass = metaClass;
|
this.metaClass = metaClass;
|
||||||
this.name = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode());
|
this.name = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode());
|
||||||
|
this.mandatory = attribute.getRequired();
|
||||||
Metadata metadata = AppBeans.get(Metadata.NAME);
|
Metadata metadata = AppBeans.get(Metadata.NAME);
|
||||||
Session metadataSession = metadata.getSession();
|
Session metadataSession = metadata.getSession();
|
||||||
if (SetValueEntity.class.isAssignableFrom(javaClass)) {
|
if (SetValueEntity.class.isAssignableFrom(javaClass)) {
|
||||||
@ -72,7 +74,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMandatory() {
|
public boolean isMandatory() {
|
||||||
return false;
|
return Boolean.TRUE.equals(mandatory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,6 +186,7 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
|||||||
field.setType(metaPropertyPath.getRangeJavaClass());
|
field.setType(metaPropertyPath.getRangeJavaClass());
|
||||||
field.setCaption(attribute.getName());
|
field.setCaption(attribute.getName());
|
||||||
field.setDatasource(ds);
|
field.setDatasource(ds);
|
||||||
|
field.setRequired(attribute.getRequired());
|
||||||
|
|
||||||
if (fieldGroup.getWidth() > 0) {
|
if (fieldGroup.getWidth() > 0) {
|
||||||
field.setWidth("100%");
|
field.setWidth("100%");
|
||||||
|
@ -18,7 +18,6 @@ import com.haulmont.cuba.gui.components.ValidationException;
|
|||||||
import com.haulmont.cuba.gui.data.Datasource;
|
import com.haulmont.cuba.gui.data.Datasource;
|
||||||
import com.haulmont.cuba.gui.data.ValueChangingListener;
|
import com.haulmont.cuba.gui.data.ValueChangingListener;
|
||||||
import com.haulmont.cuba.gui.data.ValueListener;
|
import com.haulmont.cuba.gui.data.ValueListener;
|
||||||
import com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools;
|
|
||||||
import com.haulmont.cuba.web.gui.data.ItemWrapper;
|
import com.haulmont.cuba.web.gui.data.ItemWrapper;
|
||||||
import com.vaadin.data.Property;
|
import com.vaadin.data.Property;
|
||||||
import com.vaadin.ui.AbstractComponent;
|
import com.vaadin.ui.AbstractComponent;
|
||||||
|
Loading…
Reference in New Issue
Block a user