Mail conversation:
Hi Richard,
I completely agree, this is something we should tackle asap. At pretty much all conferences I was asked about such a feature.
[...]
Have not thoroughly thought about the bidirectional bindings with conversion so far. I think we need an extremely flexible solution, which allows you to match any property on any other property. This screams for generics. :-) And then we need some convenience functionality. Obviously converting something into a String using a Formatter and/or a formatter-String is a very common use case.
- Michael
On 22.11.2011, at 01:52, Richard Bair wrote:
Hi Michael,
One thing I was hoping to talk about last Thursday was bidirectional binding for complex things, particularly when conversion is involved.
For example, suppose I want to bind a slider to a text field. In such a case, I need to convert from a number to a string, and vice versa.
Or suppose I want to convert from a java.util.Date to a String, so the user can enter a new date in a TextField. Perhaps I also want to be able to convert "yesterday" into a Date, such that a standard simple date format isn't sufficient.
What I was hoping for was something simple, such as:
textField.textProperty().bindBidirectional(new BidirectionalStringBinding() {
{ ... }
@Override computeValue...
@Override public void set(String)
});
Or something like this, where the compute value converts from source to target, and set converts from target to source. Now, I had thought BidirectionalBinding could just be a WritableValue Binding.
Alternatively, you could instead have:
textField.bindBidirectional(otherProperty, converter) or
textField.bindBidirectional(otherProperty, formatter)
though as we've defined them, these are only useful for obj->string conversion, and so doesn't solve the general case.
FWIW, this is a more important problem to solve than binding between threads.
What do you think?
Richard
Hi Richard,
I completely agree, this is something we should tackle asap. At pretty much all conferences I was asked about such a feature.
[...]
Have not thoroughly thought about the bidirectional bindings with conversion so far. I think we need an extremely flexible solution, which allows you to match any property on any other property. This screams for generics. :-) And then we need some convenience functionality. Obviously converting something into a String using a Formatter and/or a formatter-String is a very common use case.
- Michael
On 22.11.2011, at 01:52, Richard Bair wrote:
Hi Michael,
One thing I was hoping to talk about last Thursday was bidirectional binding for complex things, particularly when conversion is involved.
For example, suppose I want to bind a slider to a text field. In such a case, I need to convert from a number to a string, and vice versa.
Or suppose I want to convert from a java.util.Date to a String, so the user can enter a new date in a TextField. Perhaps I also want to be able to convert "yesterday" into a Date, such that a standard simple date format isn't sufficient.
What I was hoping for was something simple, such as:
textField.textProperty().bindBidirectional(new BidirectionalStringBinding() {
{ ... }
@Override computeValue...
@Override public void set(String)
});
Or something like this, where the compute value converts from source to target, and set converts from target to source. Now, I had thought BidirectionalBinding could just be a WritableValue Binding.
Alternatively, you could instead have:
textField.bindBidirectional(otherProperty, converter) or
textField.bindBidirectional(otherProperty, formatter)
though as we've defined them, these are only useful for obj->string conversion, and so doesn't solve the general case.
FWIW, this is a more important problem to solve than binding between threads.
What do you think?
Richard
- relates to
-
JDK-8091322 Allow bidirectional binding with conversion between arbitrary properties
-
- Open
-