-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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();
window.detach();
window.setId(listitem.getLabel());
}
}
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();
window.setId(uuid.toString());
window.doModal();
boolean salir=false;
while(!salir) {
if (!window.getId().equals(uuid.toString())) {
salir=true;
}
}
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.
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.
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!
Asked: 2020-03-13 01:43:27 +0800
Seen: 12 times
Last updated: Mar 19 '20
ZK Listbox Selectitems issue with Set
How to stop a bug from a listbox?
Cannot Change Listbox Header color & Background
Keyboard navigation in listbox
Can not display data in listbox
listbox with nonSelectabletags inplace new listitem
Input invoice using inline listbox
Change color to hover listitem listbox zk7 + Atlantic Theme
Listbox with autopaging causes constant row flickering
zk listbox getItems() returns null for item.getValue() if not scrolled fully