Search code examples
comboboxzkzul

zk: form combobox is not empty on an event to add new object


I am using zk frameworks mvvm approach to add, edit an object. When I click add button first time, the opening form is empty and it runs smoothly. After editing a record from a list, i am getting combo-box values preselected and the already selected value must not be selected, otherwise, i get null and i can't submit the form. It's mean that I can't choose selected value again for successful crud operation. My edit function for every case are working fine and there is no issue and all textbox and intbox are working normally

i am following this article http://books.zkoss.org/wiki/Small_Talks/2012/February/MVVM_in_ZK6:_Form_Binding

i have three objects, newObject, selectedObject and editObject

my form snippet from zul file

    <grid sizedByContent="true"
                                        form="@id('ds') 
                                              @load(vmc.newObject, after='addInvoke') @save(vmc.newObject, before='add') 
                                              @load(vmc.editObject, after='editInvoke') @save(vmc.editObject, before='edit')
                                              @validator('com.example.MyValidator')"
                                               >


<combobox model="@load(ds.unitList)" 
                                                    selectedItem="@bind(ds.abc.unit)" readonly="true" maxlength="50"/>

my method snippet for edit and add functions from SampleViewModel is as follows

    @Command("edit")
    @NotifyChange({ "objectList", "selectedObject", "editObject" })
    @Override
    public void edit() {
        service.editKpi(editObject);
        editObject = null;
    }

@Command("addInvoke")
@NotifyChange("newObject")
@Override
public void onClickAddButton(){

    enableEditMode(false);
    isNewMode = true;

    newObject = new AbcDTO();



}

Solution

  • i have fixed it my self.

    solution is use value in combo-box too along with selecteditem