I use the FieldGroup class to bind fields to item properties with bindMemberFields. But I cannot use label because the Label class is not Field. It would be usefull to enchance the FieldGroup class to support the Label class.
Thank you, Anna. But your suggestion will not work because of the following FieldGroup method:
protected void configureField(Field<?> field) {
field.setBuffered(isBuffered());
field.setEnabled(isEnabled());
if (field.getPropertyDataSource().isReadOnly()) {
field.setReadOnly(true);
} else {
field.setReadOnly(isReadOnly()); // here is problem, because my FieldGroup is not read only
}
}
As the result my read only text field becomes editable for the none read only item property.
In most use cases Label is simply an element that contains text and doesn’t have any field functionality, so having it implement Field interface by default would add lots of unnecessary code and processing. Setting the read-only status after the FieldGroup has done the default configuring is in my mind the more correct solution on framework level, because TextField pretty much
is a field version of Label. I might change the FieldGroup handling to keep the default read only status of fields, though – it would have to be changed temporarily to set the default value, but it shouldn’t be much of an issue to return the original state after that is done.