UI Validation [message #14186] |
Mon, 13 October 2008 18:57  |
Eclipse User |
|
|
|
Hi,
I've got a IValidator which can return more than one possible statuses.
How can I use a message from IStatus returned by this IValidator instead
of using a message which was set using a
IRidget.addValidationMessage(String) method?
Regards,
Robert
|
|
|
|
|
Re: UI Validation [message #15296 is a reply to message #14320] |
Thu, 16 October 2008 05:40  |
Eclipse User |
|
|
|
Elias Volanakis wrote:
> Hi Robert,
>
> the current API does not support this use case.
>
> Currently, the IValidator (i.e. validation rule) returns a message via
> the IStatus object. However this message is subsequently ignored. If a
> ValidationMessage exists for this rule, it is displayed -- but it
> provides only a fixed string.
>
> Personally, I would prefer to use the string from the IStatus directly.
>
> I'm not sure why an additional ValidationMessage is necessary. However
> I'm not very familiar with that API, so there might be a valid use case
> for the ValidationMessage.
>
>
Can you file a bug to track this feature request?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251060
>
>> How can I use a message from IStatus returned by this IValidator instead
>> of using a message which was set using a
>> IRidget.addValidationMessage(String) method?
>
> I will discuss this with my colleagues and see what we can do.
By the way, consider such scenario: we have a person object with a birth
date (just 20081010) and special ID from which the birth date can be
extracted (e.g. "fdsfdsf20081010sds"). The validator shall check if the
birth date from the special ID and the "normal" birth date are the same.
Currently there is no way to provide such functionality without passing
the person object to validator outside the validation API.
I had the same problem in my previous project and the solution was
providing an extension point for the validation process.
All you had to do was implementing an interface with a method:
IStatus validate(Object object, String property);
where an object in our case would be a person object and a property
would be "birthDate" or "specialID".
Another advantage of such approach is that UI forms are separated from
validation (and vice versa ;-) ) and you can add validator without
modification of existing code.
Regards,
Robert Kwolek
|
|
|
Re: UI Validation [message #576133 is a reply to message #14186] |
Mon, 13 October 2008 19:22  |
Eclipse User |
|
|
|
Robert Kwolek wrote:
> Hi,
>
>
> I've got a IValidator which can return more than one possible statuses.
>
> How can I use a message from IStatus returned by this IValidator instead
> of using a message which was set using a
> IRidget.addValidationMessage(String) method?
As I can see one of possibilities is to use one message per validator
and to use IEditableRidget.addValidationMessage(String, IValidator). Are
there any other alternatives?
Robert
|
|
|
Re: UI Validation [message #576299 is a reply to message #14203] |
Thu, 16 October 2008 02:03  |
Eclipse User |
|
|
|
Hi Robert,
the current API does not support this use case.
Currently, the IValidator (i.e. validation rule) returns a message via
the IStatus object. However this message is subsequently ignored. If a
ValidationMessage exists for this rule, it is displayed -- but it
provides only a fixed string.
Personally, I would prefer to use the string from the IStatus directly.
I'm not sure why an additional ValidationMessage is necessary. However
I'm not very familiar with that API, so there might be a valid use case
for the ValidationMessage.
Can you file a bug to track this feature request?
> How can I use a message from IStatus returned by this IValidator instead
> of using a message which was set using a
> IRidget.addValidationMessage(String) method?
I will discuss this with my colleagues and see what we can do.
Kind regards,
Elias.
---
Elias Volanakis
Innoopract, Inc.
http://www.innoopract.com
|
|
|
Re: UI Validation [message #576380 is a reply to message #14320] |
Thu, 16 October 2008 05:40  |
Eclipse User |
|
|
|
Elias Volanakis wrote:
> Hi Robert,
>
> the current API does not support this use case.
>
> Currently, the IValidator (i.e. validation rule) returns a message via
> the IStatus object. However this message is subsequently ignored. If a
> ValidationMessage exists for this rule, it is displayed -- but it
> provides only a fixed string.
>
> Personally, I would prefer to use the string from the IStatus directly.
>
> I'm not sure why an additional ValidationMessage is necessary. However
> I'm not very familiar with that API, so there might be a valid use case
> for the ValidationMessage.
>
>
Can you file a bug to track this feature request?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251060
>
>> How can I use a message from IStatus returned by this IValidator instead
>> of using a message which was set using a
>> IRidget.addValidationMessage(String) method?
>
> I will discuss this with my colleagues and see what we can do.
By the way, consider such scenario: we have a person object with a birth
date (just 20081010) and special ID from which the birth date can be
extracted (e.g. "fdsfdsf20081010sds"). The validator shall check if the
birth date from the special ID and the "normal" birth date are the same.
Currently there is no way to provide such functionality without passing
the person object to validator outside the validation API.
I had the same problem in my previous project and the solution was
providing an extension point for the validation process.
All you had to do was implementing an interface with a method:
IStatus validate(Object object, String property);
where an object in our case would be a person object and a property
would be "birthDate" or "specialID".
Another advantage of such approach is that UI forms are separated from
validation (and vice versa ;-) ) and you can add validator without
modification of existing code.
Regards,
Robert Kwolek
|
|
|
Powered by
FUDForum. Page generated in 1.07480 seconds