I want to add an image to my celltable , for that i use imageResouce as below
interface Resources extends ClientBundle {
@Source("close.png")
ImageResource getImageResource();
}
Resources resources = GWT.create(Resources.class);
deleteJobColumn = new Column<EmployerJobs, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(EmployerJobs object) {
return resources.getImageResource();
}
};
Its working perfectly fine , i am getting image in my celltable but Now i want to add clickhandler to that image ,For that i am using field Updater like below
display.getListJobsWidget().getDeleteJobColumn().setFieldUpdater(
new FieldUpdater<EmployerJobs, ImageResource>() {
public void update(int index, EmployerJobs employerJobs,
ImageResource value) {
Window.alert("Hello");
}
});
so now when i click on that above image cell it should say “Hello”, but its not doing any thing .. Any solution ..
Thanks
ImageResourceCelldoesn’t have any wiring to call theValueUpdater, it is just designed to draw the image and be done with it.You have a few ways you can change this:
ImageResourceCelland override onBrowserEvent – take a look atButtonCellto see how this can workActionCell– this doesn’t take any data from the client, but will let you pass in a delegate isntead, which will be run when the thing is clicked. Use theActionCell(SafeHtml,Delegate<C>)constructor to pass in your image, in the form of htmlAbstractCell, borrowing the render code fromImageResourceCelland the event code fromButtonCellorActionCellto keep your code as generic and reusable as possible.