Hi coders,
I've been working on an app that uses the blobstore to save files and then serve them to users. They are shown in a CellTable by creating it and all of its columns in the view (Filename | DownloadButton | DateUploaded | DeleteButton) and then dropping it into a panel after construction. Snippet from the view:
fileTable = new CellTable<SupplierFile>();
fileNames = new TextColumn<SupplierFile>() // standard text column
{
@Override
public String getValue(SupplierFile object)
{
return object.getFilename();
}
};
downloadButtons = new Column<SupplierFile, String>(new ButtonCell())
{
// the text in the cell or button
public String getValue(SupplierFile object)
{
return "Download";
}
};
downloadButtons.setFieldUpdater(new FieldUpdater<SupplierFile, String>()
{
@Override
public void update(int index, SupplierFile object, String value)
{
GWT.log("Downloading " + object.getFileUrl());
Window.open(object.getFileUrl(), "_blank", "");
}
});
DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd/MM/yyyy"); // DD/MM/YYYY
fileDates = new Column<SupplierFile, Date>(new DateCell(dateFormat))
{
@Override
public Date getValue(SupplierFile object)
{
return object.getDate();
}
};
deleteButtons = new Column<SupplierFile, String>(/*new ClickableTextCell()*/ new ButtonCell())
{
// the text in the cell or button
public String getValue(SupplierFile object)
{
return "Delete";
}
};
deleteButtons.setFieldUpdater(new FieldUpdater<SupplierFile, String>()
{
@Override
public void update(int index, SupplierFile object, String value)
{
GWT.log("Deleting " + object.getFileUrl() + " | " + object.getId());
// WHAT GOES HERE???
}
});
The first 3 columns are all OK as they don't really require any logic - only the DownloadButton really but that's just a simple Window.open();
My question is how do I call my RPC's delete() function from the view? I should be using an event, right? All of the examples I have seen have some kind of clickHandler() interfaces being watched by the presenter, but how do I implement this using a CellTable? I can't access the eventBus as that's in my presenter. I'm very confused.
Any help is greatly appreciated.
Thanks,
Drew