0

How to open a zul file as popup

asked 2012-09-28 07:21:10 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Hi all, Good afternoon.

it's possible to make a .zul file opened using button, for example :

-- MasterContact.zul --
<window id="wind">
<label value="Its master contact window" />
</window>

-- MasterPerson --
<window id="masterperson">
Contact Id : <textbox id="contactId"><button id="btnLOV" onClick" bla bla bla" />
</window>

I want to fill bla bla bla as a parameter for onClick method ??

Thanks all.

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2012-09-28 10:08:58 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Hi ,
there are plenty of way t do this some are these..
1- Make a boolean variable..

boolean showModelWindow = false; 

in your view model class. and make a button in ur parent Zul file..When you click on this button make
showModelWindow  =true;
Or 
@Command 
@NtifyChange("showModelWindow")
public void showModelWindow(){
showModelWindow = true;
}

And in your Child Zul file which will be use to show data in pop Window add these attributes inside your window.

position="center"  popup="true" closable="true" mode="modal"
OR You can say
  <window  border="normal" title="Calendar Manager" position="center"  popup="true" closable="true" mode="modal">

Its a Single way to do this there are other way also.
thanks

link publish delete flag offensive edit

answered 2012-09-28 14:07:30 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Thank for reply sjoshi,

I already made
1. Parent.zul

<?page title="Parent" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Parent" border="normal" apply="com.test.ParentCtrl">

<button id="btnTest" label="Open" />

</window>
</zk>

2. ParentCtrl
public class ParentCtrl extends GenericForwardComposer {
	
	private Button btnTest;
	
	private boolean isShowModal = false;
	
	public void onClick$btnTest(){
		
		isShowModal = true;
		
	}

}

3. Child.zul
<?page title="Child" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="Child" border="normal" position="center"  popup="true" closable="true" mode="modal">

Testing testing

</window>
</zk>

But, no action when I click the btnTest,, where's the relation of the btnTest and Child.zul ?? and how to make it ??

thank

link publish delete flag offensive edit

answered 2012-09-28 17:51:02 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

I made a Basic Example here You can Download it from here Here

link publish delete flag offensive edit

answered 2012-09-29 01:11:14 +0800

progamerdotcom gravatar image progamerdotcom
117 5

OK, thanks my friends Subodh Joshi :D

its very help me

link publish delete flag offensive edit

answered 2012-10-03 13:17:10 +0800

aros54 gravatar image aros54
66

I think this is a simpler solution:

The main window:

  <window id="main" width="50%" title="Main window" border="normal">
	<vbox>
		<label value="This is the main window"/>
		<button label="Open child window" onClick="doOpen();"/>
	</vbox>
<zscript><![CDATA[
	void doOpen() {
		// Assumption! child.zul contains a window component
		try {
			((Window)Executions.getCurrent().createComponents("child.zul", main, null)).doModal();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
]]></zscript>
  </window>

and child.zul:

<window id="child" width="200px" title="Child window" border="normal" closable="true">
	<vbox>
		<label value="This is the child window"/>
		<button label="Close child window" onClick="child.detach()"/>
	</vbox>
</window>

/Adriano

link publish delete flag offensive edit

answered 2012-10-03 14:27:25 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Thanks aros45,

If I modify your code with textbox1 additional, how to make, this textbox will be set with a variable in child.zul when button child is detach.

<window id="main" width="50%" title="Main window" border="normal">
	<vbox>
		<label value="This is the main window"/>
		<textbox id="textbox1" value=" . . . ."/>
		<button label="Open child window" onClick="doOpen();"/>
	</vbox>
<zscript><![CDATA[
	void doOpen() {
		// Assumption! child.zul contains a window component
		try {
			((Window)Executions.getCurrent().createComponents("child.zul", main, null)).doModal();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
]]></zscript>
  </window>

Thanks

link publish delete flag offensive edit

answered 2012-10-03 15:02:17 +0800

aros54 gravatar image aros54
66

Well, the answer to the general question "how to open a window stored in a zul file" has been given: build dynamically a component and open it. You can also pass parameters to the opened component using a Map as the 3rd parameter of createCompanents method.
To pass back values from the opened component you need a specific model and a controller that is able to "trigger" the set Value of your textbox when the component is closed.
Now, I suspect you are trying to make a UI with a pop-up window on which you can make a selection of some items to be displayed on the main window. If the logic is very complex you have to build your model and controller classes to manage your business. However I invite you to look if some ZK components such as bandbox and bandpopup can help you.
/Adriano

link publish delete flag offensive edit

answered 2012-10-03 16:09:41 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

ModelWindow is a Child Component for Parent.zul file and if you have OK and Cancel button in your ModelWindow you can call PostCommand onclick on these button and pas the value of from ModelWindow to your Parent.zul file.Which will be Something Like this..

@Command
	public void doSomething(@ContextParam(ContextType.VIEW) Component view) {
		Map<String, Object> params = new HashMap<String, Object>();
		ListModelList<String> MyList = new ListModelList<String>();
		for (MyData data : getDataModel()) {
			MyList .add(data.getColumnHeaderName());

		}

		params.put("MyList ", MyList );
		Binder bind = (Binder) view.getParent().getAttribute("binder");
		if (bind == null)
			return;
		bind.postCommand("doSomethingInParentModel", params);
		chilID.detach();
	}

This you can write in Child.zul Model Class or we can say Model Wndow, Model Class And call your Parent.zul ViewModel class Method doSomethingInParentModel()
Thanks

link publish delete flag offensive edit

answered 2012-10-04 08:59:53 +0800

aros54 gravatar image aros54
66

Provided that I keep saying that in my humble opinion this is not the way to do such things, to set the main window textbox value with something coming from child window you can pass the main window textbox to the child window as a parameter. When you close the child window you can set this parameter value to whatever you want. Only remember to save the parameters when entring the child window because the arg Map is not available to the events. This is the code:

main.zul

<zk>
  <window id="main" width="50%" title="Main window" border="normal">
	<vbox>
		<label value="This is the main window"/>
		<textbox id="mainText"/>
		<button label="Open child window" onClick="doOpen();"/>
	</vbox>
<zscript><![CDATA[
	void doOpen() {
		Map parms = new HashMap();
		parms.put("mainText", mainText);
		// Assumption! child.zul contains a window component
		try {
			((Window)Executions.getCurrent().createComponents("child.zul", main, parms)).doModal();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
]]></zscript>
  </window>
</zk>

child.zul

<window id="child" width="200px" title="Child window" border="normal" closable="true" onClose="doClose();">
	<vbox>
		<label value="This is the child window"/>
		<textbox id="childText"/>
		<button label="Close child window" onClick="doClose();"/>
	</vbox>
<zscript><![CDATA[
    
    Map childArg = arg; //preserves arg because it is not available to events
    
	void doClose() {
		Textbox mainText = (Textbox)childArg.get("mainText");
		mainText.setValue(childText.getValue());
		child.detach();
	}
]]></zscript>

link publish delete flag offensive edit

answered 2012-10-05 06:56:00 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Thanks a lot Adriano. I will try your idea

Regards,

Pro G.

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: 2012-09-28 07:21:10 +0800

Seen: 562 times

Last updated: Oct 05 '12

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