-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have a form where I collect user input and when the user clicks on 'Save' button...I display a message box asking for confirmation. I would like to proceed with the save only when the user clicks OK. The problem I have is, my 'Save' code gets executed whether the user presses 'OK' or 'Cancel'. I checked on the forum and added the following line to my zk.xml:
<system-config>
<disable-event-thread>false</disable-event-thread>
</system-config>
My java code:
public void onClick$saveSchd() {
Integer confirmSave = Messagebox.show("Are you sure?", "Confirm Schedule", Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
if ( confirmSave == Messagebox.OK) {
// Call Hibernate queries to save
Messagebox.show(selManagers + "have been successfully scheduled for " + selectedSat.getLabel(), "Results", Messagebox.OK, Messagebox.INFORMATION);
}
}
What am I doing wrong? Thank you for your time.
Regards, Jyothi
This is not the way to fire a event you have do get which event fire by user in MessageBox..See below code
Messagebox.show("Are you sure, Do you want to delete ?", "Confirm Dialog", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
new org.zkoss.zk.ui.event.EventListener() {
public void onEvent(Event evt) throws InterruptedException {
if (evt.getName().equals("onYes")) {
// Add business logix
}else{
// Add Business Logic
}
});
}
Hi,
Thank you for your response. I modified my code as below and it works. I now have to deal with the $1 in class name...UNIX is not letting me upload the two classes - satSchdHandler.class and satSchdHandler$1.class.
Thank you again for your response.
public void onClick$saveSchd() {
Messagebox.show("Are you sure?", "Confirm Schedule", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, new org.zkoss.zk.ui.event.EventListener() { public void onEvent(Event evt) throws InterruptedException { if (evt.getName().equals("onYes")) { alert("Yes pressed"); } else { alert("No pressed"); } } } ); }
Regards, Jyothi
Asked: 2013-02-19 03:24:37 +0800
Seen: 35 times
Last updated: Feb 19 '13
I don't suggest you to enable event-thread, it is not safe/legal in JEE app and was deprecated, you could use the Listener as a call back to listen to user's action, just like @sjoshi 's Answer
dennis ( 2013-02-19 06:27:55 +0800 )edit