1

Form Bind - Default values in dependent fields

asked 2015-09-24 16:53:16 +0800

eclipse1 gravatar image eclipse1
21 4

updated 2015-09-24 16:54:43 +0800

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 :)

delete flag offensive retag edit

Comments

thanlk Chill for you answer!

eclipse1 ( 2015-09-25 08:29:03 +0800 )edit

your welcome

chillworld ( 2015-09-25 09:44:13 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-09-25 05:55:54 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2015-09-25 06:28:58 +0800

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.

link publish delete flag offensive edit

Comments

just a side note: bear in mind that the form binding mechanism will fundamentally change in ZK 8 so in case you are planning to upgrade soon, don't put too much effort into a custom FormImpl extension

cor3000 ( 2015-09-25 06:16:24 +0800 )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
2 followers

RSS

Stats

Asked: 2015-09-24 16:53:16 +0800

Seen: 27 times

Last updated: Sep 25 '15

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