Bidirectional binding with conversion

Michael Heinrichs michael.heinrichs at oracle.com
Fri Dec 9 08:14:06 PST 2011


On 09.12.2011, at 16:55, Richard Bair wrote:

> Hi Michael,
> 
> What about adding:
> 
> public void bindBidirectional(Property<?> other, StringConverter)
> 
> as well? The StringConverter is in javafx.util and seems like another well suited means for conversion to/from String.
> 

Yeah, makes sense. I did not know this class exists.

> One other question not directly related -- why do our bindBidirectional methods take a Property instead of a WritableValue?
> 

Because a WritableValue is not observable. I think at some point we had something like
public static <E, T extends WritableValue<E> & ObservableValue<E>> void bindBidirectional(T obj1, T obj2)
but then we dropped it and used properties instead to make the signature more readable. So far properties are the only implementation of both interfaces.

- Michael


> Thanks
> Richard
> 
> On Dec 9, 2011, at 1:33 AM, Michael Heinrichs wrote:
> 
>> Hi everybody,
>> 
>> I am working on a solution for the Binding API that allows bidirectional bindings between an arbitrary property and a StringProperty. (The long term plan is to allow bidirectional bindings between two arbitrary properties in JavaFX 3.0). The request is tracked here: http://javafx-jira.kenai.com/browse/RT-18203
>> 
>> The class javafx.beans.binding.Bindings will get two new methods:
>>   public static void bindBidirectional(Property<String> stringProperty, Property<?> otherProperty, Format format)
>>   public static void unbindBidirectional(Object property1, Object property2)
>> 
>> 
>> The class javafx.beans.property.StringProperty will also get two new methods:
>>   public void bindBidirectional(Property<?> other, Format format)
>>   public void unbindBidirectional(Object other)
>> 
>> If parsing the StringProperty fails, the other property will be set to the default value. If formatting the arbitraty property fails, the StringProperty will be set to the empty String.
>> 
>> Any thoughts?
>> 
>> Thanks,
>> Michael
> 



More information about the openjfx-dev mailing list