Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

MVC dialog location

Thread view: 
Jumping Monkey - 20 Jan 2005 15:31 GMT
Hi all,

Just wondering what you views are on where to place certain dialog boxes with a
typical MVC setup

A View, A Model, A Controllor

The model holds the data.
The controllor is only thing allowed to manipulate the model.
The view displays the model.
The view may have gui_models that wrap the real model so columns
in tables can get reordered but it cant touch the real model except
throught the controllor.

A button in the view labelled "Do something"
On click the view calls the controllor.doSomething()
Once the controllor has done its stuff manipulating the model
perhaps calls view->refresh()
Or perhaps the model tells an event manager "I've changed"
and the event manager tells the view->refresh()

Now thats all pretty straight forward.

What I have trouble deciding where to put is some dialog boxes
that interact with the user.

For example the "You have unsaved changes, do you wish to save ?"
type dialog.
You click the top right X, or choose exit or whatever.

Choice 1: dumb view
The view will have to tell the controllor "user requests exit"
The controllor must check if there are unsaved changes
if so the controllor must request the view->askUserToSave()
And depending on the answer, save the changes before exiting or not.

Choice 2: Intelligent view
The view checks to see if there are unsaved changes
If so it prompts the user "do you wish to save"
And then calls controllor->saveChanges(), controllor->exit()
or just controllor->exit()

Thanks for any comments
RC - 20 Jan 2005 21:52 GMT
I would do it in the View. Here is why:

The View is an encapsulation of user interface, which can change. For
example, you might have to use bigger font on all GUI screens to help older
people. Or you might have some I18N needs. Since this dialog is definitely a
part of GUI, View me be appropriate.
Another reason is more practical, you might need a modal dialog, so you need
the reference to the original frame that might be hidden in your view class.
You do not want that to be exposed to the controller, so that you expose
your internal implementation.

That being said, for more complex (sub) GUI (like a wizard), you might call
back the controller to make sure your View wouldn't end up becoming a
controller on its own.

This is my personal opinion, and certainly not all will agree.

> Hi all,
>
[quoted text clipped - 39 lines]
>
> Thanks for any comments


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.