ObservableValue Stacktrace

Martin Sladecek martin.sladecek at oracle.com
Thu Jun 6 04:23:57 PDT 2013


On 06/06/2013 10:53 AM, John Hendrikx wrote:
> Hm, ok -- it is correct that it doesn't fail, the code runs without 
> any problem and everything works as expected.
>
> But, what would be the way to avoid these messages in my log then?  
> Something like:
>
>   Bindings.select( Bindings.when(dataProperty().isNull()).then( ??? 
> ).otherwise(dataProperty()), "castings") );
>
> ??
>
> I'd prefer to just turn these warnings off unless there is a really 
> good reason to have them (ie, they indicate a logic error or other 
> bug, something I can resolve...)

This might indicate a logic error in many cases, esp. when the property 
you bind is a primitive type. When the select fails in the middle of 
computation, the only it can do is to set the property to default value 
(which is 0). If the developer
didn't expect this, it would be quite hard to find the actual cause of 
the zero. If you really expect nulls along the way, it's much cleaner to 
handle this explicitly as you do in the code above.

>
> In my case the dataProperty() is often bound to the selection of a 
> ListView -- if you have something valid selected, then a Detail Pane 
> is filled in with information about the selected item.  When nothing 
> is selected (ie, it is null), then the Detail Pane should remain 
> empty... I donot want to have to remove/recreate these bindings every 
> time some property becomes null.
>
> Also, it seems rather wierd that JavaFX will complain about nulls in 
> the first part of the Bindings.select(), but will happily traverse the 
> graph (with or without nulls) for the other parts.
This is a bug then, it should print the warning in any part of the 
select expression.

-Martin


More information about the openjfx-dev mailing list