[REVIEW] Make controller instantiation customizable

Richard Bair Richard.Bair at oracle.com
Fri Dec 16 15:13:58 PST 2011


Sorry, I'll try to have something more comprehensive Monday. I'm worried that, although we get a ControllerFactory (and for all intents and purposes using a Class is probably just fine), we aren't addressing the broader needs of EE design patterns that people are wanting to deploy here. I've seen several variations in real practice so far (from Dan, also Adam Bien and others). Whereas Dan is attempting to use FXML, others are just doing the UI in Java because it works well for their pattern of choice. I'd like to see how we can support:

	MVP (both Passive View and Supervising Presenter)
	"Classic" MVC
	Presentation Model

I think MVVM is another name for PresentationModel, but I'm not 100% sure. I don't think supporting all of these patterns will require any fundamental changes to FXML, I think we're 99% there and with a little care we can comprehensively have a solution where FXML can be the view in any of these scenarios. Being able to use a DI container to pick the controller implementation is another goodie, but it sort of falls out from some of the patterns. But I'm not 100% sure so I'd like to spend a day and get a more comprehensive example ready to go.

In particular though, I know that Dan has already done this and that his comments about what he'd *really*like is instructive. Although we can have a ControllerFactory, if we supported the alternative (named parameters declared on the FXML side) we might actually have a better all around solution. Or maybe we find that is a fine thing to add to FXML, but having a ControllerFactory is still something we want.

FWIW, if we do go with the ControllerFactory, then we really should make it a Callback rather than a separate interface.

Cheers
Richard

On Dec 15, 2011, at 5:18 PM, Greg Brown wrote:

>> But what Dan wants to do is to go from a string to an instance using a DI lookup, not from a string to a class to an instance. How does the combination of ClassLoader + ControllerFactory solve that?
> 
> Can you be more specific? In other words, how does using a type argument vs. a string argument not permit that? I'm no expert on DI, but I know that we had a similar requirement in Pivot (developers wanted to use Spring and Guice to instantiate controllers) and a Class was sufficient in both of those cases.
> 



More information about the openjfx-dev mailing list