postGlobalCommand in Application scope

asked 2014-01-30 13:06:33 +0800

bartvdc gravatar image bartvdc
13 2

Using ZK 6.5.3 MVVM.
I'm trying to communicate events between different clients, different browsers running my application.
I thought that BindUtils.postGlobalCommand(null, APPLICATION, "somethingChanged", null) would be enough to send the event and @GlobalCommand(value = {"somethingChanged"}) to receive it. But I can't get this to work, my @GlobalCommand is never called.
Isn't this the correct way to do it in the MVVM style ?

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted

answered 2014-02-17 10:19:56 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9

updated 2014-02-18 10:16:47 +0800

Now your problem lies here :


The most important here is :

By default we can bind an event to any ViewModel's global command within the same desktop.

Application scope is higher then the desktop scope so we need to search how we can bind the global command to the application scope in stead of the desktop scope. I'm searching for it but at the moment little succes with it.

edit :

Found the solution :

You have to set the binder level to application like this :

 <window apply="org.zkoss.bind.BindComposer"
      viewModel="@id('vm') @init('be.chillworld.YourVM')" binder="@init(queueScope='application')">

and in the vm :

public void buttonClick () {
    BindUtils.postGlobalCommand(null, EventQueues.APPLICATION, "refresh", null);

public void refresh () {

you can also give a name to the "binder"so if you have multiple you can call just that queue like this

binder="@init(queueName='refreshIndex', queueScope='application')">

and in the VM you do this :

public void buttonClick () {
    BindUtils.postGlobalCommand("refreshIndex", EventQueues.APPLICATION, "refresh", null);

edit : The documentation here

Greetz chill.

link publish delete flag offensive edit

answered 2015-08-17 07:24:02 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9

Hey William,

Normally it's the binder who is subscribed to to scope. If you want to work in 2 scopes you need 2 viewmodels.

If it was me I should do this :

Create normal viewmodel, and another one subscribe to the application scope. In the application viewmodel you have a global-command (what resembles your application command). The first one you set a normal command for the viewmodel and there you call the global command with all the parameters what's needed.

Can you give this way a try?


link publish delete flag offensive edit


Hey Chill how was your weekend?

Thanks for the reply, however I went a different simplier way and used EventQueues and subscribe for the specific stuff and globalcommand for application wide communication.


WilliamB ( 2015-08-17 14:11:41 +0800 )edit

answered 2014-02-01 08:43:59 +0800

barracus gravatar image barracus flag of Italy
38 4

Could you post some code? Nave you put the @NotifyChange("myfieldToUpdate") just after @GlobalCommand?

link publish delete flag offensive edit

answered 2014-02-18 10:09:15 +0800

bartvdc gravatar image bartvdc
13 2

That works , thanks. Sorry that I can't upvote you yet (not enough points). A last question : Is there any reference, documentation to this feature ?

Greetz, Bart

link publish delete flag offensive edit

answered 2015-08-12 08:12:59 +0800

WilliamB gravatar image WilliamB
1609 1 6

But does that mean every command sent by my binder will now be application scoped?

what if i wanted to send only one command at application scope and other at desktop scope in the same view model?

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




Asked: 2014-01-30 13:06:33 +0800

Seen: 204 times

Last updated: Aug 17 '15

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