MVC体系结构和模态对话框窗口 [英] MVC Architecture and Modal Dialog Windows

查看:78
本文介绍了MVC体系结构和模态对话框窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发MVC架构中的项目.它应该是管理某些客户的简单应用程序.

I am developing a project in a MVC architecture. It should be a simple application to manage some customers.

有MainModel,MainView和MainController类,这些类使主窗口可以显示客户表的内容,并允许用户插入,删除或编辑客户.

There are MainModel, MainView and MainController classes which make the main window to show the content of the customers tables and to let the user insert, remove or edit customers.

我的问题是插入和编辑按钮应该显示一些对话框窗口,以便用户插入和编辑一些文本值,我对此表示怀疑.

My problem is that the insert and edit buttons should show some dialog windows to let the user insert and edit some text values and I have some doubts.

我想问你一些问题:

  • 每个对话框窗口都应使用MVC架构吗?
  • 如果是,我尝试这样做,但是我的对话框窗口是模式窗口,因此我的代码运行模型,运行视图,但在视图中被阻塞并且不运行控制器类.我该怎么解决?

  • Should I use the MVC architecture for each dialog window?
  • If yes, I have tried doing it but my dialog windows are modal, so my code runs the model, runs the view but it gets blocked in the view and it doesn't run the controller class. How could I solve it?

例如,在这里,它在"new InsertCustomerController ..."指令中被阻止:

For example here it gets blocked in the "new InsertCustomerController..." instruction:

    CustomerModel customerModel = new CustomerModel();
    InsertCustomerView insertCustomerView = new insertCustomerView(customerModel);
    new InsertCustomerController(insertCustomerView, customerModel);

非常感谢您.

推荐答案

无论采用哪种方式,都可以使用观察者模式,以使对话框与应用程序的模型保持同步.此示例使用PropertyChangeListener此处.

Irrespective of modality, you can use the observer pattern to keep your dialogs synchronized with the application's model. This example uses a PropertyChangeListener; other approaches are mentioned here.

这篇关于MVC体系结构和模态对话框窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆