Author |
Share Topic Topic Search Topic Options
|
katit
Senior Member
Joined: 09-Sep-2011
Posts: 146
|
Post Options
Quote Reply
Topic: Can Verifiers be Asynchronous? Posted: 10-Oct-2011 at 11:40am |
Denis, Yes, I figured it out. If it's not too hard - I would still like to see your example as well. I'm learning DevForce in's and out's so it would useful to see how you did it. Thanks!
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 10-Oct-2011 at 11:28am |
Hi katit;
Sorry for the delayed reply. I just got back from vacation.
Let me know if you still want to see my sample. I might have to search for it.
|
|
katit
Senior Member
Joined: 09-Sep-2011
Posts: 146
|
Post Options
Quote Reply
Posted: 28-Sep-2011 at 9:05pm |
Denis, Is there update sample with Async validation in DevForce? Sample code you posted already removed. Thanks!
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 11-Feb-2011 at 11:35am |
Hi as123;
It's fixed as of 6.0.8.
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 11-Feb-2011 at 11:09am |
Thanks. For some reason, I did not get the e-mail notification for the last one, and I just saw it. Do you know when will this feature be fixed?
Thanks.
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 12-Jan-2011 at 4:23pm |
as123;
I was finally able to find, what I think, is the root cause of the duplicate message.
When adding a free form VerifierResult, the TriggerLinks are not being handled properly and due to our implementation of INotifyDataErrorInfo.GetErrors(String.Empty), it causes the duplicate message. This combines with the fact that TriggerLinks is not serializable. So for now the quick fix for this is to add the TriggerLink manually inside the server call back method.
private void OnServerMethodCompleted(InvokeServerMethodOperation args) {
...........................
var vr = (VerifierResult)args.Result; vr.Verifier.AddTrigger(Customer.PropertyMetadata.CompanyName.Name);
if (vr.IsError) {
validationErrors.Add(vr);
......................... }
.......................... }
I will file a feature and/or defect request for this.
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 11-Jan-2011 at 5:37pm |
as123;
The error message duplication is indeed strange. I have verified that both INotifyDataErrorInfo error collection and the ValidationError collection only has 1 error count each. And when you remove the VerifierResult, it removes both message as well. This is the exact same thing that happens with Synchronous Validations. It looks like I need to dig deeper on this.
Regarding the user expected to come back to the field twice, this actually looks more of a UI issue in that if you focus on any other field, the error will go away. You don't have to come back to that same field twice to clear the errors.
As for your ValidationError removal question, I just used the Message property as an example. You can use any other property you like to search for the VerifierResult in question. For example, PropertyNames can be used as well.
var propertyName = Customer.PropertyMetadata.CompanyName.Name; var resultToRemove = validationErrors .Where(v => v.PropertyNames.Contains(propertyName)) .FirstOrDefault();
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 10-Jan-2011 at 12:40pm |
Thanks for the latest sample.
If I make a Company Name error by entering @ as part of the name, it shows the error correctly, but as mentioned earlier the error is duplicated if I tab back to the same field. After correcting the error, the user is expected to come back to the filed twice to clear all the existing errors. Do you still think it is the problem with DataGrid/INotifyDataErrorInfo? If so, do you know why we do not see such a behavior when doing Synchronous Validations?
Also, the ValidationError is removed by checking for '@' in the error message. It is possible that we might have such characters in other error messages or we may not have such a text to look for in our messages. Is there a better implementation for this? Is there a tag property or something like that for validation error which we can set when a specific error message is generated (may be, a unique Message ID) so that we can look for such immutable property and remove those errors.
For example, if we have validations to make sure that Name and ID must be unique (checked async), the messages might be just 'Must be Unique' or 'ID must be unique.' or 'Description must be unique.'. It might be difficult to remove such messages. Another alternative might be to regenerate the same message and look for its existence and remove it. However, this won’t work if we have generic messages like ‘Must be unique’ and the context is added dynamically as part of displaying error summary.
Thanks again for your help.
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 10-Jan-2011 at 11:49am |
Here's a sample app that should demonstrate at a basic level how to do async validation with DevForce.
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 30-Dec-2010 at 4:14pm |
Thanks for looking into it.
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 30-Dec-2010 at 4:09pm |
as123;
You're right, it shouldn't be this complicated to handle Async Verification. I need to do more research on how this works with DevForce and get back to you. I will find out about the timeframe as well.
Meanwhile, here's a link which you might find useful.
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 30-Dec-2010 at 1:21pm |
Regarding the removal of errors, I believe you meant ValidationErrors.Remove(), and NOT ValidationErrors.Clear() as I am only trying to clear a specific error.
You have mentioned about removing the entry from ValidationSummary manually, but how about the red box around the property in error (result of INotifyDataErrorInfo)? As part of the removing the validation error entry from the ValidationErrors collection, the error notification (red box) does not go away. Do I need to do anything else to fire that event so that the property is no longer in error after removing the entry from ValidationSummary?
It was mentioned earlier that IdeaBlade is looking into Async Verification. Is there a timeframe by which we can expect this?
If there is a better workaround to handle all these situations for Async Verification in SilverLight, please let me know.
Thanks
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 30-Dec-2010 at 12:25pm |
as123;
Yes, it looks like you need to add custom logic to avoid duplicate messages for this.
In regards to removing the errors, you will need to call ValidationErrors.Clear() as well as removing the errors from the ValidationSummary manually.
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 29-Dec-2010 at 10:34pm |
I tried this solution and it works with adding validation
results to the collection. However, if the same error occurs again for a
different value for the same property (after the initial error), the error is
added again to the validation summary control unlike the Verifier Engine behavior, which is only
one entry in the Validation Summary even if the same verifier error occurs for
the same property multiple times. Do we need to have custom logic to
avoid getting duplicate messages?
On a similar note, how do we remove the message after the Async
call succeeds? If I try to remove the validation error by calling
EntityAspect.ValidationErrors.Remove(), the message is removed from the
collection, but the property still shows as in error and the ValidationSummary
also shows the error. Do we need to do
anything else apart from removing the validation result from the
ValidationErrors collection? Thanks.
|
|
as123
Newbie
Joined: 27-Apr-2010
Posts: 30
|
Post Options
Quote Reply
Posted: 15-Dec-2010 at 5:47pm |
Thanks. I was looking into an earlier version of DF and this constructor was not there. It is available in 6.0.7.
|
|
DenisK
IdeaBlade
Joined: 25-Aug-2010
Posts: 715
|
Post Options
Quote Reply
Posted: 15-Dec-2010 at 5:05pm |
as123;
One of the constructors of a VerifierResult is
VerifierResult(VerifierResultCode code , string message, params string[]
propertyNames)
So by passing the propertyName, you can trigger, for example, a DataGrid's BindingValidationError event which you can customize to show the error red box.
I have attached an example below.
|
|