Model-view-controller and Undo

Model-view-controller and Undo

Post by Deniz Doga » Mon, 13 Nov 2006 22:36:57

I want to write a relatively small Java application using the MVC design
pattern and I have a question about where to put each of the objects.

I have a view (JFrame) consisting of two JFormattedTextFields and one
JTable with multiple rows and two columns. Whenever the user selects a
row "N" in the JTable the two text fields will show the String stored in
the cell on row N and column 1 and 2, respectively. The user may then
alter the information stored in the two cells of row N by writing text
directly into the text fields.
Using a certain command the user may also merge lines together.

That was a simplified description of the problem at hand. My question is
now: Should I store the TableModel in my model class or is it better to
keep it in the view class? Also, how would I go about implementing undo
functionality to this application? Where would I store the UndoManager?
In the model class or the view class?

-Deniz Dogan

1. An implementation of the Model-View-Controller pattern in PHP

2. ASP.NET Model-View-Controller design question

I want to make two pages interact through a controller.

1. Page A has a grid and Add button.
2. When Add button is clicked Page B pops up.
3. User enters information and clicks Save
4. Information is saved in database
5. User goes back to Page A which gets new data from database and displays
one more row.

So, the event handler for Add button on Page A might look like:

private void btnAdd_Click(object sender, System.EventArgs e)
Server.Transfer (string.Format ("PageB.aspx?id={0}", id));

but I want PageA to instantiate a controller class, which would in turn
transfer to Page B, Page B would collected data from a user and again would
called the controller to save data and controller would transfer back to the
Page A.

My problem is that I don't know where to put the controller code.

I would like the controller to be an independent class. However, if I do
that, how does the controller get reference to the current http context and
object (to do Server.Transfer for example)?



3. Model-View-Controller implementation question in .NET

4. Model-View-Controller Framework in C#

5. [News] open Source Model-View-Controller

6. Model-View-Controller Pattern

7. Turned based games and model-view-controller

8. Why Model-View-Controller?

9. Model-View-Controller Pattern in ASP.NET

10. (macro) recorder for service requests in a model-view-controller architecture

11. Undo with table view and array controller

12. Subject/Observer & Model-Controller-View Question

13. Calling Ctags within a rails model, controller, or view

14. Model, View, Controller question

15. Model View Controller basics.