Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » JFace Databinding. Are all fields valid ?
JFace Databinding. Are all fields valid ? [message #633410] Sun, 17 October 2010 15:34 Go to next message
Sebastian  is currently offline 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 Smile
Re: JFace Databinding. Are all fields valid ? [message #633412 is a reply to message #633410] Sun, 17 October 2010 15:42 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5318
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 #633415 is a reply to message #633410] Sun, 17 October 2010 16:04 Go to previous messageGo to next message
Sebastian  is currently offline Sebastian
Messages: 22
Registered: September 2010
Junior Member
I checked the API, but I can't get my head around it ... Some help will be appreciated Smile
Re: JFace Databinding. Are all fields valid ? [message #633420 is a reply to message #633410] Sun, 17 October 2010 17:42 Go to previous messageGo to next message
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 :)
Re: JFace Databinding. Are all fields valid ? [message #633429 is a reply to message #633410] Sun, 17 October 2010 18:58 Go to previous message
Sebastian  is currently offline Sebastian
Messages: 22
Registered: September 2010
Junior Member
Yep, that's what I was looking for.. Smile
Previous Topic:Splashscreen failing to show up
Next Topic:org.eclipse.core.expressions.definitions problem
Goto Forum:
  


Current Time: Tue Sep 16 13:41:08 GMT 2014

Powered by FUDForum. Page generated in 0.25606 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software