How to use GWTP for a ListView (Widget)?

给你一囗甜甜゛ 提交于 2019-12-12 02:59:14

问题


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

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

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.

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


回答1:


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

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

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

You should not be instantiating your ToolListView or ToolListPresenter.

Simply add:

@Inject ToolListPresenter toolListPresenter;

If you are trying to call the setInSlot method then

  1. Make sure ToolListPresenter is a PresenterWidget
  2. Make sure your slot is not a NestedSlot.

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



来源:https://stackoverflow.com/questions/35729549/how-to-use-gwtp-for-a-listview-widget

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!