-
10 Jul 2008 5:41 AM #1
events: connection exceptions, chaining events & canceling
events: connection exceptions, chaining events & canceling
As I've posted previously, I'd like to setup a global connection handler. Essentially, I want to do something similar in concept to the basic login tutorial; I want to capture and handle 403 statuses. If any XHR request results in a 403 status, I want to cancel, gracefully, the requesting event (which could be a loader), and launch a separate process. It would be cool if, after that process was done, it could resume the initiator, but it has to at least cancel it. I'd also like the listener to act as an interceptor - if the response is not a 403, chain to whatever failure handler would normally receive the event. Can someone tell me if this can be done, and what I'd need to do to make it happen?
TIA
-
10 Jul 2008 5:45 AM #2
See ext-basex (in my sig below). It enhances the ext-base adaptor to handle all that with native Ext events.
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
10 Jul 2008 9:01 AM #3
Ok, so, I'm trying it out. When I add it to an already working page, I get an error about this.headers not being defined. Is there something special I need to do to implement it?
-
10 Jul 2008 9:11 AM #4
Some code and stacktrace might help
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
10 Jul 2008 9:30 AM #5
Well, ok - I'm using a simple TreeLoader to make a call (actually twice, the first is the lazy load, the second expands a node):
And this results:Code:tree=new T.TreePanel({ title: "review items", animate:false, enableDD:false, lines:false, frame:true, autoHeight:true, autoScroll:true, rootVisible:true, loader: new T.TreeLoader({ dataUrl:"/foundry/forge/test3.cfm" }), root: new T.AsyncTreeNode({ text:"Districts" ,listeners:{ expand:{ fn:function(){ var N=tree.getNodeById(d) N.expand(); N.getUI().getEl().scrollIntoView(); },single:true } } ,id:"district" }) })Code:this.headers is undefined http://localhost/srsdss/js/ext/ux/ext-basex.js Line 546 request()() ext-basex.js (line 546) request()(Object url=/foundry/forge/test3.cfm scope=Object) ext-all-debug.js (line 5106) requestData()([Node district] loaded=false loading=true childrenRendered=false, function()) ext-all-debug.js (line 23859) load()([Node district] loaded=false loading=true childrenRendered=false, function()) ext-all-debug.js (line 23816) expand()(undefined, undefined, undefined) ext-all-debug.js (line 23162) fn()() cN_formInit.js (line 83) createSingle()() ext-all-debug.js (line 1397) fire()() ext-all-debug.js (line 1488) fireEvent()() ext-all-debug.js (line 1184) afterExpand()() ext-all-debug.js (line 16098) onExpand()(true, undefined) ext-all-debug.js (line 28119) expand()(undefined) ext-all-debug.js (line 16080) onCheckClick()() ext-all-debug.js (line 28124) h()() ext-all-debug.js (line 1613) getTime()() yahoo-do...-event.js (line 8) [Break on this error] var cType = this.headers['Content-Type']||null;
-
10 Jul 2008 9:49 AM #6
Hmm..
The default value for this(Ext.lib.Ajax).headers should be {}.
If you 'break' on that error what is 'this' and/or what is the value of this.headers?
Are you clearing out the default headers somewhere else?"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
10 Jul 2008 10:00 AM #7
Ah, I see now.
ext-basex is designed to enhance the Ext base adaptor only. Not the YUI adapter."be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
10 Jul 2008 10:09 AM #8
Yep; when I break on that line, 'this' is a queueManager object; there are no headers defined.
No, I'm not monkeying with anything; it should all be straight defaults. My includes:Code:this = Object queueManager=Object queueAll=false activeRequests=0 cType = undefined cb = Object scope=Object argument=Object timeout=30000 data = "node=district" h = undefined hs = false method = "POST" options = Object async=true headers=false proxied=false q = undefined qm = undefined qname = undefined req = undefined uri = "/foundry/forge/test3.cfm" y = 2
I did make this change on line 11551 of ext-all-debug.js, however, if that makes any differencePHP Code:<script src="/js/yui/core/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script src="/js/yui/core/build/container/container-min.js"></script>
<script src="/js/yui/core/build/utilities/utilities.js"></script>
<script src="/js/ext/core/adapter/yui/ext-yui-adapter.js"></script>
<script src="/js/ext/core/ext-all-debug.js"></script>
<script src="/js/ext/ux/ext-basex.js"></script>
<script src="/js/ext/ux/Ext.ux.Plugin.RemoteComponent.js"></script>
<script>Ext.BLANK_IMAGE_URL = "/imgs/s.gif";</script>
<script src="/js/common.js"></script>
-
10 Jul 2008 10:11 AM #9
Oh. Ok, well, I reassert my original post, then.
-
10 Jul 2008 10:15 AM #10
Ext.Ajax does have a requestexception event available to you. Check the docs.
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.


Reply With Quote

