gwtpgwt-platform

GWTP how to pass data from presenter to view


I have view with table. I would like to pass data to that table. Data is got from server using rest.

What is the best and clean way to pass data?

I've would do this using constructor? But view is generated by Presenter, so I cannot do this.

I've also ui handler for this view, but I use this only to get data from view (inputs f.e.) not the other way.


Solution

  • So you define a setter in your view interface first

    public interface MyView extends View, HasUiHandlers<...> {
        void setModel(MyModel model);
    }
    

    Then you implement the method in the ViewImpl, and in your presenter just call getView().setModel(...) from your service's onSuccess callback or any other place