PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: rite2dinesh on January 22, 2010, 12:38:44



Title: PureMVC and Swing JTable
Post by: rite2dinesh on January 22, 2010, 12:38:44
Hi,
I am trying to port my application(which is in its early development stage) into pureMVC framework. I have a query with respect to the same

i)In which part of the pureMVC framework the swing components models(eg.DefaultTableModel) fit?
eg. I have a JTable and DefaultTableModel , in my opinion JTable would be part of my View Component and where does the model fit?

ii)If I am talking something which does not make any sense at all, can some one please give me an example on how to use Swing Jtable  in pureMVC framework?



Please clarify.

Thanks.


Title: Re: PureMVC and Swing JTable
Post by: puremvc on January 22, 2010, 11:47:51
It would be equivalent to a value object.

It would just inherit from AbstractTableModel  or be in instance of DefaultTableModel depending on whether you need to subclass.

In a typical scenario, you might have a Proxy retrieve a TableModel from the server (or construct one from the server response) and pass it over to the Mediator for the JTable in a notification. The Mediator for the JTable simply takes it out of the note body and and passes it to its view component, which might be the JTable or a container with the JTable in it.

The JTable modifies the model, which could be a reference to the one the Proxy holds or a copy. If it's a reference, then saving is a matter of retrieving the proxy to save its data object (the TableModel). If you're working with a copy at the view, then the mediator can take the one modified by the JTable and pass it back to the Proxy, which replaces its data object with the new one and then saves it.


-=Cliff>