0

Controller comunication

asked 2017-06-01 18:28:48 +0800

caiofilipemr gravatar image caiofilipemr
5 2

Hello everybody.

I am having trouble to find the best approach to maintain a communication beetwen two controllers which are running at the same time.

I have two controllers (A and B).

The A.zul file:

<window>
  //Other components
      <tabpanel>
        <include src="/views/B.zul"/>
      </tabpanel>
    </tabpanels>
  </tabbox>
</window>

The B.zul file:

<div id="divB" apply="pkg.B">
  <button onClick="divB$composer.doSomething();"/>
</div>

A.java:

class A extends GenericForwardComposer {
  public void doSomethigOnButtonInBControllerClicked() {
    // Do something when the button in the B controller was clicked.
  }
}

B.java:

class B extends GenericForwardComposer {
  public void doSomething() {
    // Call doSomethigOnButtonInBControllerClicked of A
  }
}

B is included by others controllers, which means it has to warn his "parent" without know who is it.

What is the best approach in this case?

Thanks in advance.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-19 08:37:48 +0800

Darksu gravatar image Darksu
1991 1 4

Hello caiofilipemr,

In order to communicate between parent-child i usually use global command:

http://books.zkoss.org/zk-mvvm-book/8.0/databinding/globalcommand_binding.html

For the second case scenario that is a little tricky, and will have to give some thoughts.

Best,

Darksu

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: 2017-06-01 18:28:48 +0800

Seen: 26 times

Last updated: Jun 19 '17

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