bindMemberFields turns off read only enables field

I have some fields configured with read only turned on and/or disabled that, when I call “bindMemberFields”, have the read only mode turned off and the field is enabled. I know, from digging into the code, that this happens, as defined in the API, because “configureField”. What is the best way to keep the “read only” or “enabled” flags the same as defined earlier in the code?


This is important because sometimes one person is doing the UI and another is doing the binding or other business logic. The binding person might not know this information, or it might be inconvenient for them to check the declarative definition ( HTML ) or Java definition, for some reason.

As you’ve noticed, the FieldGroup is very bad at considering any user-set values for these. The only way to have the ‘enabled’ property work like you want is to set it after the field has been bound. The same thing applies to readOnly, but that one has an additional configuration; if the underlying data source (property) is read-only, then the field will be too.

I have struggled with this “nice feature” as well…

Try with Viritin 1.56, either with raw MBeanFieldGroup or with AbstractForm. It now works the way I think it should. Read only flag set for a field is now respected, even if the property is still read-write.

Here is the test related to it:


I’m using Viritin 1.61 and I followed your example above by turning the field read-only on the constructor and still didn’t work.

The only way I could do that was setting it read-only after the component was bound, like Thomas mentioned for FieldGroup, by overriding setEntity().

@Override MBeanFieldGroup<BaseEntityForm> setEntity(BaseEntityForm entity) { def fieldgroup = super.setEntity(entity) name.readOnly = true fieldgroup } * The code is Groovy