PL-1202 Разработать механизм работы с динамическими атрибутами

support required attributes
#PL-1202
This commit is contained in:
Eugeny Degtyarjov 2015-04-24 13:49:55 +00:00
parent 12bd06bf57
commit d8a1c18f47
3 changed files with 4 additions and 2 deletions

View File

@ -31,6 +31,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
private MetaClass metaClass;
private transient Range range;
private Class javaClass;
private Boolean mandatory;
private AnnotatedElement annotatedElement = new FakeAnnotatedElement();
@ -38,6 +39,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
this.javaClass = DynamicAttributesUtils.getAttributeClass(attribute);
this.metaClass = metaClass;
this.name = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode());
this.mandatory = attribute.getRequired();
Metadata metadata = AppBeans.get(Metadata.NAME);
Session metadataSession = metadata.getSession();
if (SetValueEntity.class.isAssignableFrom(javaClass)) {
@ -72,7 +74,7 @@ public class DynamicAttributesMetaProperty extends MetadataObjectImpl implements
@Override
public boolean isMandatory() {
return false;
return Boolean.TRUE.equals(mandatory);
}
@Override

View File

@ -186,6 +186,7 @@ public class FieldGroupLoader extends AbstractFieldLoader {
field.setType(metaPropertyPath.getRangeJavaClass());
field.setCaption(attribute.getName());
field.setDatasource(ds);
field.setRequired(attribute.getRequired());
if (fieldGroup.getWidth() > 0) {
field.setWidth("100%");

View File

@ -18,7 +18,6 @@ import com.haulmont.cuba.gui.components.ValidationException;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.ValueChangingListener;
import com.haulmont.cuba.gui.data.ValueListener;
import com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools;
import com.haulmont.cuba.web.gui.data.ItemWrapper;
import com.vaadin.data.Property;
import com.vaadin.ui.AbstractComponent;