Zk get value of child component mvvm -


include component value showing null not binding.

<window id="win" width="100%" border="normal" height="100%"     apply="org.zkoss.bind.bindcomposer" validationmessages="@id('vmsgs')"     viewmodel="@id('vm') @init('com.customer.portal.controller.motorquotationviewmodel')">  <row>      <include src="basicinfo.zul"></include> </row> <row>      <button id="btncalculatepremium"                         onclick="@command('calculatepremium')" /> </row> 

basicinfo.zul

<window id="win" width="100%" border="normal" height="100%"         apply="org.zkoss.bind.bindcomposer" validationmessages="@id('vmsgs')"         viewmodel="@id('vm') @init('com.customer.portal.controller.basecontroller')">         <grid>             <rows>                 <row>                     <label id="lblbasicinfo"></label>                 </row>                 <row id="rowidtype">                     <label id="lblidtype"></label>                     <textbox id="txtidtype" inplace="true"                         value="@bind(vm.riskwebvo.vname)" constraint="no empty" />                 </row> </rows> </grid> </window> 

main view model

public class motorquotationviewmodel extends basecontroller {      public void calculatepremium() { logger.info(riskwebvo.getvname());//showing null  } public uwmtriskwebvo getriskwebvo() {         return riskwebvo;     }      public void setriskwebvo(uwmtriskwebvo riskwebvo) {         this.riskwebvo = riskwebvo;     }  } 

child view model

    public class basecontroller extends selectorcomposer<component>{          protected uwmtriskwebvo riskwebvo = new uwmtriskwebvo();     public uwmtriskwebvo getriskwebvo() {             return riskwebvo;         }          public void setriskwebvo(uwmtriskwebvo riskwebvo) {             this.riskwebvo = riskwebvo;         }      } 

when i'm getting value of main view model it's binding values when i'm trying values of include components showing null.

possible problem :

cause speak of null , not nullpointerexception assume when create new did, name not set.

protected uwmtriskwebvo riskwebvo = new uwmtriskwebvo(); 

second tuning :

do work mvvm or mvc, make choice. shouldn't can't extends selectorcomposer<component> , appplying bindcoomposer in zul.

tweaking :

while motorquotationviewmodel extends basecontroller don't have set basecontroller in basicinfo.zul cause everyting inside include listen vm.

duplicated names :

with section tweaking read, understand called vm's twice vm. how sure witch vm take?
take attention names set in includes.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -