How to provide own ValidationStatus without to bind a model-property to something? [message #20075] |
Fri, 10 July 2009 22:50 |
Eclipse User |
|
|
|
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 |
Matthew Hall 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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03878 seconds