Saturday, January 20, 2007

Data Binding Validation Story

In preparation for the 1.0 release the validation story has changed. Previously for a target observable value change the pipeline was:

  1. BindingEvent.PIPELINE_AFTER_GET - retrieve target value

  2. BindingEvent.PIPELINE_AFTER_VALIDATE - validate target value

  3. BindingEvent.PIPELINE_AFTER_CONVERT - convert target value to model type

  4. BindingEvent.PIPELINE_AFTER_BUSINESS_VALIDATE - validate converted value

  5. BindingEvent.PIPELINE_AFTER_CHANGE - set converted value on model



Validation occurred during PIPELINE_AFTER_VALIDATE and PIPELINE_AFTER_BUSINESS_VALIDATE.

The pipeline for value bindings has become:

  1. BindingEvent.PIPELINE_AFTER_GET - retrieve target value

  2. BindingEvent.PIPELINE_AFTER_CONVERT - convert target value

  3. BindingEvent.PIPELINE_BEFORE_CHANGE - a placeholder for expensive validation

  4. BindingEvent.PIPELINE_AFTER_CHANGE - set on model



Validators can now be registered for any position, multiples can be registered for a single position, and validation can occur on model to target changes as well as target to model.

Policies


Policies are the way to define when the model is to be updated. The currently supported policies are BindSpec.POLICY_AUTOMATIC and BindSpec.POLICY_EXPLICIT. A common need in dialogs is the ability to defer updating of a model until the user selects OK/Apply. Previously in order to accomplish this you had to create a temporary model to bind to the UI so that it wouldn't update the live model. Now you can specify BindSpec.POLICY_EXPLICIT for the update policy via the BindSpec and control when the model is updated. You can also specify the target validation policy so that the target is validated on change but the model is not updated until you invoke an explicit update.

There aren't any snippets of the functionality yet but hopefully I'll be able to create one soon. I just wanted to give a heads up for anyone using HEAD as there are some nonpassive changes in this.

No comments: