0

Auto fill problem with my binding-data (MVVM and MVC)

asked 2015-04-08 04:37:23 +0800

kenjiamo gravatar image kenjiamo
1 1

updated 2015-04-20 22:36:01 +0800

Hello everybody,

I have a kind of bug with zk 7 with auto fill of chrome :(

Auto fill fills the fields in my web page (textbox) but the fields of my view-model or my controller stay empty with chrome.

For example, with an address form autofilled all data is null in my viewmodel (not in my textbox on the webpage)

If I simulate an event 'onChange' my binding works.

(zAu.send(new zk.Event(zk.Widget.$('$idOfMyTextBox'),"onChange",{'value':'test!!','start':6})) )

The problem is the same in a new zk project with one mvvm page.

Does anyone have a solution ?

Thanks for you help :)

Here an example :

<zk >

<window apply="org.zkoss.bind.BindComposer" viewmodel="@id('vm') @init('com.enriquepigeon.TestZk.MyViewModel')">

<label value="Name" />
<textbox value="@bind(vm.nom)" />
<h:br />

<label value="First name" />
<textbox value="@bind(vm.prenom)" />
<h:br />

<label value="Address" />
<textbox value="@bind(vm.adresse)" />
<h:br />

<label value="Postal code" />
<textbox value="@bind(vm.codePostal)" />
<h:br />

<label value="City" />
<textbox value="@bind(vm.ville)" />
<h:br />

<button label="launch" onClick="@command('launch')" />

</window>

</zk>

VM :

public class MyViewModel {

private String nom; private String prenom; private String ville; private String adresse; private String codePostal;

public String getNom() { return nom; }

public void setNom(String nom) { this.nom = nom; }

public String getPrenom() { return prenom; }

public void setPrenom(String prenom) { this.prenom = prenom; }

public String getVille() { return ville; }

public void setVille(String ville) { this.ville = ville; }

public String getAdresse() { return adresse; }

public void setAdresse(String adresse) { this.adresse = adresse; }

public String getCodePostal() { return codePostal; }

public void setCodePostal(String codePostal) { this.codePostal = codePostal; }

@Command public void launch(){ System.out.println("Name : "+nom); System.out.println("First name : "+prenom); System.out.println("Address : "+adresse); System.out.println("Postal code : "+codePostal); System.out.println("City : "+ville); }

}

Result :

And the result is :

Name : MyName First name : null Address : null Postal code : null City : null

delete flag offensive retag edit

Comments

can you create a fiddle where we can test?

chillworld ( 2015-04-08 09:49:42 +0800 )edit

Sorry for the delay, (lot's of work, never end :D)

I will try to do a fiddle, but for waiting i update my question with an example.

kenjiamo ( 2015-04-20 22:31:47 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-17 10:42:33 +0800

lamboc gravatar image lamboc
1

maybe you can try to add Notifychange in your method

 @Command 
 @NotifyChange({"nom","prenom","adresse","codePostal","ville"})
     public void launch(){ 
         System.out.println("Name : "+nom); System.out.println("First name : "+prenom); 
         System.out.println("Address : "+adresse); System.out.println("Postal code : 
                "+codePostal); System.out.println("City : "+ville);
       }

Goodluck

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-04-08 04:37:23 +0800

Seen: 51 times

Last updated: Jun 17 '15

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