简体   繁体   English

基于MVP(模型视图演示器),我应该如何实现呢?

[英]Based on the MVP (Model View Presenter) how should I implement this?

I have a app on Google App Engine and I'm using GWT, and when the user goes to www.myapp.com/#show I need to show a graph, and in that page there is a button to search and add nodes to that graph, when the search Button is clicked I need to show a popup with the search form (it has several functions and dialogs). 我在Google App Engine上有一个应用程序,并且正在使用GWT,当用户转到www.myapp.com/#show时,我需要显示一个图形,并且在该页面中有一个按钮可以搜索并向其中添加节点该图,单击搜索按钮时,我需要显示一个带有搜索表单的弹出窗口(它具有多个功能和对话框)。

Can I create a view for that page and another view for the popup and use the same presenter for both? 我可以为该页面创建一个视图,为弹出窗口创建另一个视图,并为两者使用相同的演示者吗?

or What is the best way to implement that based on the pattern MVP? 或基于模式MVP的最佳实现方式是什么?

MVC(Model View Controller) style tells that you have this three packages for Entities, UI, Controller classes. MVC(模型视图控制器)样式告诉您具有用于实体,UI,控制器类的这三个包。 This help you organize your code and break it to plugins. 这可以帮助您组织代码并将其分解为插件。

As for your question it is better if you can implement a CustomPopUp class in the View(UI) package and make it abstact. 至于您的问题,最好是可以在View(UI)包中实现CustomPopUp类并将其抽象化。 So PopUp could have as parameters the message the context or everything it needs to show the approprate message. 因此PopUp可以将消息的上下文或显示适当消息所需的所有内容作为参数。

And you can pass CustomPopUp as private delegator to your UI classes who need to show popup messages. 而且,您可以将CustomPopUp作为私有委托者传递给需要显示弹出消息的UI类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM