Review request for RT-20719

Greg Brown greg.x.brown at oracle.com
Wed Apr 25 15:28:35 PDT 2012


> How exactly is IDProperty used again? I get confused because <Circle id="foo" fx:id="bar"> has two id's. The fx:id is used for the name of the property in the controller when doing injection, but otherwise why is the node's property annotated with @IDProperty?

The IDProperty annotation specifies the name of the property to which an fx:id value will be applied. If an element's type defines this annotation (like javafx.scene.Node), FXMLLoader propagates the value of fx:id to the specified property. This allows us to avoid requiring the user to do something like this:

<Circle fx:id="foo" id="foo">

They can instead just do this:

<Circle fx:id="foo">

We don't want to hard-code FXMLLoader to always propagate the fx:id to the "id" property, since a user-defined class may already have an "id" property that is used for a different purpose, or it may have a property with a different name that is used like an ID (e.g. "key" or "name"). Using the annotation, a developer can specify which property should be used as the ID. Spring has a similar concept, though at the moment I don't remember what it is called - maybe someone with more Spring experience can comment.

> Also I wonder if we can have a more FXML specific name than IDProperty.

I'm open to suggestions on improving the name, but (like @DefaultProperty) I don't think the concept is necessarily specific to FXML. It's analogous to specifying which column is the primary key in a database table, so it could apply to other contexts outside of FXML. Also, since @DefaultProperty lives in javafx.beans, it seems like this one should as well.

It doesn't really matter that much where it lives - I'd just like to make it public so app developers can use it.

G



More information about the openjfx-dev mailing list