1

[Solved]How to get event ?

asked 2015-01-25 04:19:21 +0800

unitcell gravatar image unitcell
28 4

updated 2015-01-25 13:30:27 +0800

Hi all,

How do I to get event in view model to stop propagation ? like below code.

@Command @NotifyChange("model")
public void delete(Event event) {

event.stopPropagation();

Messagebox.show("Delete it ?", "confirm", Messagebox.YES|Messagebox.NO, Messagebox.QUESTION,
  new EventListener(){
    public void onEvent(Event e) throws Exception {
      if(e.getName().equals("onYes")) {
        System.out.println("Do change");
        modellist.remove("Yes");
        modellist.add("None");
      }
    }
  });

}

public List<String> getModel(){
System.out.println("Changing...");
return modellist;

}


<window title="Hello World!!" border="normal" width="300px" height="200px"
     apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('TestVM')">
<vlayout>
<button label="delete" onClick="@command('delete')"/>
<label value="@load(vm.model)"/>
 </vlayout>

</window>

Thanx.

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2015-01-25 07:17:02 +0800

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

what about this :

@Command 
@NotifyChange("model")
public void delete(@ContextParam(ContextType.TRIGGER_EVENT) Event event)) {
    ...
}

Greetz chill.

link publish delete flag offensive edit
1

answered 2015-01-25 09:53:39 +0800

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

updated 2015-01-25 09:53:52 +0800

In stead of using the annotation @NotifyChange use the BindUtils class. You can put in code when you want to notify the binder.

example :

Messagebox.show("Delete it ?", "confirm", Messagebox.YES|Messagebox.NO, Messagebox.QUESTION, new EventListener(){
public void onEvent(Event e) throws Exception {
  if(e.getName().equals("onYes")) {
    System.out.println("Do change");
    modellist.remove("Yes");
    modellist.add("None");
    BindUtils.postNotifyChange(null,null,modellist,"*");
  }
}
});
link publish delete flag offensive edit
1

answered 2015-01-25 18:26:31 +0800

Darksu gravatar image Darksu
1991 1 4

Hello unitcell,

In a similar issue i changed the value of the disable-event-thread as shown in the following url:

http://books.zkoss.org/wiki/ZKConfigurationReference/zk.xml/Thesystem-configElement/Thedisable-event-threadElement

Best Regards,

Darksu

link publish delete flag offensive edit

Comments

For a reason decrepated from version 7.0.0

chillworld ( 2015-01-25 19:03:13 +0800 )edit
0

answered 2015-01-25 08:58:30 +0800

unitcell gravatar image unitcell
28 4

Great ! Thank you, chillworld.

It still cannot to stop notify change. I want @notfiychange to run after Messagebox(user confirmed).

Do u have any idea ?

Thanx.

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
1 follower

RSS

Stats

Asked: 2015-01-25 04:19:21 +0800

Seen: 23 times

Last updated: Jan 25 '15

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