How to make a window wait like Messagebox does

asked 2020-03-13 01:43:27 +0800

pablo123 gravatar image pablo123
35 2

Hi, I have (inside a window) a listbox rendered using args like this in zul file:

java.util.Map nombres = execution.getArg();
<listitem forEach="${each.value}" label="${each}" onClick="grid.UsersNameListController.obtenerNombre(self)"/>

And this is the method when te user clicks in one row of the list:

public class UsersNameListController extends SelectorComposer<Component>{
    public static void obtenerNombre(Listitem listitem){

        Window window = (Window) listitem.getParent().getParent().getParent().getParent().getParent();


In the class where I fire this new window I try to do window.getId(); to get the label as you can see in the code above. But the program just continues and the id it gets is the id before the user clicks on the row. I tried to stop the execution doing a while() loop but the browser doesnt show the new window, it shows the "Loading" gif at the corner of the screen. This is what I tried:

UUID uuid = UUID.randomUUID();
boolean salir=false;
while(!salir) {
     if (!window.getId().equals(uuid.toString())) {
nombre = window.getId();

I'm doing that in a window because I did not find a way to insert a list inside a Messagebox. So I need that "wait untill user press button" method in Messagebox for my window. ¿Any suggestion?

AND... my onClick method is static because zk forces me to make it static. It is giving me too many other problems to work. ¿How do I call onClick with out doing it static?

I'm using ZK 8.6.2. Thanks for your time and sorry for my bad english.

delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted

answered 2020-03-13 15:19:40 +0800

MDuchemin gravatar image MDuchemin
2480 1 6
ZK Team

Hi there,

From what you describe, the easiest solution for you would be to use a customized messagebox template. have a look here for more information, and here to find the original template (a good place to start customization.)

For the waiting at client / waiting at server part: ZK works with requests and responses. When the user does something, it sends a request to the server. The server then process the request and prepare a response, containing the updates to the UI.

If you try to wait inside of that request / response cycle (ex, in your composer), you will just make the server send the response a little later, but without changing the order of event. (while the client waits for the server, it will display that "processing..." message)

There are better way to work with this type of scenario. The standard to receive events and do something when received is event queues. You can define a queue, and post an event when the user does specific actions. For example, you could send an event when the user clicks on the row, and listen to this event to send the window doModal.

I'd recommend checking the server-push documentation if you need the server to send the update without a user's action to generate a request in your application. (this doesn't seem to be the case from your description, though)

Let me know if that works for you. If not, it's be useful if you could send a zk fiddle of your current code, to see the whole picture.

link publish delete flag offensive edit

answered 2020-03-19 00:42:11 +0800

pablo123 gravatar image pablo123
35 2

Thanks for your reply! The template of the messagebox is very useful and I will use it for sure. About my question... well, I noticed that Messagebox.show does not stop the program execution as I thought, so I decided to do all the logic in the same java class instead of launching the window frame from the main class, going to other class to control that window, and returning to the main class. In that way I dont need to wait for the variables to change. The event queues are quite difficult for me to work with, but I'll take a look at it. Thanks for your repli and have a nice day!

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: 2020-03-13 01:43:27 +0800

Seen: 12 times

Last updated: Mar 19 '20

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