Revision history [back]

click to hide/show revision 1
initial version

asked 2014-11-10 13:41:11 +0800

srikant2013 gravatar image srikant2013

zk mvvm rebind an input field

I am trying to populate a textbox value on change of a combobox in a mvvm form. Data updates in textbox correctly but validator class getting null value for the textbox field on click of save button. How to rebind the textbox value to vm?

Here is my form code...

<window id="w_add_list" title="Add New Object" position="center,top" border="normal" width="800px" closable="true">
<zscript>

    <style>   
        .error {color:#ff0000; font-size: 11px;}
    </style>

    <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.qk.or.ORListViewModel')"
        validationMessages="@id('vmsgs')" form="@id('list') @save(vm.newList, before='add') 
        @validator('com.qk.or.ListAddValidator')">
        <grid>
            <rows>
                <row>
                    <cell width="200px">
                        <label value="Module" />
                    </cell>
                    <cell width="280px">
                        <combobox width="250px" id="pn" autodrop="true" buttonVisible="false" model="@load(vm.modules)" value="@bind(list.module_Name)" selectedItem="@bind(list.module_Name)" tabindex="1">
                            <attribute name="onChange"><![CDATA[
                                String mod = self.getValue();

                                if (! mod.equals("")) {
                                    ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();
                                    List list2 = tcdao.getSubModulesByModule(mod);

                                    ListModelList lm2 = new ListModelList(list2);
                                    pt.setModel(lm2);
                                }
                            ]]></attribute>
                        </combobox>
                    </cell>
                    <label class="error" value="@load(vmsgs['module_Name'])" />
                </row>
                <row>
                    <label value="Sub Module" />
                    <combobox width="250px" id="pt" autodrop="true" buttonVisible="false" value="@bind(list.subModule_Name)" selectedItem="@bind(list.subModule_Name)" tabindex="2">
                        <attribute name="onChange"><![CDATA[
                            String mod = pn.getValue();
                            String smod = self.getValue();

                            if (! mod.equals("") && ! smod.equals("")) {
                                ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();

                                ObjectRepository or = new ObjectRepository();
                                or.setModule_Name(mod);
                                or.setSubModule_Name(smod);

                                String tname = tcdao.getTemplate(or);

                                if (tname != null && ! tname.equals("")) {
                                    tb_tname.setValue(tname);
                                    tb_tname.setReadonly(true);

                                } else {
                                    tb_tname.setReadonly(false);

                                }

                            }
                        ]]></attribute>
                    </combobox>
                    <label class="error" value="@load(vmsgs['subModule_Name'])" />
                </row>
                <row>
                    <label value="Template (Container Name)" />
                    <textbox width="250px" id="tb_tname" autodrop="true" buttonVisible="true" value="@bind(list.template_Name)" tabindex="3" />
                    <label class="error" value="@load(vmsgs['template_Name'])" />
                </row>
                <row>
                    <label value="UI Name" />
                    <textbox value="@bind(list.UI_Name)" width="250px" tabindex="4" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Navigation Path" />
                    <textbox value="@bind(list.navigation_Path)" width="250px" tabindex="5" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="OR Module" />
                    <textbox value="@bind(list.OR_Module)" width="250px" tabindex="6" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Name" width="100px" />
                    <textbox value="@bind(list.window_Name)" width="150px" tabindex="7" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Properties" />
                    <textbox value="@bind(list.window_Properties)" width="250px" rows="3" tabindex="8" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Name" />
                    <textbox value="@bind(list.page_Name)" width="250px" tabindex="9" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Properties" />
                    <textbox value="@bind(list.page_Properties)" width="250px" rows="3" tabindex="10" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Name" />
                    <textbox value="@bind(list.table_Name)" width="250px" tabindex="11" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Properties" />
                    <textbox value="@bind(list.table_Properties)" width="250px" rows="3" tabindex="12" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Dialog Box" />
                    <textbox value="@bind(list.dialogBox)" width="250px" tabindex="13" />
                    <label class="error" value="@load(vmsgs['dialogBox'])" />
                </row>
                <row>
                    <label value="Dialog Properties" />
                    <textbox value="@bind(list.dialog_Properties)" width="250px" rows="3" tabindex="14" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Screen Name" />
                    <textbox value="@bind(list.screen_Name)" width="250px" tabindex="15" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Class" />
                    <textbox value="@bind(list.object_Class)" width="250px" tabindex="16" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Property" />
                    <textbox value="@bind(list.object_Property)" width="250px" rows="3" tabindex="17" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Name" />
                    <textbox value="@bind(list.object_Name)" width="250px" tabindex="18" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Keyword Name" />
                    <textbox value="@bind(list.keyword_Name)" width="250px" tabindex="19" />
                    <label class="error" value="@load(vmsgs['keyword_Name'])" />
                </row>
                <row>
                    <label value="Data_Method" />
                    <textbox value="@bind(list.data_Method)" width="250px" tabindex="20" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Add to Container" />
                    <hlayout spacing="10px">
                        <radiogroup id="container_add" selectedItem="@bind(list.add_to_Container)">
                            <radio label="No" value="0" />
                            <radio label="Yes" value="1" />
                        </radiogroup>
                    </hlayout>
                    <label class="error" value="@load(vmsgs['add_to_Container'])" />
                </row>

                <row>
                    <cell colspan="3" style="text-align:center">
                        <hlayout>
                            <button label="Submit" onClick="@command('add', wid=w_add_list) @global-command('refresh')" mold="trendy" tabindex="6" />
                            <button label="Cancel" onClick="w_add_list.detach()" mold="trendy" tabindex="7" />
                        </hlayout>
                    </cell>
                </row>
            </rows>
        </grid>
    </div>
</window>

I am trying to update the textbox [<textbox width="250px" id="tb_tname" ]="" on="" value="" change="" of="" submodule="" combobox.<="" p="">

zk mvvm rebind an input field

I am trying to populate a textbox value on change of a combobox in a mvvm form. Data updates in textbox correctly but validator class getting null value for the textbox field on click of save button. How to rebind the textbox value to vm?

Here is my form code...

<window id="w_add_list" title="Add New Object" position="center,top" border="normal" width="800px" closable="true">
<zscript>

    <style>   
        .error {color:#ff0000; font-size: 11px;}
    </style>

    <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.qk.or.ORListViewModel')"
        validationMessages="@id('vmsgs')" form="@id('list') @save(vm.newList, before='add') 
        @validator('com.qk.or.ListAddValidator')">
        <grid>
            <rows>
                <row>
                    <cell width="200px">
                        <label value="Module" />
                    </cell>
                    <cell width="280px">
                        <combobox width="250px" id="pn" autodrop="true" buttonVisible="false" model="@load(vm.modules)" value="@bind(list.module_Name)" selectedItem="@bind(list.module_Name)" tabindex="1">
                            <attribute name="onChange"><![CDATA[
                                String mod = self.getValue();

                                if (! mod.equals("")) {
                                    ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();
                                    List list2 = tcdao.getSubModulesByModule(mod);

                                    ListModelList lm2 = new ListModelList(list2);
                                    pt.setModel(lm2);
                                }
                            ]]></attribute>
                        </combobox>
                    </cell>
                    <label class="error" value="@load(vmsgs['module_Name'])" />
                </row>
                <row>
                    <label value="Sub Module" />
                    <combobox width="250px" id="pt" autodrop="true" buttonVisible="false" value="@bind(list.subModule_Name)" selectedItem="@bind(list.subModule_Name)" tabindex="2">
                        <attribute name="onChange"><![CDATA[
                            String mod = pn.getValue();
                            String smod = self.getValue();

                            if (! mod.equals("") && ! smod.equals("")) {
                                ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();

                                ObjectRepository or = new ObjectRepository();
                                or.setModule_Name(mod);
                                or.setSubModule_Name(smod);

                                String tname = tcdao.getTemplate(or);

                                if (tname != null && ! tname.equals("")) {
                                    tb_tname.setValue(tname);
                                    tb_tname.setReadonly(true);

                                } else {
                                    tb_tname.setReadonly(false);

                                }

                            }
                        ]]></attribute>
                    </combobox>
                    <label class="error" value="@load(vmsgs['subModule_Name'])" />
                </row>
                <row>
                    <label value="Template (Container Name)" />
                    <textbox width="250px" id="tb_tname" autodrop="true" buttonVisible="true" value="@bind(list.template_Name)" tabindex="3" />
                    <label class="error" value="@load(vmsgs['template_Name'])" />
                </row>
                <row>
                    <label value="UI Name" />
                    <textbox value="@bind(list.UI_Name)" width="250px" tabindex="4" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Navigation Path" />
                    <textbox value="@bind(list.navigation_Path)" width="250px" tabindex="5" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="OR Module" />
                    <textbox value="@bind(list.OR_Module)" width="250px" tabindex="6" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Name" width="100px" />
                    <textbox value="@bind(list.window_Name)" width="150px" tabindex="7" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Properties" />
                    <textbox value="@bind(list.window_Properties)" width="250px" rows="3" tabindex="8" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Name" />
                    <textbox value="@bind(list.page_Name)" width="250px" tabindex="9" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Properties" />
                    <textbox value="@bind(list.page_Properties)" width="250px" rows="3" tabindex="10" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Name" />
                    <textbox value="@bind(list.table_Name)" width="250px" tabindex="11" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Properties" />
                    <textbox value="@bind(list.table_Properties)" width="250px" rows="3" tabindex="12" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Dialog Box" />
                    <textbox value="@bind(list.dialogBox)" width="250px" tabindex="13" />
                    <label class="error" value="@load(vmsgs['dialogBox'])" />
                </row>
                <row>
                    <label value="Dialog Properties" />
                    <textbox value="@bind(list.dialog_Properties)" width="250px" rows="3" tabindex="14" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Screen Name" />
                    <textbox value="@bind(list.screen_Name)" width="250px" tabindex="15" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Class" />
                    <textbox value="@bind(list.object_Class)" width="250px" tabindex="16" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Property" />
                    <textbox value="@bind(list.object_Property)" width="250px" rows="3" tabindex="17" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Name" />
                    <textbox value="@bind(list.object_Name)" width="250px" tabindex="18" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Keyword Name" />
                    <textbox value="@bind(list.keyword_Name)" width="250px" tabindex="19" />
                    <label class="error" value="@load(vmsgs['keyword_Name'])" />
                </row>
                <row>
                    <label value="Data_Method" />
                    <textbox value="@bind(list.data_Method)" width="250px" tabindex="20" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Add to Container" />
                    <hlayout spacing="10px">
                        <radiogroup id="container_add" selectedItem="@bind(list.add_to_Container)">
                            <radio label="No" value="0" />
                            <radio label="Yes" value="1" />
                        </radiogroup>
                    </hlayout>
                    <label class="error" value="@load(vmsgs['add_to_Container'])" />
                </row>

                <row>
                    <cell colspan="3" style="text-align:center">
                        <hlayout>
                            <button label="Submit" onClick="@command('add', wid=w_add_list) @global-command('refresh')" mold="trendy" tabindex="6" />
                            <button label="Cancel" onClick="w_add_list.detach()" mold="trendy" tabindex="7" />
                        </hlayout>
                    </cell>
                </row>
            </rows>
        </grid>
    </div>
</window>

I am trying to update the textbox [<textbox width="250px" id="tb_tname" ]="" on="" value="" change="" of="" submodule="" combobox.<="" p=""> "tb_tname"] on value change of Submodule combobox.

zk mvvm rebind an input field

I am trying to populate a textbox value on change of a combobox in a mvvm form. Data updates in textbox correctly but validator class getting null value for the textbox field on click of save button. How to rebind the textbox value to vm?

Here is my form code...

<window id="w_add_list" title="Add New Object" position="center,top" border="normal" width="800px" closable="true">
<zscript>

    <style>   
        .error {color:#ff0000; font-size: 11px;}
    </style>

    <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.qk.or.ORListViewModel')"
        validationMessages="@id('vmsgs')" form="@id('list') @save(vm.newList, before='add') 
        @validator('com.qk.or.ListAddValidator')">
        <grid>
            <rows>
                <row>
                    <cell width="200px">
                        <label value="Module" />
                    </cell>
                    <cell width="280px">
                        <combobox width="250px" id="pn" autodrop="true" buttonVisible="false" model="@load(vm.modules)" value="@bind(list.module_Name)" selectedItem="@bind(list.module_Name)" tabindex="1">
                            <attribute name="onChange"><![CDATA[
                                String mod = self.getValue();

                                if (! mod.equals("")) {
                                    ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();
                                    List list2 = tcdao.getSubModulesByModule(mod);

                                    ListModelList lm2 = new ListModelList(list2);
                                    pt.setModel(lm2);
                                }
                            ]]></attribute>
                        </combobox>
                    </cell>
                    <label class="error" value="@load(vmsgs['module_Name'])" />
                </row>
                <row>
                    <label value="Sub Module" />
                    <combobox width="250px" id="pt" autodrop="true" buttonVisible="false" value="@bind(list.subModule_Name)" selectedItem="@bind(list.subModule_Name)" tabindex="2">
                        <attribute name="onChange"><![CDATA[
                            String mod = pn.getValue();
                            String smod = self.getValue();

                            if (! mod.equals("") && ! smod.equals("")) {
                                ObjectRepositoryDAO tcdao = new ObjectRepositoryDAO();

                                ObjectRepository or = new ObjectRepository();
                                or.setModule_Name(mod);
                                or.setSubModule_Name(smod);

                                String tname = tcdao.getTemplate(or);

                                if (tname != null && ! tname.equals("")) {
                                    tb_tname.setValue(tname);
                                    tb_tname.setReadonly(true);

                                } else {
                                    tb_tname.setReadonly(false);

                                }

                            }
                        ]]></attribute>
                    </combobox>
                    <label class="error" value="@load(vmsgs['subModule_Name'])" />
                </row>
                <row>
                    <label value="Template (Container Name)" />
                    <textbox width="250px" id="tb_tname" autodrop="true" buttonVisible="true" value="@bind(list.template_Name)" tabindex="3" />
                    <label class="error" value="@load(vmsgs['template_Name'])" />
                </row>
                <row>
                    <label value="UI Name" />
                    <textbox value="@bind(list.UI_Name)" width="250px" tabindex="4" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Navigation Path" />
                    <textbox value="@bind(list.navigation_Path)" width="250px" tabindex="5" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="OR Module" />
                    <textbox value="@bind(list.OR_Module)" width="250px" tabindex="6" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Name" width="100px" />
                    <textbox value="@bind(list.window_Name)" width="150px" tabindex="7" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Window Properties" />
                    <textbox value="@bind(list.window_Properties)" width="250px" rows="3" tabindex="8" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Name" />
                    <textbox value="@bind(list.page_Name)" width="250px" tabindex="9" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Page Properties" />
                    <textbox value="@bind(list.page_Properties)" width="250px" rows="3" tabindex="10" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Name" />
                    <textbox value="@bind(list.table_Name)" width="250px" tabindex="11" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Table Properties" />
                    <textbox value="@bind(list.table_Properties)" width="250px" rows="3" tabindex="12" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Dialog Box" />
                    <textbox value="@bind(list.dialogBox)" width="250px" tabindex="13" />
                    <label class="error" value="@load(vmsgs['dialogBox'])" />
                </row>
                <row>
                    <label value="Dialog Properties" />
                    <textbox value="@bind(list.dialog_Properties)" width="250px" rows="3" tabindex="14" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Screen Name" />
                    <textbox value="@bind(list.screen_Name)" width="250px" tabindex="15" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Class" />
                    <textbox value="@bind(list.object_Class)" width="250px" tabindex="16" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Property" />
                    <textbox value="@bind(list.object_Property)" width="250px" rows="3" tabindex="17" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Object Name" />
                    <textbox value="@bind(list.object_Name)" width="250px" tabindex="18" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Keyword Name" />
                    <textbox value="@bind(list.keyword_Name)" width="250px" tabindex="19" />
                    <label class="error" value="@load(vmsgs['keyword_Name'])" />
                </row>
                <row>
                    <label value="Data_Method" />
                    <textbox value="@bind(list.data_Method)" width="250px" tabindex="20" />
                    <label class="error" value="" />
                </row>
                <row>
                    <label value="Add to Container" />
                    <hlayout spacing="10px">
                        <radiogroup id="container_add" selectedItem="@bind(list.add_to_Container)">
                            <radio label="No" value="0" />
                            <radio label="Yes" value="1" />
                        </radiogroup>
                    </hlayout>
                    <label class="error" value="@load(vmsgs['add_to_Container'])" />
                </row>

                <row>
                    <cell colspan="3" style="text-align:center">
                        <hlayout>
                            <button label="Submit" onClick="@command('add', wid=w_add_list) @global-command('refresh')" mold="trendy" tabindex="6" />
                            <button label="Cancel" onClick="w_add_list.detach()" mold="trendy" tabindex="7" />
                        </hlayout>
                    </cell>
                </row>
            </rows>
        </grid>
    </div>
</window>

I am trying to update the textbox "tb_tname"] on value change of Submodule combobox.

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