3 Replies Latest reply on Dec 12, 2013 11:38 AM by Max Barkley

    Errai @ModelSetter Unsettles Data-Binding ?

    Charles Odili Apprentice

      I have a situation where using a @ModelSetter method in a @Templae @Page kinda turns off the binding between the @Model object and @Bound @Datafield widgets.

      Details here :

      @Inject @Model private PutmeApplication putmeApply;
        ....
      
      
        // observe a CDI event. Gets fired from the server.
        private void onJambRegValidation(@Observes PutmeApplication evt) {
             LogUtil.log("recieved CDI event");
             if (evt != null) {
                  LogUtil.log("record exists ...");
                  //importIntoModel(evt);
                  setModel(evt); // call method annotated with @ModelSetter
             }
        }
      
      
        @ModelSetter
        private void setModel(PutmeApplication model) {
             // this kinda "turn-off" the binding on putmeApply ?
             // Data in model parameter, which gets assigned to putmeApply do not show up in the UI
             // and data entered into bound UI data-fields to do show up in putmeApply fields
             this.putmeApply = model;
        }
      
      
        // bcos @ModelSetter private void setModel(PutmeApplication model) is "failing",
        // I had to do this for now ?
        private void importIntoModel(PutmeApplication src) {
             putmeApply.setFirstname(src.getFirstname());
             putmeApply.setLastname(src.getLastname());
             putmeApply.setDob(src.getDob());
             putmeApply.setGender(src.getGender());
             putmeApply.setJambScore(src.getJambScore());
             putmeApply.setFirstChoice(src.getFirstChoice());
             putmeApply.setJambreg(src.getJambreg());
        }