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 / September 2005

Tip: Looking for answers? Try searching our database.

Swing AbstractAction/Action relation to the MVC?

Thread view: 
Casper - 05 Sep 2005 15:15 GMT
It's great to be able to isolate UI events into Swing actions so the
same action is called from a menu, toolbar and/or shortcut. But what is
its relevance to the MVC-pattern. I have isolated all UI actions of my
app in a single ActionFactory class, but I am simple unsure about how
this plugs in with a model. Are the actions part of the view or the
controller?

Any pointers or references greatly appreciated,
Casper
Giovanni Azua - 05 Sep 2005 16:36 GMT
Hi Casper,

IMHO What you mean as actions is the Controller itself.

The Controller (even though can be implemented generic enough)
would know about/coupled with the interfaces of the View (visualization)
and Model (underlying structures that could be e.g. persistent).

I think one has reached the optimal MVC implementation whenever
you can redefine/switch any of the three components without breaking the
other two e.g.

Swing application optimally implemented as MVC is converted into
Web Application by switching to a different View component, ideally
the Controller would be easily wrapped or extended to support the
J2EE-specifics e.g. servlets

HTH,
Best Regards,
Giovanni

> It's great to be able to isolate UI events into Swing actions so the same
> action is called from a menu, toolbar and/or shortcut. But what is its
[quoted text clipped - 4 lines]
> Any pointers or references greatly appreciated,
> Casper
Karsten Lentzsch - 06 Sep 2005 13:55 GMT
> It's great to be able to isolate UI events into Swing actions so the
> same action is called from a menu, toolbar and/or shortcut. But what is
> its relevance to the MVC-pattern. I have isolated all UI actions of my
> app in a single ActionFactory class, but I am simple unsure about how
> this plugs in with a model. Are the actions part of the view or the
> controller?

Actions fit better into the "Presentation Model" (PM)
pattern. And let me add that MVC is for components,
PM and MVP are for applications.

You can find descriptions of both MVP and PM at
http://www.martinfowler.com/eaaDev/OrganizingPresentations.html

I provide a "Desktop Patterns & Data Binding"
presention where I show how Actions can be used
in Swing in combination with the PM pattern.
See http://www.jgoodies.com/articles/

Hope this helps. Kind regards,
Karsten Lentzsch
Giovanni Azua - 06 Sep 2005 16:54 GMT
Hi Karsten,

> Actions fit better into the "Presentation Model" (PM)
> pattern. And let me add that MVC is for components,
[quoted text clipped - 7 lines]
> in Swing in combination with the PM pattern.
> See http://www.jgoodies.com/articles/

According to you what is fundamentally the difference between
Presenter and Controller? and another comment, using the Observer
Pattern is perfectly viable having a Controller that is totally
decoupled from the other two (MV) e.g. Eiffel Event Library
using agents.

Why do you assert that MVC is only for components? e.g.
Visual C++ applications use MVC Pattern, Java Web and
Swing applications as well employ MVC.

Kind Regards,
Giovanni
Karsten Lentzsch - 07 Sep 2005 10:38 GMT
>>You can find descriptions of both MVP and PM at
>>http://www.martinfowler.com/eaaDev/OrganizingPresentations.html
[quoted text clipped - 3 lines]
>>in Swing in combination with the PM pattern.
>>See http://www.jgoodies.com/articles/

> According to you what is fundamentally the difference between
> Presenter and Controller? [...]

I think Martin Fowler describes this well in this writing:
http://www.martinfowler.com/eaaDev/OrganizingPresentations.html

> Why do you assert that MVC is only for components? e.g.
> Visual C++ applications use MVC Pattern, Java Web and
> Swing applications as well employ MVC.

More precisely: MVC is better for components,
MVP and PM are better for applications. In Smalltalk
where MVC was invented, whole apps were built with MVC.
Since modern toolkits already handle fine grained events,
the application's presentation logic can focus on
coarse grained events that lead to operations on
the domain or presentation state.

And yes, you can build a Swing application that uses
MVC. But no, Swing itself doesn't use MVC; instead
it uses a variant of MVC. For example in Swing the
painting code and the event handling is not separated,
it is typically done in a single class, the UI delegate.
You can find some diagrams about the difference between
MVC and the variant used in Swing in my presentations
"Desktop Patterns & Data Binding" as well as in
"Data Binding for Swing" at http://www.jgoodies.com/articles/

- Karsten
Casper - 07 Sep 2005 16:33 GMT
Thanks to all for the answers. :)

Regards,
Casper


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.