Search code examples
javascriptextjscomboboxopenlayersextjs3

ExtJS, OpenLayers: modify url protocol before it is sent


I'm trying to get a value from combobox inside a formPanel to pass it to a protocol url (of openlayers.protocol.http). This is the url, based on http://jsbin.com/ireqed/2/edit, that I want to get (in the case I'd choose "cars" in the combobox and enter "cool" in textfield):

http://www.mop.org/fs/cars?format=GeoJSON&comments__ilike=cool&queryable=comments

after testing, I finally can get the URL I want after choosing one value in combobox and entering a word in textfield (as above).

To send this new URL in the protocol in formPanel, I use an autoLoad call in the handler function of my search button, I think this is sending the url but it's not catched by the protocol itself (ie. XMLHttpRequest.js) but for ExtJS. So, the GeoJSON output is displayed in the formPanel. I attached three PNGs to show this: formPanel before pressing 'search' button, formpanel after pressing 'search' button, output in firebug.

In firebug, once 'search' button is pressed two URLs are called, the first one is the URL I want to replace in the url of the protocol, but it goes to ext-base.js, which is the wrong place. The second one, I actually don't know why is sent, goes to XMLHttpRequest.js which is the right place, but it shouldn't be sent.

So, before the url must be sent in the first place, I need to change it, how could I do it? btw it seems to me it is replacing an inexistent url which belongs to ExtJS, pls help, thanks

UPDATE #1:

getting closer... because adding OpenLayers.loadURL(myurl, {}, null, function(response){}); in the handler function sents the url to XMLHttpRequest.js (right place), but just immediately another url (from the formpanel) is sent to the same place and this covers the right one, is there a way to add some timing to the openlayers.loadurl function? I understand this function works asynchronously (that's why is faster and gets submitted first than the second one), is there a way to just overwrite the second one? two urls sent, the first one is the right one


Solution

  • The solution was to take the protocol outside the formPanel and use only "protocol.options.url = newUrl;", a complete explanation is here