API change request for RT-20471/JavaFX 2.2

Daniel Zwolenski zonski at googlemail.com
Mon Mar 19 17:03:35 PDT 2012

+1 on the improved API from me.

Just as something to think about, we're starting to have a mini-dependency
injection framework in FXML, with a custom DI API. There are standard
annotations for this built into Java (under JEE) including the @Resource
and @PostConstruct annotations, which closely match the way the @FXML
annotation is being used in this case:

The standard stuff might be an area worth looking at either to leverage, or
for design ideas to consider (e.g. the @PostConstruct annotation can be
applied to any method, it does not need to be named 'initialize()').

Another source of ideas on this stuff could be JSR330 (the 'javax.inject'

e.g. Using just the features in JFX2.0, I've been able to inject the
ResourceBundle into my 'controller' using this standard JEE dependency
injection, and also use the PostConstruct to do the initialisation. As a
result I've been able to avoid the Initializable interface and achieve the
result this enhancement is aimed at achieving (though my solution requires
a DI implementation such as Spring, whereas in the proposal the FXMLLoader
would effectively be the DI implementation).

Just some thoughts to throw in the mix, but I definitely like the
annotation based solution over the interface one.

On Tue, Mar 20, 2012 at 7:25 AM, Greg Brown <greg.x.brown at oracle.com> wrote:

> This change would automatically inject "location" and "resources" fields
> in an FXML controller object rather than requiring the controller to
> implement Initializable. See JIRA issue for details:
> http://javafx-jira.kenai.com/browse/RT-20471
> Greg

More information about the openjfx-dev mailing list