Tuesday, January 24, 2012

Re: Making an RPC call from a CellTable ButtonCell in a view (MVP pattern)

MVC-wise I think it's on the fence since it's just throwing an event.
The presenter or the view can be changed without having to change the
delete code on either side.

To update my table on a delete I am passing the index of the row on
the delete event.

** Presenter **

@Override
public void onThingDeleteRequest(ThingDeleteEvent event) {
view.removeThing(event.getIndex(), --numThings);
service.deleteThing(event.getThing(), deleteThingCallback);
}


** View **

@Override
public void removeThing(int index, int numThings) {
dataProvider.getList().remove(index);
tableThings.setRowCount(numThings, true);
tableThings.setVisibleRange(0, numThings);
}

Not sure if those are the correct calls to make on the table but it
works for me. I also am not using paging.


On Jan 24, 9:24 am, Drew Spencer <slugmand...@gmail.com> wrote:
> It's a weird one, this. It does seem much easier to have
>
>                         deleteButtons.setFieldUpdater(new
> FieldUpdater<SupplierFile, String>()
> {
> @Override
> public void update(int index, SupplierFile object, String value)
> {
> TheApp.get().getEventBus().fireEvent(new DeleteFileEvent(object.getId()));
>
> }
> });
>
> in my view than do it any other way. At least I'm firing an event, so the
> actual logic is carried out in the presenter. It'll do for now I reckon! I
> don't want to get into modifying classes, etc. I'm only in the early stages
> of making this app so I'll move on to column sorting for now.
>
> What do you use CellTable for, Patrick?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment