4

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?

pb2q
  • 58,613
  • 19
  • 146
  • 147
japkpc
  • 73
  • 7

2 Answers2

3

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);
            }   
            };
        });
    
bNd
  • 7,512
  • 7
  • 39
  • 72
  • I am using AsyncDataProvider for setting the data to cell table, in that case how do i set the list? Also i am using RequestBuilder to fetch the data from server. – japkpc Mar 20 '13 at 06:38
  • write AsyncDataProvider setdata method in view. and pass data list in that method from presenter. – bNd Mar 20 '13 at 06:46
  • i have set the dataprovider, but the cell table is not displaying the data that is fetched from server. i am using RequestBuilder to fetch data from the server. At the time of setting the dataprovider in the presenter, request call back is not completed. how do i solve this?. – japkpc Mar 20 '13 at 08:15
  • set dataprovider after request call back completed. add code what you tried? – bNd Mar 20 '13 at 08:28
  • in the call back function i called tableView.setDataProvider(dataprovider); in tableview the setDataProvider will set the dataProvider.addDataDisplay(celltable); – japkpc Mar 20 '13 at 08:38
1

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.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307