PDA

View Full Version : [CLOSED] AjaxRequestException.Handler parameters



registrator
May 12, 2015, 9:41 PM
Hi all

I have AjaxRequestException.Handler defined on my Resource Manager but I want s different behavior for session expired event.
What parameters I can pass on with a function that is a handler for this event please?
So I can figure out what message am I getting as an exception and can act accordingly.

Thank you

Daniil
May 13, 2015, 8:26 AM
Hi @registrator,

If you run this example, choose ResourceManager and AjaxRequestException in the respective ComboBoxes, you'll see a set of parameters.
http://examples2.ext.net/#/Events/Listeners/Arguments

registrator
May 13, 2015, 9:45 AM
Wow, cool example. Thank you for pointing it out!

registrator
May 17, 2015, 11:33 AM
Can you please help me defining the function for handling this?

I got this:



@Html.X().ResourceManager().ShowWarningOnAjaxFailu re(false).AjaxTimeout(30000).Listeners(l => l.AjaxRequestException.Fn = "ajaxException(response, result, el, eventType, action, extraParams, o)")


var ajaxException = function (response, result, el, eventType, action, extraParams, o) {

Ext.Msg.alert('Application Error', 'Sorry, an error happened while processing your request. We apologize for the inconvenience!');
return false;
};

In the browser I get: Response not defined and then I remove response and get Result not defined so I think I am doing something very wrong here.

Thank you

Daniil
May 19, 2015, 9:20 PM
Please try:

l.AjaxRequestException.Fn = "ajaxException"

The Fn property's value should be just a function name.

registrator
May 20, 2015, 3:08 PM
Thank you for the answer Daniil.
When I define this like you suggest, the function is called on every page load even if there is no exception and all the parameters passed in are undefined.

Daniil
May 20, 2015, 3:36 PM
Please provide a test case.

registrator
May 20, 2015, 4:05 PM
You can do it like this:

Open your MVC examples solution.
Fid Home.cshtml in the Views/Main folder
Change @Html.X().ResourceManager() to
@Html.X().ResourceManager().ShowWarningOnAjaxFailu re(false).AjaxTimeout(30000).Listeners(l => l.AjaxRequestException.Fn = "ajaxException()")
Find main.js file in the resources/js folder
Add a reference to the main.js file in the Home page <head> tag

<script src="@Url.Content("~/resources/js/main.js")"></script>
Just before " if (window.location.href.indexOf("#") > 0) {" line at the bottom add

var ajaxException = function (result, el, eventType, action, extraParams, o) {

Ext.Msg.alert('Application Error', 'Sorry, an error happened while processing your request. We apologize for the inconvenience!');
return false;
};

Set a brake-point in this function and as soon as your run the project you'll find it stops in this function with no exception thrown on first load of the home page.

Daniil
May 21, 2015, 6:46 AM
l.AjaxRequestException.Fn = "ajaxException()"
That is not my suggestion :)

My was:

l.AjaxRequestException.Fn = "ajaxException"

registrator
May 21, 2015, 7:20 AM
Oh, right. I apologize.
It works of course.

Thank you