Bidirectional binding with conversion
zonski at googlemail.com
Fri Dec 9 03:25:28 PST 2011
Nice idea, I can see it being useful.
Does it need to be limited to bidirectional bindings? Any reason unidirectional bindings cant use a converter too?
I wonder if we need a way to detect the failed parsing/formatting? For example if we were converting a TextField.textProperty to a Number (or Date) and it couldn't be parsed, I reckon I'd want to highlight the field as an error. Maybe this could be done with a custom formatter, is that the best way though?
On 09/12/2011, at 9:24 PM, Michael Heinrichs <michael.heinrichs at oracle.com> wrote:
> Hi Jonathan,
> it is very likely that we will add other types of bindings later. With a generic unbind method, we only have to add new bind methods in the future, significantly reducing the number of methods.
> Looking back it was a mistake to make the unbind methods symmetrical to the bind methods, they should have been generic right from the start. I hope I will have a chance to fix it at some point in the future.
> - Michael
> On 09.12.2011, at 10:42, Jonathan Giles wrote:
>> I'm sure there is a reason, but why do the unbind methods take Object rather than Property<?> or similar?
>> -- Jonathan
>> On Friday, 9 December 2011 7:33:30 p.m., 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?
More information about the openjfx-dev