| I wrote some JavaSE sample to test the new ValueExtractor classes for JavaFX like ListPropertyValueExtractor. In that case I miss an important feature in the base API. Let's say I have a model that has the following fields:
@NotEmpty(message = "Name sollte nicht leer sein!")
private final StringProperty name = new SimpleStringProperty();
private final Property<@Min(50) Integer> count = new SimpleObjectProperty<>();
@Size(min=1, max=4)
private final ListProperty<@Size(min=2, max=32) String> tags = new SimpleListProperty<>(FXCollections.observableArrayList());
Next I bind all the properties of the model to UI nodes. Example:
nameField.textProperty().bindBidirectional(model.nameProperty());
In addition I want to do a validation call whenever a value in the model changes. For the name property this can be done by the following code:
nameErrorNode.visibleProperty().bind(Bindings.createBooleanBinding(() ->
!validator.validateProperty(model, "name").isEmpty(),
model.nameProperty()));
By doing it like this only the name property will be validated whenever it changes. It would be wrong to validate the complete model in this case. I can simply do the same for the list:
tagErrorNode.visibleProperty().bind(Bindings.createBooleanBinding(() ->
!validator.validateProperty(model, "tags").isEmpty(),
model.tagsProperty()));
In this case the list will be validated whenever the list changes. This happens for example if a new element will be added, updated or removed. Let's imagine a list with 1_000_000 entries or so. In that case I do not want to validate the complete list when I update an element. Based on this I think that an additional method next to
Validator.validateProperty()
is needed in the JBV Spec to validate internal elements. |