You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Gast, Thorsten" <th...@wirecard.com> on 2010/07/14 13:36:06 UTC

Accessing transport within wicketGlobalFailureHandler

Hi,

I want to use wicketGlobalFailureHandler() to handle some http status codes from an Ajax-Call.

Currently I am doing something like this - which works fine - but is in my opinion not very nice.

function wicketGlobalFailureHandler() {
	var t = Wicket.Ajax.transports;
	for (var i = 0; i < t.length; ++i) {
		if (t[i].readyState == 4) {
			var status = t[i].status; 
			if (status == '401') {
				alert('Do something...');
			}
			if (status == '403') {
				alert('Do another thing...');
			}
		}
	}
}

Is there a better way, instead of getting all transports and then checking readyState and status code? 
Is there a possibility to get only the current transport, which triggered the failure handler?

Or maybe I'm doing something completely wrong and there is a better approach how I can handle these cases...

Regards

Thorsten