Saturday, June 7, 2014

Am I need to have Presenter instance at View when using CellTable or DataGrid ?

Hi sirs , I am a newer for GWT and also in this group . And sorry for my English . Thanks.

I am trying to add a hyperlink in DataGrid and on clicking on that link I want to call a method.

I used as ...

// email

ClickableTextCell emailCell = new ClickableTextCell();

emailColumn = new Column<AdminModel, String>(emailCell) {

@Override

public String getValue(final AdminModel object) {

return object.getEmail();

}


@Override

public void render(final Context context, final AdminModel object, final SafeHtmlBuilder sb) {

sb.appendHtmlConstant("<a style =\"text-decoration:underline;cursor:pointer;\" >");

sb.appendHtmlConstant(object.getEmail());

sb.appendHtmlConstant("</a>");

@Override  public void onBrowserEvent(Context context, Element elem, AdminModel object, NativeEvent event) {      super.onBrowserEvent(context, elem, object, event);        Event evt = Event.as(event);      int eventType = evt.getTypeInt();      if (eventType == Event.ONCLICK) {          // Here I would like to RPC call           doSomething(object);      }  }


}

};


But I am using GWT MVP and I have no instance of Presenter instance at View. So I tried to call from Presenter as ....


view.getEmailColumn().setFieldUpdater(new FieldUpdater<AdminModel, String>() {


public void update(final int index, final AdminModel object, final String value) {

// Call RPC method HERE


}

});


If so , I can't get Element of clicked Column from Presenter (correct me if I am wrong ) . If Presenter instance has include in View , I think there has any problem.

So , please suggest me which way can I get clicked element from Presenter  ?

I am no sure is DataGrid or CellTable force me to create instance of Presenter at View side ?


Thanks for reading my question !

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment