-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am trying to delete one row from grid,but delete row from database but its shows grid and when i refresh page that row delete, please provide me automatic refresh not working when i delete the record.
Please help me.
@Command
@NotifyChange({"galleryList","showLineGrid"})
public void onDelete(@BindingParam("Imageupload") final Imageupload img)
{
showLineGrid = false;
System.out.println("Enter Delete Record:-");
Messagebox.show("Are you sure you wish to delete this record?",
"Delete Confirm?", Messagebox.OK | Messagebox.CANCEL,
Messagebox.QUESTION,
new org.zkoss.zk.ui.event.EventListener(){
public void onEvent(Event e){
if(Messagebox.ON_OK.equals(e.getName())){
System.out.println("Enter On delete Method:-"+img);
int id= Integer.parseInt(img.getNv_galleryupload_id());
/*Deleting lines*/
List<MUploadGallerySHeader> images = new Query(Env.getCtx(), MUploadGallerySHeader.Table_Name, " NV_UploadGallery_ID= "+id, null).setOnlyActiveRecords(true).list();
for(MUploadGallerySHeader shdr:images)
{
shdr.delete(true);
}
/*Deleting header*/
MUploadGallery hdr = new MUploadGallery(Env.getCtx(),id, null);
/*delete gallery folder here*/
String folderPath ="";
if(hdr.getNV_UploadGallery_ID()>0 && hdr!=null)
{
folderPath=SAVE_PATH+hdr.getProject_Name()+File.separator+File.separator+"construction"+File.separator+File.separator
+hdr.getTower_Name()+File.separator+File.separator+hdr.getYear()+File.separator+File.separator+hdr.getMonth();
System.out.println(" Header SAVE_PATH+folderPath -------- "+folderPath);
deletefile(folderPath);
}
hdr.delete(true);
galleryList= new GalleryUploadServiceImpl().getImageuploadsList("");
// binder = (AnnotateDataBinder) e.getTarget().getAttribute("binder", true);
// binder.loadAll();
}else if(Messagebox.ON_CANCEL.equals(e.getName())){
//Cancel is clicked
}
}
}
);
}
Please help i am struck here.
Hi there,
This is normal, you rely on the @NotifyChange
but actually your object is already notified before the actual delete is happend cause you use the EventListener
.
solution :
hdr.delete(true);
galleryList= new GalleryUploadServiceImpl().getImageuploadsList("");
BindUtils.postNotifyChange(null,null,className.this,"galleryList");
BindUtils.postNotifyChange(null,null,className.this,"showLineGrid");
}else if(Messagebox.ON_CANCEL.equals(e.getName())){
//Cancel is clicked
}
Greetz chill.
thank you for reply,
Still no refresh on grid, I am added this class,see once
hdr.delete(true); galleryList= new GalleryUploadServiceImpl().getImageuploadsList(""); BindUtils.postNotifyChange(null, null,img, "galleryList"); BindUtils.postNotifyChange(null,null,img,"showLineGrid");
}else if(Messagebox.ON_CANCEL.equals(e.getName())){
//Cancel is clicked
}
may be it help:BindUtils.postNotifyChange(null,null,img,"*");
Oke possible that that won't work.
What definitly works is this :
hdr.delete(true);
galleryList= new GalleryUploadServiceImpl().getImageuploadsList("");
BindUtils.postGlobalCommand(null, null, "refresh", null);
} else if(Messagebox.ON_CANCEL.equals(e.getName())){
//Cancel is clicked
}
and you make a new method :
@GlobalCommand
@NotifyChange({"galleryList","showLineGrid"})
public void refresh(){}
Asked: 2014-06-04 08:52:35 +0800
Seen: 31 times
Last updated: Jun 04 '14