0

GWTWebアプリケーションを自社開発のMVCからGWTプラットフォームに適合させようとしています。

アプリケーションビューをプレゼンターに移植することができ、基本的にPlaceRequestを介してビューにアクセスできました。そして、URL(#)を変更します。

ただし、このGWTプラットフォームを使用してモデルを処理する方法がわかりません。一般的なMVPでは、RPCを介してサーバーからデータをフェッチするgo()メソッドがプレゼンターにあることを知っています。

GWTプラットフォームのプレゼンターには、Eclipseプラグインによって自動的に生成されるメソッドがあります。

  • コンストラクタ
  • revealInParent
  • onBind
  • onReset

モデルをフェッチして更新するRPCコードをどこに配置すればよいですか。私が持っているプレゼンターで言います:

ProfilePresenter.java:

public class ProfilePresenter
        extends
        Presenter<ProfilePresenter.MyView, ProfilePresenter.MyProxy> {

    public interface MyView extends View {
        HasText getFullname();
        HasText getLocation();
        HasText getAboutme();
        HasText getLastlogin();
    }

    private User user; // Model which represents the User information etc.

また、プレゼンターに関連付けられたビューが表示されたら、サーバーからユーザーモデルを取得してモデルを更新し、その後、公開されているインターフェイスを介してビューを更新する必要があります。

また、ビューにいくつかのボタンがあり、プレゼンターHasClickHandlerはイベントハンドラーをどこに配置すればアクセスできますか?

4

2 に答える 2

2

I would put the RPC call in the onReset method. See the presenter lifecycle

Personally I deal with events using the reversed MVP pattern. But you can also call a handler this way:

    getView().getSubmitButton().addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
        }
    });

with the following signature for getSubmitButton in your view interface:

HasClickHandlers getSubmitButton()
于 2012-02-26T07:39:09.777 に答える
0

Sydney covered most of your questions.

In general onResetmethod is a good place to make backend calls.
Sometimes when the backend call takes longer and you want to display the view only after the data was loaded you can use manual reveal.
But for the profile page I don't think that is necessary.

I also agree with the reverse MVP pattern. It's way easer to test presenters using the reverse MVP Pattern than using the HasXXXHandlers interfaces.

于 2012-02-26T18:35:28.893 に答える