0

change property binded to component in even listener fail

asked 2018-10-22 17:21:20 +0800

superium gravatar image superium
29 5
    @Command
    @NotifyChange({ "currentPost", "winvisible" })
    public void doAdopt() {
        Messagebox.show("sure?", "make sure",
                new Messagebox.Button[] { Messagebox.Button.OK, Messagebox.Button.CANCEL }, Messagebox.QUESTION,
                new EventListener<ClickEvent>() {

                    @Override
                    public void onEvent(ClickEvent event) throws Exception {
                        if (Messagebox.Button.OK.equals(event.getButton())) {
                            //do somthing here ,if success:
                            setWinvisible(false);     //failed to hide my window.and got null exception atfer this executed, and click component in the window.

                            } else {
                                //do something
                            }
                        }

                    }

                });
        if (.........) 
            setWinvisible(false);      //success, and this executed before user response the messagebox.
    }

hello, I'm using MVVM, and failed to hide my window in the even listener. any suggestion ?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-10-23 10:18:03 +0800

cor3000 gravatar image cor3000
6280 2 7

inside the event listener (which is not an MVVM command handler) method you have to trigger the notify change programmatically.

if (Messagebox.Button.OK.equals(event.getButton())) {
    //do something here, if success:
    setWinvisible(false); 
    BindUtils.postNotifyChange(null, null, YourViewModelClass.this, "winvisible");
} else {
    //do something
}
link publish delete flag offensive 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: 2018-10-22 17:21:20 +0800

Seen: 5 times

Last updated: Oct 23 '18

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