带有Popup Presenter参数的PlaceRequest

时间:2011-09-22 03:11:17

标签: gwt gwt-platform

我试图将placerequest中的参数传递给将是弹出窗口的演示者,但是,我在弹出式演示者中收到空参数..我忘了什么?

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);
    }
}

我认为ai做错了什么......

提前感谢。

1 个答案:

答案 0 :(得分:1)

根据我在wiki中的理解,弹出窗口不能是一个地方,它需要一个父节目主持人。

我在这里看到两个明显的问题:

  • 您的第二个演示者(弹出窗口)应该实现PresenterWidget,而不是Presenter
  • 您无法通过调用placeManager.revealPlace()来显示弹出窗口,因为弹出窗口不是一个位置。相反,您必须应用wiki(addToPopupSlot()或RevealRootPopupContentEvent.fire()中解释的两种方法之一,这两种方法都是从父级调用的。)