Try to update the content of component A from another component B

asked 2023-02-07 15:34:39 +0800

reamer gravatar image reamer

Hi Support Team: I have a screen which is composed by more than one components. Each component is defined in a .zul file and with its own ViewModel class. Now, I want to update a field value of component A from component B when I triggered a command of button in component B. Because, component A and B are both the sub component of the screen. So, the global-command does not work.(Global command can only work from sub component and defined in parent component, am i right?)

Do you have any advice?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2023-02-09 17:52:05 +0800

MDuchemin gravatar image MDuchemin
2480 1 6
ZK Team

Hey there.

Could you make a small mockup of your current state in ZK fiddle? You are mentioning viewModels and commands, so I assume you are working in MVVM?

There are a few options you can consider. For example, you can use reference binding @ref to pass an object reference to both components, and trigger updates on that.

If you need to do a lot of redrawing when that value change, you can force an <apply> property update to redraw the content of that block entirely.

You can have your component send events, use that event to send commands to the page's parent VM, and update the value from the VM to the other component with notifyChange

You can use eventQueues to post messages between the different VMs of your application.

All of these have advantages and drawbacks. If you can post a short sample, it would be easier to recommend one method specifically.

link publish delete flag offensive edit

answered 2023-02-13 14:33:58 +0800

reamer gravatar image reamer

Thanks so much for your reply. Let me try it first.

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

1 follower



Asked: 2023-02-07 15:34:39 +0800

Seen: 11 times

Last updated: Feb 13

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