-
Bug
-
Resolution: Fixed
-
Normal
-
6.0.0, Freshly
-
None
Problem Description:
Converter cannot get parameters by ctx.getConverterArg("key1") when using with form binding.
Steps to Reproduce
- use the following code.
- click the button, you will see the console display the following message:
to bean, Key1:null
to bean, Key2:null
<zk> <vbox apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.zkoss.zktest.bind.viewmodel.form.Form')" width="400px"> <div form="@id('fx') @load(vm.order) @save(vm.order, before='compute')"> <textbox value="@bind(fx.name) @converter(vm.myConverter, key1=fx.name, key2='value2')" /> <button id="computeButton" label="Compute" onClick="@command('compute')" /> </div> </vbox> </zk>
package org.zkoss.zktest.bind.viewmodel.form; import org.zkoss.bind.BindContext; import org.zkoss.bind.Converter; import org.zkoss.bind.annotation.Command; import org.zkoss.zk.ui.Component; public class Form{ public class Order{ private String name = "default name"; public String getName() { return name; } public void setName(String name) { this.name = name; } } private Order order = new Order(); public Order getOrder() { return order; } public Converter getMyConverter(){ return new Converter() { public Object coerceToUi(Object val, Component component, BindContext ctx) { String value1 = (String)ctx.getConverterArg("key1"); String value2 = (String)ctx.getConverterArg("key2"); System.out.println("to UI, myKey:"+value1); System.out.println("to UI, Key2:"+value2); return val; } public Object coerceToBean(Object val, Component component, BindContext ctx) { String value1 = (String)ctx.getConverterArg("key1"); String value2 = (String)ctx.getConverterArg("key2"); System.out.println("to bean, myKey:"+value1); System.out.println("to bean, Key2:"+value2); return val; } }; } // -----------command ----------------- @Command public void compute(){ } }