我试图将placerrequest中的参数传递给一个将是弹出式的演示器,但是,我在弹出式演示器中接收空参数。我忘了什么吗?
AddProjetoPresenter
public class AddProjetoPresenter extends Presenter<AddProjetoPresenter.AddProjetoView, AddProjetoPresenter.AddProjetoProxy>
{
@ProxyCodeSplit
@NameToken(NameTokens.addproj)
public interface AddProjetoProxy extends ProxyPlace<AddProjetoPresenter>
{
}
public interface AddProjetoView extends View
{
HasValue<String> getNome();
HasValue<Date> getDtInicio();
HasValue<Date> getDtFim();
HasClickHandlers getAddRequisitos();
HasClickHandlers getAddStakeholders();
HasClickHandlers getBtCancelar();
HasClickHandlers getBtSalvar();
}
private final DispatchAsync dispatch;
private final PlaceManager placeManager;
private Projeto projeto;
@Inject
public AddProjetoPresenter(final EventBus eventBus, final AddProjetoView view, final AddProjetoProxy proxy, final DispatchAsync dispatch,
final PlaceManager placeManager)
{
super(eventBus, view, proxy);
this.dispatch = dispatch;
this.placeManager = placeManager;
}
@Override
protected void revealInParent()
{
RevealContentEvent.fire(this, MainPresenter.TYPE_SetMainContent, this);
}
@Override
protected void onBind()
{
super.onBind();
getView().getBtSalvar().addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
}
});
getView().getAddRequisitos().addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
PlaceRequest pr = new PlaceRequest(NameTokens.addreq);
pr.with("oi", "oiiiii"); // HERE
placeManager.revealPlace(pr, false);
}
});
}
}
AddRequisitoPresenter
public class AddRequisitoPresenter extends Presenter<AddRequisitoPresenter.AddRequisitoView, AddRequisitoPresenter.AddRequisitoProxy>
{
@ProxyCodeSplit
@NameToken(NameTokens.addreq)
public interface AddRequisitoProxy extends ProxyPlace<AddRequisitoPresenter>
{
}
public interface AddRequisitoView extends PopupView
{
DialogBox getDialog();
}
private final DispatchAsync dispatcher;
private Projeto projeto;
@Inject
public AddRequisitoPresenter(final EventBus eventBus, final AddRequisitoView view, final AddRequisitoProxy proxy, final DispatchAsync dispatcher)
{
super(eventBus, view, proxy);
this.dispatcher = dispatcher;
}
@Override
public void prepareFromRequest(PlaceRequest request)
{
super.prepareFromRequest(request);
getView().getDialog().setText(request.getParameterNames().size() + ""); //SIZE IS ZERO!!
}
@Override
protected void onBind()
{
super.onBind();
}
@Override
protected void revealInParent()
{
RevealRootPopupContentEvent.fire(this, this);
}
}
我想我做错了什么…
根据我在wiki上的理解,一个弹出窗口不能是一个地方,它需要一个父演示器。
我看到两个明显的问题:
- 你的第二个演示器(弹出窗口)应该实现PresenterWidget,而不是presenter
- 你不能通过调用placeManager.revealPlace()来显示弹出窗口,因为弹出窗口不是一个位置。相反,您必须应用wiki中解释的两个方法之一(addToPopupSlot()或revealrootpopupcontenttevent .fire(),两者都是从父调用的)。