JFace Databinding. Are all fields valid ? [message #633410] |
Sun, 17 October 2010 15:34 |
Sebastian Messages: 22 Registered: September 2010 |
Junior Member |
|
|
Hey guys,
I am looking for a decent solution for the following scenario.
I have a CustomerEditor which lets you add a customer to the system. I use JFace Databinding to keep model and ui synced.
Most of the properties on the customer object are Domain values and not sole Strings or ints, so I use converters to get the transition done.
One top of that, I follow the Design By Contract approach which means that all the properties have preconditions before their DomainValue can be created. I use validators to get this done.
Now the problem: The validation, converting works just fine. But, the thing is when I enter invalid data, the model won't get updated (which is cool since it remains in a consistent state this way.
When the user hit's the save button, I have to check that all fields in the form have valid content, otherwise I'd return an error message. So, how do I check whether or not all text fields in my form have valid contents ? Is there an implementation available already or would I have to come up with my own stuff?
Thanks
|
|
|
Re: JFace Databinding. Are all fields valid ? [message #633412 is a reply to message #633410] |
Sun, 17 October 2010 15:42 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You can query this using DatabindingContext#getValidationStatusProviders()
Tom
Am 17.10.10 17:34, schrieb Sebastian:
> Hey guys,
>
> I am looking for a decent solution for the following scenario.
>
> I have a CustomerEditor which lets you add a customer to the system. I
> use JFace Databinding to keep model and ui synced.
> Most of the properties on the customer object are Domain values and not
> sole Strings or ints, so I use converters to get the transition done.
>
> One top of that, I follow the Design By Contract approach which means
> that all the properties have preconditions before their DomainValue can
> be created. I use validators to get this done.
>
> Now the problem: The validation, converting works just fine. But, the
> thing is when I enter invalid data, the model won't get updated (which
> is cool since it remains in a consistent state this way.
>
> When the user hit's the save button, I have to check that all fields in
> the form have valid content, otherwise I'd return an error message. So,
> how do I check whether or not all text fields in my form have valid
> contents ? Is there an implementation available already or would I have
> to come up with my own stuff?
>
> Thanks :)
|
|
|
|
Re: JFace Databinding. Are all fields valid ? [message #633420 is a reply to message #633410] |
Sun, 17 October 2010 17:42 |
Eclipse User |
|
|
|
Originally posted by: karsten.triadiary.com
Hi,
hope that I understood your question :-)
During binding the values I also create an AggregateValidationStatus.
avStatus = new AggregateValidationStatus(bindingContext.getBindings(),
AggregateValidationStatus.MAX_SEVERITY);
On save I do:
bindingContext.updateModels();
final IStatus iStatus = (IStatus) avStatus.getValue();
if (!ValidationStatus.OK_STATUS.equals(iStatus)) {
// something could not be validated
} else {
// perform save
}
Could that help?
Karsten
Am 17.10.2010 17:34, schrieb Sebastian:
> Hey guys,
>
> I am looking for a decent solution for the following scenario.
>
> I have a CustomerEditor which lets you add a customer to the system. I
> use JFace Databinding to keep model and ui synced.
> Most of the properties on the customer object are Domain values and not
> sole Strings or ints, so I use converters to get the transition done.
>
> One top of that, I follow the Design By Contract approach which means
> that all the properties have preconditions before their DomainValue can
> be created. I use validators to get this done.
>
> Now the problem: The validation, converting works just fine. But, the
> thing is when I enter invalid data, the model won't get updated (which
> is cool since it remains in a consistent state this way.
>
> When the user hit's the save button, I have to check that all fields in
> the form have valid content, otherwise I'd return an error message. So,
> how do I check whether or not all text fields in my form have valid
> contents ? Is there an implementation available already or would I have
> to come up with my own stuff?
>
> Thanks :)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03312 seconds