PDA

View Full Version : 2 Store loading the same URL with different params



caesarloh
14 Jul 2009, 1:05 AM
I have 2 stores loading the same URL but with different params one after another.

Only 1 store will be able to load properly. Why is it so???

I understand the request is an AJAX asynchronous call, but it should still be 2 different request, right? So if there is 2 different request, it should be able to load.

danh2000
14 Jul 2009, 1:07 AM
You'll have to post some code for anyone to be able to help.

Please isolate the code into a small test case and link to an online version or post a small copy/pastable example.

caesarloh
14 Jul 2009, 1:19 AM
var reader = new Ext.data.JsonReader({/* json fields*/});

var store1 = new Ext.data.Store
(

{

id : "store1",
reader: reader,
remotesort : false,
autoLoad : false
proxy : new Ext.data.HttpProxy
(

url: "someUrl.jsp"
)
}
);

var store2 = new Ext.data.Store(); /* similiar to store1*/

var grid1 = new Ext.grid.GridPanel() /* simple grid */;
var grid2 = new Ext.grid.GridPanel() /* similiar to store 2*/;


The code where i reload the store :



store1.load(params:{Type:"Available"});
store2.load(params:{Type:"UnAvailable",id:123});

Remy
14 Jul 2009, 2:49 AM
I could be wrong but isn't the proxy simply connecting once (ie being reused but still only making the single connection?)

Animal
14 Jul 2009, 2:52 AM
A concurrency issue on your server?

Loading from a JSP??

JSPs are for building a UI.

Use a servlet. And ensure that multiple threads running that servlet do not stomp on each other's data.

caesarloh
14 Jul 2009, 8:01 AM
Remy :

I thought each store should have their own proxy? Which mean it should be 2 differents request?

Animal :

Hm... maybe it could be concurrency. I will try using a servlet and see how I can work it...

caesarloh
14 Jul 2009, 6:27 PM
Does the store.load() have a timeout value specified?

salaccosmin
15 Jul 2009, 4:30 AM
I have the same problem.This is the solution i put in place

var proxy = new Ext.data.HttpProxy({
url: 'servlet URL',
method: 'POST'
});

var store = new Ext.data.Store({
proxy: proxy,
remoteSort: true,
reader: new Ext.data.JsonReader({
root:'rows',
totalProperty: 'results',
id:'CODE_ELEMENT'
}, [
'CODE_ELEMENT',
'NIVEAU',
'LIBELLE',
'NOM_PAGE',
'CODE_ROLE'
])
});
store.load();
//now the second element a combo who goes on the same servlet to fill the data

var proxyCombo = new Ext.data.HttpProxy({
url: 'servlet URL',
method: 'POST'
});
var storeCombo = new Ext.data.JsonStore({
proxy: proxyCombo,
//send info to my servlet to fill another JSON object
baseParams : {
forCombo : true,
},
reader: new Ext.data.JsonReader({
root:'rows',
totalProperty: 'results',
id:'CODE_ROLE'
}, [
'CODE_ROLE',
'LIBELLE'
])
});
var combo = new Ext.form.ComboBox({
store: storeCombo,
valueField: "CODE_ROLE",
displayField: "LIBELLE",
});
combo.store.load();

caesarloh
15 Jul 2009, 5:50 PM
I just figured what was my problem...

My JSP/servlet took a extremely long time (30seconds) to return back the result. So, when the 2 stores made their calls, the 2nd call will alway timeout as the first call already took 30 seconds.

I managed to identify it when i used a Ext.Ajax.request and set the timeout to 60 seconds. It managed to return the result for both calls.