Question

I am new for GWT. I would like to know, is it possible to set the cell table content from the GWT Presenter? Is it OK to set the cell table data from the view itself and still following the MVP Pattern?

Was it helpful?

Solution

Don't confuse with GWT presenter and it's pattern. As you know that GWT presenter is contract to communicate between View and Model. it's good to write server dispatch code and event bus code in presenter and setting of data for GWT widgets in View itself.

After fetching celltable data from model to presenter, using dispatch.execute method. In onSuccess method, call a method which set data in celltable.

  • Define one method which set celltable data in View Interface

      public interface MyView  extends View
        {
         void setCellTableData(List<Data> dataList);
        }
    

    it will implemented in view class, write a code that set data of celltable there.

  • In presenter, onSuccess method set data like

    dispatch.execute(new GetDataAction(),
        new AsyncCallback<GetDataActionResult>() {
            @Override
            public void onFailure(Throwable caught) {
    
            }
            @Override
            public void onSuccess(List<Data> result) {
                 getView().setCellTableData(result);
            }   
            };
        });
    

OTHER TIPS

View is only to render the UI.

It should not hold the state of a specific domain object.

All view rendering business logic should be part of Presenter layer.

Better practices of MVP..

Use and Maintaining Different layers in MVP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top