-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
At the moment we are using the Spring Framework (version 5) in combination with ZK 9.6 with the Community Edition. For loading purposes we are trying to use threads to run processes in the background and display to the user when it is done.
We call Clients.evalJavaScript('displayMessage()') in the init of a VM and it works. But sadly :( when we call the method from a new thread, it seems to lose all the context and in the browser we do not see the result message.
Display message is just a function in our .zul that does simple console.log("message");
Can you help us navigate in the right direction?
Kind regards,
Remie
Essentially, what you need is server-push:
https://www.zkoss.org/wiki/ZKDeveloper%27sReference/Server_Push
Specifically, you need to: 1 - enable server push. This allow you to activate a ZK desktop from any thread, instead of only ZK "native" threads.
2 - Invoke Executions.activate(Desktop) targeting the relevant desktop. It has two purposes: It grants the right to access the UI of the given desktop to the caller's thread.
It establishes a connection with the client (the browser window displaying the desktop), such that the update will be sent to the client after finished.
3 - do updates (call ZK component methods, send client commands, etc.)
4 - invoke Exceutions.deactivate(Desktop) targeting the relevant desktop, to return the control, such that other thread could have a chance to update UI. Deactivate will also trigger the response to be sent to the client.
You can consider that activate / deactivate is essentially a transaction
Since you mentioned that you are using CE, the only server-push implementation available out of the box is polling-server-push: https://www.zkoss.org/wiki/ZKDeveloper'sReference/Server_Push/Configuration
(comet and websocket serverpush are PE/EE)
Asked: 2022-11-24 18:39:01 +0800
Seen: 9 times
Last updated: Nov 30 '22
bug with intboxes on mobile devices
zk keikai-how to add custom button/label to formulabar?
zk-keikai- update multiple cells parallel at same time asynchronously
zk-keikai-How to auto fit column width based on text
zk-keikai-ClipboardPateEvent-called twice
Reference a spring bean from VariableResolver
hmmm... interesting..
paulkey ( 2022-11-24 18:41:40 +0800 )edit