-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
Hi ,
there are plenty of way t do this some are these..
1- Make a boolean variable..
boolean showModelWindow = false;
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
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>
public class ParentCtrl extends GenericForwardComposer { private Button btnTest; private boolean isShowModal = false; public void onClick$btnTest(){ isShowModal = true; } }
<?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
I made a Basic Example here You can Download it from here Here
OK, thanks my friends Subodh Joshi :D
its very help me
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
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
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
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
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>
Thanks a lot Adriano. I will try your idea
Regards,
Pro G.
Asked: 2012-09-28 07:21:10 +0800
Seen: 562 times
Last updated: Oct 05 '12