0

Mvp4g アーキテクチャでは、(@Presenter アノテーションを使用して注入された) ビューの 1 つのインスタンス (のみ) がそのプレゼンターに関連付けられます。私の場合、プレゼンター EntityPresenter を持つ EntityView があります。ユーザーがナビゲータ ツリーのリーフ ノードをクリックするたびに、新しいタブを TabSet に追加します。そして、この新しいタブには EntityView が含まれます。したがって、TabSeT のタブと同じ数の EntityView を使用します。

multiple=trueEntityPresenterに設定しました。EntityView のコンストラクターは、1 つの引数を受け入れます。

@Inject
public EntityView(final Record view) {
  //some initialization
}

質問は、私がどこで行うかです (別のプレゼンターから):

EntityPresenter presenter = eventBus.addHandler(EntityPresenter.class);

Record params EntityView のコンストラクターに渡したい引数が 1 つあります。その方法を教えてください。@Inject でコンストラクター(引数を受け入れる)に注釈を付けると、 EntityView が EntityPresenter に注入されますか?

4

1 に答える 1

0

I suggest to use an EventHandler - that's a presenter without a view in mvp4g - which get an event showEntity(long key). In the onShowEntity(...) - method you can create the presenter with the statement:

EntityPresenter presenter = eventBus.addHandler(EntityPresenter.class);

With that reference of the instance, you can esaly set the key in the presenter. But keep in mind, you have to manage your presenter instances by yourself, when using multiple=true.

于 2012-01-18T15:31:11.070 に答える