0

popup with input?

asked 2010-06-30 16:36:33 +0800

diego898 gravatar image diego898
246 3

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.

delete flag offensive retag edit

11 Replies

Sort by ยป oldest newest

answered 2010-06-30 20:31:20 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2010-06-30 20:35:56 +0800

Hi diego898
You can refer to ZK demo
and you can replace toolbarbutton to any input you prefer

link publish delete flag offensive edit

answered 2010-07-01 09:39:24 +0800

diego898 gravatar image diego898
246 3

What I mean is that when a user presses "save" a popup box will popup asking them for a file name

link publish delete flag offensive edit

answered 2010-07-01 20:58:30 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2010-07-01 20:58:50 +0800

You can set popup attribute in menuitem

link publish delete flag offensive edit

answered 2010-07-02 14:03:15 +0800

diego898 gravatar image diego898
246 3

I dont understand what you mean by that? When a user presses save in a menuitem, I want a popup window asking him to input some string of text to where I will save a file.

link publish delete flag offensive edit

answered 2010-07-04 04:29:17 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

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>


Composer.java
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();
			}
		});
		
	}
	
}



window.zul
<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>

link publish delete flag offensive edit

answered 2010-07-05 12:27:47 +0800

diego898 gravatar image diego898
246 3

Great than you so much!

link publish delete flag offensive edit

answered 2016-01-28 07:04:36 +0800

Icebergx5 gravatar image Icebergx5
1

updated 2016-01-28 07:05:33 +0800

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.

link publish delete flag offensive edit

answered 2016-01-28 08:02:15 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

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.

link publish delete flag offensive edit

answered 2016-01-29 08:28:53 +0800

Icebergx5 gravatar image Icebergx5
1

Ok. But I'm using spring. So what can I do now?

Thanks.

link publish delete flag offensive edit

answered 2016-01-29 10:43:55 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

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.

link publish delete flag offensive edit
Your reply
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

Follow

RSS

Stats

Asked: 2010-06-30 16:36:33 +0800

Seen: 577 times

Last updated: Feb 02 '16

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