Bhuvan
Bhuvan

Reputation: 4177

send notification to parent class from nested class in Zk when using mvvm

class A{
  private List<B> list;
  // getter setter
  public class B{
    @command
    public void delete(){
       // remove itself from list
       // Now how to post event to event queue to update list on browser
    }  
  }
}

The list is bind in a zul page. One way i found is to use BindUtils.postNotifyChange(null, null, this, "list"); but it doesnt work

Upvotes: 0

Views: 572

Answers (3)

user2860053
user2860053

Reputation:

Try it:

BindUtils.postNotifyChange(null, null, A.this, "list");

Reference:

http://fossies.org/dox/zk-src-6.5.3/classorg_1_1zkoss_1_1bind_1_1BindUtils.html#a0634db05f8a346fc6cdd6a2c57848879

Upvotes: 0

Nabil A.
Nabil A.

Reputation: 3400

If A is the VM than the correct call is

BindUtils.postNotifyChange(null, null, A.this, "list");

In java you call the this pointer in a nested class with ParentClassName.this

Upvotes: 1

Andy Senn
Andy Senn

Reputation: 649

I'm not quite clear on what the question is, but I'll take a stab at answering it.

Since B is not static (must exist within the context of an instance of A), you can call A.this.list to access list from within B.

Upvotes: 0

Related Questions