Search code examples
gwtp

How to use GWTP for a ListView (Widget)?


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?


Solution

  • 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.