PDA

View Full Version : Bind in a deferred command



sdc
24 Feb 2009, 8:01 AM
Hi,

Do anybody know why Bindings.bind now uses a deferred command (since 1.2.3) ? I would like to override the Bindings class and not use a deferred command, because I have issues with it, but I would like to know what kind of issues I can encounter this way ?

Thanks in advance.

Cheers

sven
24 Feb 2009, 8:12 AM
I know why ;)

If you have for example a grid and on row select you bind the model to a form, than if you edit the field and dont blur it but select the next row the value got lost. The fieldblur happens too late. Now the field blurs, the value gets updated and the next model is bound.

sven
24 Feb 2009, 8:17 AM
Another fix for that would be to update the model one last time in unbind. Than we could bind directly without the DeferredCommand. What do you think about that?

EDIT: but that will cause some other issues.

So what about adding a bind event that is fired after binding has finished? Than you could show your dialog in the listener for that event. Also your testcases can be in that listeners.

sdc
24 Feb 2009, 9:07 AM
Mmm... At first glance, I was not expecting unbind to update the model but :
- a bound model is supposed to be always sync'd with the field values, so I don't think it would cause other issues to update the model from field in the unbind.
- as field is updated on bind, it would be coherent to update the model on unbind
In fact, I think it is a good idea, Sven ! :)

EDIT : Oops, I've read your edit. I didn't find issues, but I guess you have good reasons to tell that. Anyway, a bind event will definitely not cause other issues. It would also improve my test cases (no need anymore to enable async mode and use deferred commands). I think I could also neatly fix my validation issues.

EDIT2 : I found an issue on your first suggestion : if you call bind(ModelData) and that the parameter IS the already bound model, the model would be reset from form field values before the fields are updated. But this can be easily fixed : unbind the model if and only if model != null and if !model.equals(this.model).
Anyway, I guess you have found other issues. If so, your second suggestion (fire a Bind event) will be enough for me.

Thanks for the solutions :) !!! Please tell me which one you choose.

sven
24 Feb 2009, 10:01 AM
Adding a bind event ;)

Than you can show your dialog in that event and everything works as before.

sdc
24 Feb 2009, 10:08 AM
Ok. Thank you, Sven :). Please tell me when it is in SVN.

sdc
25 Feb 2009, 2:08 AM
Actually, I think my test cases will still have to be in async mode so that the bind can be done (in a deferred command), no ?
Are you sure that your first suggestion would cause other issues ? B)

sven
25 Feb 2009, 2:58 AM
Yes it does. I had this befor and there were side effect.

In the explorer for example we bind a date to a datefield. The date has timeinfos and the datefield removed this infos. So you get red markers on unbind as the model gets updated with the new value from the field. We worked arround this in the example. But that would a too big change for you.