Alex Occhipinti
Top achievements
Rank 1
Alex Occhipinti
asked on 15 Aug 2009, 01:52 AM
Having done a thorough search for the obvious, I figured I was better off just asking the experts here.
I have a custom/advanced edit form which is powered by a custom data provider. This provider is capable of throwing custom exceptions that I would love to be able to catch and display a friendly error message to the user. However, I can't seem to find where the heck to put a try catch block and what to wrap it around. I'm believe that there would have to be one inside the AdvancedForm for insert/update cases as well as one in the page that hold the calendar in the case of moving an appointment from the calendar view.
I have a custom/advanced edit form which is powered by a custom data provider. This provider is capable of throwing custom exceptions that I would love to be able to catch and display a friendly error message to the user. However, I can't seem to find where the heck to put a try catch block and what to wrap it around. I'm believe that there would have to be one inside the AdvancedForm for insert/update cases as well as one in the page that hold the calendar in the case of moving an appointment from the calendar view.
7 Answers, 1 is accepted
0
Hi,
It's not possible to catch the provider exception in the template code, as they are part of different call chains. The best that we can do now is to raise an event in the provider and then handle it on the page to display the error message. The form itself will be closed however, as this is done immediately after calling the provider Insert/Update method. I'll send you sample code if this is good enough for you.
We plan to revise the SchedulerProvider "interface" and this will definitely be one of the areas that we'll improve. We can add a return value to each provider method that will indicate whether it was successful or not. We'll implement it as an interface, so additional information can be passed as well. Then we can raise an event that will let you act on this result and optionally abort the operation altogether.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
It's not possible to catch the provider exception in the template code, as they are part of different call chains. The best that we can do now is to raise an event in the provider and then handle it on the page to display the error message. The form itself will be closed however, as this is done immediately after calling the provider Insert/Update method. I'll send you sample code if this is good enough for you.
We plan to revise the SchedulerProvider "interface" and this will definitely be one of the areas that we'll improve. We can add a return value to each provider method that will indicate whether it was successful or not. We'll implement it as an interface, so additional information can be passed as well. Then we can raise an event that will let you act on this result and optionally abort the operation altogether.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Alex Occhipinti
Top achievements
Rank 1
answered on 22 Aug 2009, 02:21 AM
Hmmm, this doesn't sound good at all. If I am understanding this correctly, that means that there is no way for me to check for a resource conflict without trashing all the user entered data (there's a bunch being entered through a custom Advanced form) if there is a conflict. Is there no way to alter the user of a pending problem with the configuration that they entered without losing all the data? Perhaps moving the resource check outside the custom provider, but in a location that will have access to the submitted (to be saved) appointment and the scheduler's appointments?
0
Hello,
Sounds like a custom validator would be the best fit for this scenario. Take a look at the DurationValidator in the Advanced Templates sample for an example. You can access the scheduler appointments in the validator OnServerValidate handler through Owner.Appointments.
I hope this helps.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Sounds like a custom validator would be the best fit for this scenario. Take a look at the DurationValidator in the Advanced Templates sample for an example. You can access the scheduler appointments in the validator OnServerValidate handler through Owner.Appointments.
I hope this helps.
All the best,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Alex Occhipinti
Top achievements
Rank 1
answered on 01 Nov 2009, 10:35 PM
Telerik, the custom validator works very nicely. However the handler is being called twice on each event update and insert. Why is this? How can I make it be only called once?
0
Hello,
We can confirm that the validator code is executed twice. We've traced the second call back to our own code. It's redundant and we'll remove it after some testing just to make sure that it's not needed in some exotic case.
Thank you for reporting this issue. As a token of our gratitude for your involvement, your Telerik points have been updated.
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
We can confirm that the validator code is executed twice. We've traced the second call back to our own code. It's redundant and we'll remove it after some testing just to make sure that it's not needed in some exotic case.
Thank you for reporting this issue. As a token of our gratitude for your involvement, your Telerik points have been updated.
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andrew
Top achievements
Rank 1
answered on 11 May 2010, 12:19 AM
Hello Tsvetomir,
Above you mentioned that
"The best that we can do now is to raise an event in the provider and then handle it on the page to display the error message. The form itself will be closed however, as this is done immediately after calling the provider Insert/Update method. I'll send you sample code if this is good enough for you."
Can you please post this code?
As well, can you inform us of the status of providing the new interface to the data provider so that errors can be passed back as you described above?
Above you mentioned that
"The best that we can do now is to raise an event in the provider and then handle it on the page to display the error message. The form itself will be closed however, as this is done immediately after calling the provider Insert/Update method. I'll send you sample code if this is good enough for you."
Can you please post this code?
As well, can you inform us of the status of providing the new interface to the data provider so that errors can be passed back as you described above?
0
Hi,
On a second thought this might not be easy, as we don't have a direct reference to the provider instance. Until we provider a proper error handling mechanism your solution is probably the best.
Greetings,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
On a second thought this might not be easy, as we don't have a direct reference to the provider instance. Until we provider a proper error handling mechanism your solution is probably the best.
Greetings,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.