[Databinding] Is this a good Master-Details-Binding pattern for my use case? [message #830409] |
Tue, 27 March 2012 15:33 |
Mark Hoffmann Messages: 113 Registered: July 2009 Location: Jena |
Senior Member |
|
|
Hello,
this is not a question to solve a problem. Everything works fine. This is a question of a good design for a certain demand.
Imagine the following use-case. At night my server application imports a lot of data. These data will be valiated during the import. Invalid data are specially marked. At the next day a user opens his editor to correct these invalid data. The editor looks like this.
The list of invalid data are presented in a table. The user selects the entry and the details part present the several properties/fields of the data. The invalid fields should be marked using control decoration. I realized this using forms. I did the master details binding, like this:
IObservableValue masterSelectionOV = ViewerProperties.singleSelection().observe(invalidDataViewer);
IObservableValue nameTextOV = WidgetProperties.text(SWT.Modify).observe(nameText);
IObservableValue nameModelDetailOV = EMFProperties.value(...).observeDetail(masterSelectionOV);
UpdateValueStrategy t2mUVS = new UpdateValueStrategy().setAfterGetValidator(myValidator);
dbc.bindValue(nameTextOV, nameModelDetailOV, t2mUVS, null);
// after all bindings
masterSelectionOV.addValueChangeListener(new IValueChangeListener() {
public void handleValueChange(ChangeEvent event) {
dbc.updateModels();
}
});
I cannot use the automatic model to target validation, because on errors the target will not be filled with the wrong value. So I need a further validate target to model to get the validation error. Especially with the master details binding this is a problem, because the widget/target can contain values from the selection before if you use model to target validation with an validation error.
The use case is, the model contains invalid values that have to be updated to the target, but the validation error should also be propagated to the databinding context and the message manager. It should be like the process when DataBindingContext#bindValue() is called. What I need is the wrong model value in my widget/target and the validation error for my control decoration.
My question is, is this solution a proper way or not. Does anybody know a better way to solve this demand?
Thanks.
Mark
[Updated on: Tue, 27 March 2012 17:34] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03198 seconds