Search code examples
mvvmsavezk

ZK MVVM binder save with EL-Expression


How to do this with zk MVVM

i want to save a bean but with condition if the type is personal than save into personal, else into company

<textbox value="@save(vm.personal ? vm.masterCifPersonal.cifId : vm.masterCifCompany.cifId)" width="100px" maxlength="10"/>

but when binder save into bean, this exception appear

Illegal Syntax for Set Operation


Solution

  • My tip is to modify your code and use a temporary var:

    <textbox value="@save(vm.temp)" width="100px" maxlength="10"/>
    

    and modify your setter as

    void setTemp(Long temp) {
        if(personal) {
            masterCifPersonal.cifId = temp;
        } else {
            masterCifCompany.cifId = temp;
        }
    }