Adding Listeners at runtime? - Java MVC
Posted
by Halo
on Stack Overflow
See other posts from Stack Overflow
or by Halo
Published on 2010-03-16T09:56:32Z
Indexed on
2010/03/16
10:06 UTC
Read the original article
Hit count: 355
My model in my MVC pattern, generates components at runtime and gives them to the View to be displayed on the screen through update() method (you know, model is the observable and the view is the observer). But I also need to add listeners to these components, and the controller has the listener methods (because they say the MVC pattern is like this) and it's not involved in this update process. So I can't add the listeners at runtime, but only in the controller's constructor at startup.
I've got an idea, that is making the controller the observer and then giving the data to the view, as well as adding the listeners. Do you think this would be OK?
© Stack Overflow or respective owner