I have a GWT 2.4 app using MVP, clientFactory, activities, places, and uiBinder. I have a composite widget that I created as a standalone object with it's own ui.xml file. I reference that class and insert it into the main viewImpl.ui.xml file.
The composite widget receives some data from the backend and I need to get it back to the activity so it can be displayed in a table. I'm using the presenter that is associated with the view to get to the activity. Here is the code: In the View interface:
public interface NameView extends IsWidget
{
void setPresenter(Presenter presenter);
...
public interface Presenter{
void goTo(Place place);
void setRowDataList(List<Data> rowData);
}
In my Activity I implement the View.Presenter as in:
Activity extends AbstractActivity implements NameView.Presenter
so the activity is the presenter I need from within my standalone widget and in the start method for the activity I use:
NameView nameView = clientFactory.getNameView();//NameView is just an example.
nameView.setPresenter(this); ...
to setup the presenter and instantiate it. My problem is, in the widget I need this:
presenter.setRowDataList(rowData);
but I'm not sure how to reference the instantiated Presenter from the widget?
This separate widget, actually a gwtUpload widget, is standalone. I do a server side calculation on some data that is uploaded and that is what is returned back to this widget.
The widget data needs to get back to the Activity in order to pass that data back to the NameViewImpl class.
I thought the presenter was the proper way to do that, but since the widget isn't wired to the view or viewImpl I need a way to get that presenter for the widget.
I know GIN would do it with DI or maybe I create another presenter. I've never setup GIN with GWT. Any ideas as to the correct way to do this?
Working Implementation:
I don't know if this is the best implementation or not, but based on the answer from Thomas, I set my widget with the instance of the presenter(activity) in the setPresenter() method in the ViewImpl class. It works as a pass-through for the widget to return back to the activity. I assume that is what Thomas meant as a callback interface.