本文介绍了如何将GWTP用于ListView(窗口小部件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在项目中使用GWTP,目前正在重新编写我的所有代码,以使其可与该库一起使用.

I started to use GWTP for my project and I'm currently re-writing all my code to let it work with this library.

但是,如果我想要例如,我很难理解如何使用GWTP.一个带有ListItemView个项目的ListView.

However, I struggle to understand how I use GWTP if I want e.g. a ListView with ListItemView items.

@Inject
public ToolsPresenter(PlaceManager placeManager, EventBus eventBus, MyView view, MyProxy proxy) {

    super(eventBus, view, proxy, AdminToolPresenter.SLOT_AdminToolMainContent);

    this.placeManager = placeManager;

    ToolListView toolListView = new ToolListView(...)
    ToolListPresenter toolListPresenter = new ToolListPresenter(....);

    this.setInSlot(SLOT_ToolList, toolListPresenter);
}

我想要的是将ListView放在插槽中.我非常确定我无法执行此处显示的操作,但是我不了解如何将简单的Widget与GWTP一起使用.

What I want is to place my ListView inside a slot. I am very certain that I can't do what is shown up there but I just don't get how I use just simple Widgets with GWTP.

还是我做这件事完全错误,我应该将Composite扩展为ListView,而根本不使用GWTP?

Or am I doing this completely wrong and I should just extend a Composite for ListView and not use GWTP stuff here at all?

推荐答案

您的问题中缺少很多信息,因此这是一个很难回答的问题.

There is a lot of information missing from your question so this is a difficult one to answer.

假设1 -您的GWTP工件(ToolListView,ToolListPresenter,ToolListView.ui.xml和ToolListModule)已正确设置,并且ToolListModule已安装在父模块中.

Assumption 1 - Your GWTP artifacts (ToolListView, ToolListPresenter, ToolListView.ui.xml, and ToolListModule) are setup correctly and ToolListModule is installed in a parent module.

假设2 -您正在使用GWTP 1.5+版本,其中已输入插槽.

Assumption 2 - You are using GWTP version 1.5+ which has typed slots.

您不应实例化ToolListView或ToolListPresenter.

You should not be instantiating your ToolListView or ToolListPresenter.

只需添加:

@Inject ToolListPresenter toolListPresenter;

如果您尝试调用setInSlot方法,则

If you are trying to call the setInSlot method then

  1. 确保ToolListPresenter是PresenterWidget
  2. 确保您的插槽不是NestedSlot.

最后,尝试将对setInSlot的调用移到构造函数之外,并移至覆盖的onBind()方法中.

Finally try moving the call to setInSlot outside of your constructor and into the overridden onBind() method.

这篇关于如何将GWTP用于ListView(窗口小部件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:07