Hi,

We had something very similar in Eclipse-Databinding so I think something like that makes a lot of sense but I wonder how you want to implement this FOCUS, ACTION.

Another thing we had was a delayed-Observable where the sync only happened if there hasn't been a change with a user specified timeout which fairly nice to implement undo/redo like stuff eg in TextAreas.

As you don't have access to Node in javafx.base I'm not sure how you want to implement the trigger stuff. Just in case in Eclipse-Databinding world we had stuff like this in a module (in this case OSGi-Bundle) who has access to both the core-API and the ui-API.

Tom

Am 10.11.21 um 06:45 schrieb Michael Strauß:
JavaFX developers routinely use programming patterns like MVC, MVP, or
MVVM to separate views from their associated business logic. Bindings
can be used to connect the values of UI controls (like Label or
TextField) to properties on a business logic class.

A typical (simplified) scenario may look like this:

var valueField = new TextField();
valueField.textProperty().bindBidirectional(businessLogic.valueProperty());

The business logic class may perform data validation or other actions
on the value that was entered in the TextField. However, in many
cases, it is neither necessary nor desirable for the binding to update
the business-layer property on every single change (i.e. every single
character that was typed by a user). For example, if a business rule
verifies that the data entered by a user is formatted in a specific
way, it's usually not a great experience to yield a validation error
before the user has finished typing. Instead, it's often better to
wait until the user has significantly interacted with a UI control
before running business logic.

For this reason, I propose to add a new type of binding to the
javafx.beans.binding.Bindings class:

void bindBidirectional(Property<T> target, Property<T> source,
UpdateSourceTrigger trigger)

UpdateSourceTrigger is an enumeration that allows developers to
specify the condition on which changes of the target property will
update the source property. Its values are:

DEFAULT: Updates the source property on every change (this is the
default behavior of bidirectional bindings).
FOCUS: Updates the source property when the UI control loses input focus.
ACTION: Updates the source property when the UI control loses input
focus or when it receives an ActionEvent (in the case of TextField,
this corresponds to the ENTER key).

Note that this setting only applies to changes of the target property.
When the source property is changed instead, the target property is
always immediately updated.

Any feedback on this proposal is appreciated.


--
Tom Schindl - CTO
BestSolution.at EDV Systemhaus GmbH
Salurner Straße 15, A-6020 Innsbruck
Phone: ++43 (0)512 935834
http://www.BestSolution.at - http://efxclipse.org

Reply via email to