Follow up for ZK 8 : http://forum.zkoss.org/question/99805/form-binding-default-values-in-dependent-fields-zk8/
chillworld ( 2016-03-18 08:09:31 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi!
I needed to implement a mechanism to put defaults in dependent fields.
Based on observers we created the following ZKFiddle example:
zkfiddle.org/sample/3el48on/12-Observable-Form
The mechanism described in the example works but did not expect to be required to notify the changes made to the form since the objects are bound in zul.
Why the next code it's necessary?
@Command public void notifyChanges(){ BindUtils.postNotifyChange(null,null,this.observableForm,"value"); }
Thank you all :)
I did check your code,
You actually don't need the Command
because you can handle it already in the TestObserver
.
public class TestObserver implements TestObserverForm{
@Override
public void update(final TestObservableForm observable, final String field) {
observable.setField("value", String.format("Data setted when %s changed!", field));
BindUtils.postNotifyChange(null,null,observable,"value");
}
}
Small explication :
The setField will trigger the change of that specific field.
You update another field in the back but the binder has no clue that you did this.
So the only thing what you can do is notify the binder that something extra has changed.
Your idea was good, to notify the binder.
Just you make it yourself a little harder then it should have been.
Chill.
Follow up for ZK 8 : http://forum.zkoss.org/question/99805/form-binding-default-values-in-dependent-fields-zk8/
chillworld ( 2016-03-18 08:09:31 +0800 )editAsked: 2015-09-24 16:53:16 +0800
Seen: 27 times
Last updated: Sep 25 '15
thanlk Chill for you answer!
eclipse1 ( 2015-09-25 08:29:03 +0800 )edityour welcome
chillworld ( 2015-09-25 09:44:13 +0800 )edit