Set item-bound components to read-only

hi all,

I’m trying to generate formulars using the PropertyItemSet and FieldGroup classes. Some component elements should be set to read-only (ie. a ComboBox with academic degrees) but I don’t get this managed.

I thought I could achive this by using the ObjectProperty.setReadOnly() method but this does not seem to work. It looks like the readOnly state gets lost somewhere during the use of the setPropertyDataSource() or wrapInTransactionalProperty() methods of the FieldGroup class.

I’m using a dataBean with complex Attributes, this attributes are aware of their own readOnly-State.

private FormLayout createPersonalDataForm( PersonalDataBean personalData ) {

    FormLayout formLayout = new FormLayout();
    ArrayList<KAMAttribute> propertyValues = personalData.getPropertyValues(); // List of bean-attributes
    ArrayList<String> propertyCaptions = personalData.getPropertyCaptions(); // List of attribute-captions
    PropertysetItem item = new PropertysetItem();
    FieldGroup fieldGroup = new FieldGroup(item);
    
    for ( int i = 0; i < propertyValues.size(); i++ ) { // for each attribute element
      
      KAMAttribute attribute = propertyValues.get( i );
      String caption = propertyCaptions.get( i );
      ObjectProperty<KAMAttribute> objectProperty = new ObjectProperty<KAMAttribute>( attribute ); // build property
      objectProperty.setReadOnly( attribute.isReadOnly() ); // set readOnly-state

      item.addItemProperty( caption, new ObjectProperty<KAMAttribute>( attribute ) ); 
      
      Field field = ISUtilsVaadin.generateField( attribute, caption ); // generate suitable component ( with custom converters )
      fieldGroup.bind( field, caption ); // bind attribute to component

      formLayout.addComponent( field );        
            
    } // for
 
    return formLayout;
}

Could anyone explain why using the ObjectProperty.setReadonly() method does not work in this case? What am I doing wrong?

Thanks!

5 hours and now I see the second ObjectProperty instance…