[REVIEW] Make controller instantiation customizable

Greg Brown greg.x.brown at oracle.com
Wed Dec 14 08:51:57 PST 2011

> at first glance, I don't see any reason why we couldn't add a setController() method in addition to getController().

I just prototyped this, and there is one potential issue - the controller is currently reset to null every time load() is called. We'd have to remove that code so we wouldn't inadvertently blow away any caller-provided value. The downside is that, if the FXMLLoader instance is reused to load another file, the controller won't be automatically cleared, which could be confusing. So I'm not sure that making the "controller" property mutable is such a good idea.

We could go with Daniel's original suggestion to pass the controller to the load() method, but it seems a bit strange to me. We could do it - but maybe you could try working with ControllerFactory and setClassLoader() to see if they might meet your needs first?


More information about the openjfx-dev mailing list