Bidirectional binding with conversion

Richard Bair richard.bair at oracle.com
Mon Dec 12 09:50:54 PST 2011


OK, so is this the design?

============================================================

The class javafx.beans.binding.Bindings will get three new methods:
    public static void bindBidirectional(Property<String> stringProperty, Property<?> otherProperty, Format format);
    public static <T>  void bindBidirectional(Property<String> stringProperty, Property<T> otherProperty, StringConverter<T> converter);
    public static void unbindBidirectional(Object property1, Object property2);

The class javafx.beans.property.StringProperty will also get three new methods:
    public void bindBidirectional(Property<?> other, Format format);
    public <T> void bindBidirectional(Property<T> other, StringConverter<T> converter);
    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.

============================================================

Sounds good to me!

Richard

(Hopefully I got the generics on the StringConverter variant correct)


More information about the openjfx-dev mailing list