Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to provide own ValidationStatus without to bind a model-property to something?
How to provide own ValidationStatus without to bind a model-property to something? [message #20075] Fri, 10 July 2009 22:50 Go to next message
Eclipse UserFriend
Originally posted by: TheRealHawk.Freenet.de

Hi,

what I want to do is something like this:
final DataBindingContext _dbx = new DataBindingContext();
_dbx.bindValue(
null,
BeansObservables.observeValue(mybean, "myProperty"),
null,
new UpdateValueStrategy().setBeforeSetValidator(new MyValidator()));

For this behavior I created a NullObservableValue which does nothing.

Is there a better eclipse-way to do this?
I simply want to observe a bean and validate its complete state (e.g. all
start-date has to be before end-dates, currency values should be greater
than 0 and so on).
--> For this I want to add my own ValidationStatusProvider to the
DataBindingContext.

Markus
Re: How to provide own ValidationStatus without to bind a model-property to something? [message #20536 is a reply to message #20075] Mon, 13 July 2009 16:07 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Markus,

MultiValidator (despite the name being mismatched to what you're trying
to do) will help you here.

final IObservableValue myBeanObservable =
BeansObservables.observeValue(myBean, "myProperty");
MultiValidator myValidator = new MultiValidator() {
protected IStatus validate() {
SomeType propValue = myBeanObservable.getValue();
// Do validation on propValue and return an appropriate status
}
};
dbc.addValidationStatusProvider(myValidator);

Hope this helps,

Matthew

Markus Koch wrote:
> Hi,
>
> what I want to do is something like this:
> final DataBindingContext _dbx = new DataBindingContext();
> _dbx.bindValue(
> null,
> BeansObservables.observeValue(mybean, "myProperty"),
> null,
> new UpdateValueStrategy().setBeforeSetValidator(new MyValidator()));
>
> For this behavior I created a NullObservableValue which does nothing.
>
> Is there a better eclipse-way to do this?
> I simply want to observe a bean and validate its complete state (e.g. all
> start-date has to be before end-dates, currency values should be greater
> than 0 and so on).
> --> For this I want to add my own ValidationStatusProvider to the
> DataBindingContext.
>
> Markus
>
>
Re: How to provide own ValidationStatus without to bind a model-property to something? [message #20581 is a reply to message #20536] Mon, 13 July 2009 20:37 Go to previous message
Eclipse UserFriend
Originally posted by: TheRealHawk.Freenet.de

This works.

Thanks

Markus

"Matthew Hall" <matthall@woodcraftmill.com> schrieb im Newsbeitrag
news:h3fm3d$c27$2@build.eclipse.org...
> Markus,
>
> MultiValidator (despite the name being mismatched to what you're trying to
> do) will help you here.
>
> final IObservableValue myBeanObservable =
> BeansObservables.observeValue(myBean, "myProperty");
> MultiValidator myValidator = new MultiValidator() {
> protected IStatus validate() {
> SomeType propValue = myBeanObservable.getValue();
> // Do validation on propValue and return an appropriate status
> }
> };
> dbc.addValidationStatusProvider(myValidator);
>
> Hope this helps,
>
> Matthew
>
> Markus Koch wrote:
>> Hi,
>>
>> what I want to do is something like this:
>> final DataBindingContext _dbx = new DataBindingContext();
>> _dbx.bindValue(
>> null,
>> BeansObservables.observeValue(mybean, "myProperty"),
>> null,
>> new UpdateValueStrategy().setBeforeSetValidator(new MyValidator()));
>>
>> For this behavior I created a NullObservableValue which does nothing.
>>
>> Is there a better eclipse-way to do this?
>> I simply want to observe a bean and validate its complete state (e.g. all
>> start-date has to be before end-dates, currency values should be greater
>> than 0 and so on).
>> --> For this I want to add my own ValidationStatusProvider to the
>> DataBindingContext.
>>
>> Markus
Previous Topic:Default menu item from a menu manager
Next Topic:[databinding] Binding same TableViewer with 2nd input
Goto Forum:
  


Current Time: Thu Dec 26 12:39:51 GMT 2024

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

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

Back to the top