Revision history [back]

click to hide/show revision 1
initial version

asked 2015-05-24 05:19:22 +0800

ghostomg gravatar image ghostomg flag of Indonesia

Binder Converter Arguments Pass View Model Property

Hi, I'm using ZK 7.0.2, I'm just wondering If I could pass view model property to programmatically binder's converter arguments. let say I have this property in my View Model class :

private List<Person> personList;
// ... personList setter & getter

When I pass this personList to my custom converter argument by ZUL page, like below snipset, it just work fine (both of coerceToUi & coerceToBean method work fine).

<textbox value="@bind(fx.person) @converter('personConverter', list=vm.personList)" />

But when I used it by programmatically binder (the equivalent purpose). it just pass plain String object rather than invoked view model object.

String[] beforeCmds = {"saveAction"};
HashMap<String,Object> converterArgs = new HashMap<>();
converterArgs.put("list", "vm.personList");

Textbox txtPerson = new Textbox();
binder.addPropertyLoadBindings(txtPerson, "value", "fx.person", 
    null, null, null, "'personConverter'", converterArgs);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    null, null, null, "'personConverter'", converterArgs, null, null);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    beforeCmds, null, null, "'personConverter'", converterArgs, null, null);

In personConverter class, it received pass args by :

List<Person> list = (Person) bc.getConverterArg("list");

Error appears because can't cast string object "vm.personList" to List<person>. Or indeed it can not be pass view model property by programmatically binder? Please kindly help me. Thank you.

Binder Converter Arguments Pass View Model Property

Hi, I'm using ZK 7.0.2, I'm just wondering If I could pass view model property to programmatically binder's converter arguments. let say I have this property in my View Model class :

private List<Person> personList;
// ... personList setter & getter

When I pass this personList to my custom converter argument by ZUL page, like below snipset, it just work fine (both of coerceToUi & coerceToBean method work fine).

<textbox value="@bind(fx.person) @converter('personConverter', list=vm.personList)" />

But when I used it by programmatically binder (the equivalent purpose). it just pass plain String object rather than invoked view model object.

String[] beforeCmds = {"saveAction"};
HashMap<String,Object> converterArgs = new HashMap<>();
converterArgs.put("list", "vm.personList");

Textbox txtPerson = new Textbox();
binder.addPropertyLoadBindings(txtPerson, "value", "fx.person", 
    null, null, null, "'personConverter'", converterArgs);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    null, null, null, "'personConverter'", converterArgs, null, null);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    beforeCmds, null, null, "'personConverter'", converterArgs, null, null);

In personConverter class, it received pass args by :

List<Person> list = (Person) (List<Person>) bc.getConverterArg("list");

Error appears because can't cast string object "vm.personList" to List<person>. Or indeed it can not be pass view model property by programmatically binder? Please kindly help me. Thank you.

Binder Converter Arguments Pass View Model Property

Hi, I'm using ZK 7.0.2, I'm just wondering If I could pass view model property to programmatically binder's converter arguments. let say I have this property in my View Model class :

private List<Person> personList;
// ... personList setter & getter

When I pass this personList to my custom converter argument by ZUL page, like below snipset, it just work fine (both of coerceToUi & coerceToBean method work fine).

<textbox value="@bind(fx.person) @converter('personConverter', list=vm.personList)" />

But when I used it by programmatically binder (the equivalent purpose). it reach the custom converter class, but just pass plain String object rather than invoked view model object.

String[] beforeCmds = {"saveAction"};
HashMap<String,Object> converterArgs = new HashMap<>();
converterArgs.put("list", "vm.personList");

Textbox txtPerson = new Textbox();
binder.addPropertyLoadBindings(txtPerson, "value", "fx.person", 
    null, null, null, "'personConverter'", converterArgs);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    null, null, null, "'personConverter'", converterArgs, null, null);
binder.addPropertySaveBindings(txtPerson, "value", "fx.person",
    beforeCmds, null, null, "'personConverter'", converterArgs, null, null);

In personConverter class, it received pass args by :

List<Person> list = (List<Person>) bc.getConverterArg("list");

Error appears because can't cast string object "vm.personList" to List<person>. Or indeed it can not be pass view model property by programmatically binder? Please kindly help me. Thank you.

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