Hi guys,
I'd like to hear your opinions about how to make model classes work together in a Swing App.
From my previous experiences with web apps, I know the controller commonly puts all info needed by views as a kind of attribute in session, request or application scopes.
However, I don't know what approach is used with Swing apps.
Reading the
Java Tutorial from sun I could understand that in Swing the MVC is more a Model Driven approach than a really MVC
pattern as we are used to hear in the web app world.
I also know that in a Swing app, my forms (JFrame, JDialogs ...) may be considered as view, the event listeners as controllers and my custom classes as models, but I'm not confortable about how to stick everything together, do you know what I mean ?
Well, just to simplify my doubt a little bit, let me use the following scenario :
I know it's not a useful real world app but it's just for understanding what I have in mind.
Scenario :
----------
Imagine I have a Swing app where the main window ("Product List Screen") contains a JTable with all products with its respective code, descriptions,
unit price, stock quantity and so on ...
On this same window, there's a button ("New Product") which opens a new window ("New Product Screen") for creating the product.
So far, I could identify :
View : The two windows I mention above ("Product List" and "New Product")
Controller : Action Listener used to listen the button click.
Just continuing ...
After open the "New Product" screen, the user is expected to input all product info and them submit the info for insertion.
Here starts my doubt : How to inform the view ("The Product List Screen") of a new product inclusion and ask it to re-read all information from database ?
Even better, how to pass this new product info to the "Previous Product List Screen" as a bean avoiding the need of a read from database ?
If I was using a WEB app, I simply would put such bean as a request attribute and then redirect to the view. But .... What if I'm using a Swing app ? Is there some kind of shared area to put such beans and other model classes ? I don't think so.
I'm really interested about your comments and tips.
TIA,
Edisandro.
[ September 20, 2006: Message edited by: Edisandro Bessa ]