0

When i Click on delete messagebox ok button issue

asked 2014-06-04 08:52:35 +0800

sathishk gravatar image sathishk
17 5

updated 2014-06-04 09:58:30 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

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.

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2014-06-04 10:11:59 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

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.

link publish delete flag offensive edit

answered 2014-06-04 10:51:51 +0800

sathishk gravatar image sathishk
17 5

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
                        }
link publish delete flag offensive edit

answered 2014-06-04 11:51:44 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

may be it help:BindUtils.postNotifyChange(null,null,img,"*");

link publish delete flag offensive edit

answered 2014-06-04 12:11:23 +0800

sathishk gravatar image sathishk
17 5

Still no refresh in grid..

link publish delete flag offensive edit

answered 2014-06-04 12:48:00 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

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(){}
link publish delete flag offensive edit

answered 2014-06-04 13:24:02 +0800

sathishk gravatar image sathishk
17 5

Thank you. It's working properly....

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-06-04 08:52:35 +0800

Seen: 31 times

Last updated: Jun 04 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More