0

I have some components inside binder:

binder.bind(cbClientRating, Client::getRating, Client::setRating);
binder.bind(tfFirstName, Client::getFirstName, Client::setFirstName);
binder.bind(tfLastName, Client::getLastName, Client::setLastName);
binder.bind(dfBirthDate, Client::getBirthDate, Client::setBirthDate);

According my business logic i do not need to change readonly status for one component inside binder, for example Combobox - cbClientRating when i call binder.setReadOnly(false). It should be stay in readonly mode equal true.

Now i call cbClientRating.setReadOnly(true) after calling binder.setReadOnly(false)

binder.setReadOnly(false); cbClientRating.setReadoOnly(true);

Is there any other solution?

jlemon
  • 95
  • 1
  • 9

1 Answers1

0

Source code of Binder#setReadOnly(boolean):

/**
 * Sets the read only state to the given value for all currently bound
 * fields.
 * <p>
 * This is just a shorthand for calling setReadOnly for all currently bound
 * fields. It means that fields bound after this method call won't be set
 * read-only.
 *
 * @param fieldsReadOnly
 *            true to set the fields to read only, false to set them to read
 *            write
 */
public void setReadOnly(boolean fieldsReadOnly) {
    getBindings().stream().map(BindingImpl::getField)
            .forEach(field -> field.setReadOnly(fieldsReadOnly));
}

So this is only a convenience method. I recommend that you handle the field read only states completly by yourself according to your business logic.

Steffen Harbich
  • 2,639
  • 2
  • 37
  • 71