1

I have this code in zk:

@Command
public void showModal(@BindingParam("languageContributionStatus") UserStatus mnoList) {
    //create a window programmatically and use it as a modal dialog.
    final HashMap<String, Object> map = new HashMap<String, Object>();
    setPickedItemSet(mnoList.getMnoList());
    map.put("mnoList", mnoList.getMnoList());

        win = (Window) Executions.createComponents("/comListMnosUser.zul", null, map);

        win.doModal();

}

In this code i have a page and i create a window with other page, in my other page:

<zk xmlns="http://www.zkoss.org/2005/zul">    

 <window id="CreateList" border="normal" mode="modal" width="320px"
            apply="org.zkoss.bind.BindComposer"
            viewModel="@id('vm') @init('com.UserMno')">
    <label value="First Name"></label>
    <listbox model="@bind(vm.allMno)" checkmark="true" multiple="true" selectedItems="@bind(vm.mnoList)"/>
    <button id="SaveBtn" hflex="1" label="Save" onClick="@command('save', mnosL=vm.mnoList)" />
</window>

</zk>

Then i need save the variable mnoList to use in the previous page, but i can not use Excecution.createComponent, because i need only close the window because i have win.doModal();

And use the variable mnoList, but i do not know how can i pass this variable to use in the other page.

Somebody can help me??

user2768380
  • 151
  • 1
  • 5
  • 21

1 Answers1

1

I think you are in right direction even no need to pass object as a argument with button which you did because mnoList is class variable or you can say ViewModel so it already available on your modal Window java class. What you can do .

1-Use same button and code something like this

<button id="SaveBtn" hflex="1" label="Save" onClick="@command('save')" />

2-In UserMno.java class use the method like this.And write logic to call Parent ViewModel method from Child ViewModel.

    @Command
    public void doReorder(@ContextParam(ContextType.VIEW) Component view) {
Map<String, Object> params = new HashMap<String, Object>(); //create a Map to store 
    params.put("param", mnoList);

        Binder bind = (Binder) view.getParent().getAttribute("binder");
        if (bind == null)
            return;
        bind.postCommand("parentclassMethodName", param);
}

This parentclassMethodName method should be in your parent ViewModel class.