JavaFX 8 and FXML DataBinding

Milan Kubec milan.kubec at oracle.com
Mon Jan 7 05:31:53 PST 2013


Hello,
please could you file a bug report with more details to JIRA
(http://javafx-jira.kenai.com) because it looks like a bug.
Ideally if you can provide a test case. What kind of collection is
'employees'?

Thanks

  Milan Kubec


Dne 7.1.2013 12:41, Sebastian Rheinnecker napsal(a):
> Hello,
>
> in JavaFX 2.x versions it was possible to bind data in FXML
> declarations like this:
>
>             <Label
> text="${corporation.employees.selectedEmployee.firstName}" />
>
> with selectedEmployee being a SimpleObjectProperty and firstName being
> a StringProperty.
>
> I tried the Java 8 EAP today and got the following error:
>
> java.lang.NullPointerException
>   at com.sun.javafx.fxml.BeanAdapter.<init>(BeanAdapter.java:77)
>   at
> com.sun.javafx.fxml.expression.ExpressionValue$KeyPathMonitor.monitor(ExpressionValue.java:108)
>   at
> com.sun.javafx.fxml.expression.ExpressionValue$KeyPathMonitor.monitor(ExpressionValue.java:121)
>   at
> com.sun.javafx.fxml.expression.ExpressionValue$KeyPathMonitor.monitor(ExpressionValue.java:121)
>   at
> com.sun.javafx.fxml.expression.ExpressionValue.monitorArguments(ExpressionValue.java:235)
>   at
> com.sun.javafx.fxml.expression.ExpressionValue.addListener(ExpressionValue.java:196)
>   at
> javafx.beans.property.StringPropertyBase.bind(StringPropertyBase.java:166)
>   at
> javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:382)
>   at
> javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:223)
>   at
> javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:576)
>   at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2449)
>   at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2149)
> ...
>
> I believe this is due the properties get() method is returning null at
> the time the application is started (at this time no employee is
> selected). This also happens if something is directly bound to the
> property which returns null:
>
> ${corporation.employees.selectedEmployee}
>
> As mentioned before, the BeanAdapter accepted those in JavaFX 2.x
> versions and it worked well. Is this an incompatible change or am I
> doing something wrong?
>
> Kind regards,
>
> Sebastian Rheinnecker
>



More information about the openjfx-dev mailing list