2

私はGWTに不慣れで、長いギャップの後にプログラミングに戻ります...私の質問はGWTでのMVP実装についてです、私は次の投稿を通過しました、そしてそれらは非常に役に立ちました、しかし私はまだいくつかの疑問を持っています

MVPとMVCとは何ですか?違いは何ですか? GWTアプリケーションを設計するためのあなたの推奨事項は何ですか?MVC、MVP、またはカスタムメッセージングソリューション?

MVPのGWTチュートリアル(http://code.google.com/webtoolkit/articles/mvp-architecture.html)にもコントローラー(AppController)があり、一部の応答はプレゼンターではなくコントローラーレベルで管理されていると思います。だから私の質問は、MVPパターンの実装におけるコントローラーの役割はどうあるべきかということです。

非同期サーバー呼び出し、プレゼンター、またはコントローラーをどこから開始する必要がありますか。たとえば、レコードを保存する必要がある場合は、プレゼンターからサーバー関数(DAOを呼び出してレコードを保存する)を呼び出すか、イベントバスとコントローラーを使用してプレゼンターがイベントを投稿する必要があります。イベントに基づいて動作し、サーバー関数を呼び出して保存します。

4

2 に答える 2

0

あなたの最後の段落に答えて、私はあなたがそれをすることになっているビューに何か(いくつかのボタン)があるならプレゼンターでそれをするべきだと思います。プレゼンターは論理的にビューに強く結びついています(技術的には、実装ではなくインターフェースによって弱く結び付けられている必要があります)。ビューから明示的に呼び出されないアクションのレコードを保存したい場合は、プレゼンターでは行いません。

于 2010-09-06T16:27:48.570 に答える
0

リンク先のGWTチュートリアルページには、AppControllerについての説明があります。

To handle logic that is not specific to any presenter and instead resides at the application layer, we'll introduce the AppController component.

So it's the glue between multiple Presenters, Views and the Model (maybe multiple Models). It also handles the browser history. And maybe additional things that aren't specific to one presenter.

As for the server call: There are several options, but I personally wouldn't do it from the view, and also not from the presenter - I'd use a model listener. The reason is, that multiple views and presenters can work together on one model. And when they change the model, that change should be sent to the server. Maybe you don't want to do that immediately, but collect a few changes before you send them. In that case, you could have a timer that's set up - well - by the AppController.

于 2010-09-06T22:34:47.560 に答える