0

How to return a selection value from a modal window?

asked 2011-05-23 15:55:10 +0800

davout gravatar image davout
1435 3 18

I have a modal window that displays a listbox. What's the best way of returning a listbox selection result from a modal window?

I'm creating the modal window using 'createComponents'.

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2011-05-23 17:22:17 +0800

twiegand gravatar image twiegand
1807 3

Davout,

You might try doing something like this:

main.zul

<zk>
	<window id="win" onReceive="getModalData();">
		<button label="Open" onClick='Executions.createComponents("modalWindow.zul", win,null);'/>
		<label id="lbl"/>
		<zscript>
			void getModalData(){
				lbl.setValue(event.getData());
			}
		</zscript>
	</window>
</zk>

modalWindow.zul

<zk>
	<window title="please input" border="normal" mode="modal">
		<attribute name="onClose">
			Events.postEvent(new Event("onReceive",self.getParent(), tb.getValue()));
		</attribute>
		<textbox id="tb" />
		<button label="Accept" onClick='Events.postEvent(new Event("onClose",self.getParent()));'/>
	</window>
</zk>

Hopefully this will give you an idea or two.

Regards,

Todd

link publish delete flag offensive edit

answered 2011-05-24 03:56:36 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2011-05-24 04:08:25 +0800

There are samples of such modal search listboxes in my blog. All of them gives back a selected object.
The little trick is the private constructor and a static method for calling them.

call: Branch branch = BranchSearchListBox.show(parentComponent);

Such a pure java solution can be modified in 10 minutes to work for an other search approach.

best
Stephan

PS: See such a searchListBox working live in the customer dialog module here .
In the dialog you must first click the CRUD 'edit' button than you can try three of these searchListBoxes. 'simple', 'advanced' and 'extended'

link publish delete flag offensive edit

answered 2012-06-13 16:52:14 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi Stephan

In your case, i think you created the search customer in pure java. But in my case, i have a seperate zul and controller using MVC.
And also, i am calling using execute.create components.

So in this case, how we can receive the return value ?

Can you please help me

link publish delete flag offensive edit

answered 2012-06-14 11:16:18 +0800

vincentjian gravatar image vincentjian
2245 6

Hi Senthilchettyin,

For separate zul files, you can use EventQueue. Refer to this document

link publish delete flag offensive edit

answered 2012-06-14 12:52:47 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thank you vicent. But i am using MVVM . Can you please help me on that too..?

link publish delete flag offensive edit

answered 2012-06-15 10:39:32 +0800

vincentjian gravatar image vincentjian
2245 6

Hi Senthilchettyin,

You can try global command, refer to this document.

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: 2011-05-23 15:55:10 +0800

Seen: 1,045 times

Last updated: Jun 15 '12

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