Thursday, 12 September 2013

What is right place for button handlers in modal window in MVC architecture?

What is right place for button handlers in modal window in MVC architecture?

I have an app that follows MVC architecture. All events on buttons in main
view are handled in controller. One of these buttons opens dialog window
with text field and two buttons (save and close).
I tried two approaches but both led me to dirty code:
Dialog window view is a separate class with c-tor with 2 args: main view
and model. This way all events are handled inside dialog window view
handler and main view with model are used to change data both on UI and in
DB.
Dialog window view is inner class of main controller. All events are
handled in place where events for other buttons are handled. The only
bottle neck of this approach is that I have to add inner class field to
Controller class in order to get access to dialog window buttons.
There were other approaches but they are more awful than ones above.
Where should I handle events on these buttons according to MVC
architecture? If it is needed I can provide you with javafx example.

No comments:

Post a Comment