开发者

Data Presentation Widgets + MVP

开发者 https://www.devze.com 2023-02-15 14:46 出处:网络
I am trying to use the new Data Presentation Widgets (cellTable) Now for a demo I am making, I used the example from here How to use GWT 2.1 Data Presentation Widgets to create a button in a column f

I am trying to use the new Data Presentation Widgets (cellTable)

Now for a demo I am making, I used the example from here How to use GWT 2.1 Data Presentation Widgets to create a button in a column for开发者_运维技巧 each row.

My understanding of MVP is that I would need to expose the HasClickEvents to my presenter from my view. How do I accomplish this?

Right now I have

projectGrid.addColumn(new Column<DataDTO, DataDTO>(new ActionCell<DataDTO>("Assign", new Delegate<DataDTO>() {
            public void execute(DataDTO row) {
                //Attach it here?
                Window.alert(row.toString());

            }
        })) {

            @Override
            public DataDTO getValue(DataDTO object) {
                // TODO Auto-generated method stub
                return object;
            }


        });


Yes, Delegate#execute() is the right place to invoke the callback to the presenter. There are a couple of ways you can do this but I find it easier to give my views a handle to their presenter and then define callback methods on the presenter:

class MyPresenter {
  public void onAssign() {
    // Perform action.
  }
}

class MyView {
  private MyPresenter presenter;

  public MyView() {
    projectGrid.addColumn(
      new Column<DataDTO, DataDTO>(
        new ActionCell<DataDTO>("Assign", new Delegate<DataDTO>() {
          public void execute(DataDTO row) {
            presenter.onAssign();
          }
        })) {...});
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消