Add listener at runtime? – Java MVC
In my MVC mode, my model generates components at runtime and provides them to the view to be displayed on the screen through the update () method (you know, the model is observable and the view is the observer) But I also need to add listeners for these components, and the controller has listener methods (because they say MVC mode is like this) and it does not participate in this update process So I can't add listeners at run time, but only in the constructor of the controller at startup
I have an idea, that is to make the controller an observer, then provide the data to the view, and add a listener Do you think this will be good?
Solution
Yes, let the controller be a model observer to allow it to update the view. In my opinion, it must be suitable for MVC orthodoxy