0

MessageBox issue

asked 2013-02-19 03:24:37 +0800

jmyneni gravatar image jmyneni
5 1

updated 2013-02-19 05:21:53 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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

delete flag offensive retag edit

Comments

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

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-02-19 05:28:43 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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

answered 2013-02-19 15:55:25 +0800

jmyneni gravatar image jmyneni
5 1

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

link publish delete flag offensive edit

Comments

Please dont post question in answer section you can edit your question or ask a new question this will not going to help anyone.

sjoshi ( 2013-02-19 16:10:56 +0800 )edit

Got it...thank you!

jmyneni ( 2013-02-19 16:54:54 +0800 )edit
Your answer
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
2 followers

RSS

Stats

Asked: 2013-02-19 03:24:37 +0800

Seen: 35 times

Last updated: Feb 19 '13

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