-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello all,
I am wondering how to create a popup when someone clicks a menuitem that has a field for the user to input text?
For example, when they click save it will bring up a popup asking them to input the path where they want to save.
Hi diego898
You can refer to ZK demo
and you can replace toolbarbutton to any input you prefer
You can set popup attribute in menuitem
I create a sample
index.zul
<zk> <window id="win" apply="ctrl.Composer" width="300px" title="win" border="normal"> <toolbar> <toolbarbutton label="save" id="saveTb" /> </toolbar> </window> </zk>
package ctrl; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.SuspendNotAllowedException; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zul.*; public class Composer extends GenericForwardComposer { private Window win; private String path = ""; public void onClick$saveTb() throws SuspendNotAllowedException, InterruptedException { final Window dialog = (Window) Executions.createComponents("window.zul", win, null); dialog.doModal(); Button okBtn = (Button) dialog.getFellow("okBtn"); okBtn.addEventListener("onClick", new EventListener() { @Override public void onEvent(Event event) throws Exception { Textbox tb = (Textbox) dialog.getFellow("tb"); path = tb.getValue(); System.out.println(path); dialog.detach(); } }); } }
<zk> <window width="300px" title="save" border="normal"> <label value="Where are you want to save ?"/> <separator/> <textbox id="tb"/> <button label="OK" id="okBtn"/> </window> </zk>
Your example are very good. So when code processing come the "dialog.doModal();" line, it is going on. It doesn't stop that line. why? I'm expecting stop the code until close the window. I want to open three window in loop and receive input from user. After every input request, I'm expecting stop the code. How can I do these?
Thanks in advance.
That's because the eventThread.
It used to be that the tread stopped there but that's (for a good reason) deprecated.
You can still activate it.
Otherwise you just have to work with eventlisteners on the dialog.
Chill.
What are you talking about?
eventThread is only for ZK. Spring hasn't any reference to that.
Did you look at jimmyshiau solution(5 up)?
There is the example on how you can work with the eventlistener.
The code what you need to execute when user presses correct need to be there.
Chill.
Asked: 2010-06-30 16:36:33 +0800
Seen: 577 times
Last updated: Feb 02 '16