PDA

View Full Version : [3.0] Ext.data.Store uses POST



csky
15 Apr 2009, 11:08 AM
In 3.0, Ext.data.Store uses POST to fetch. In 2.2 it used GET. Tried to add method to config options, doesn't appear to work. Retrieve should use GET, no?

evant
15 Apr 2009, 12:51 PM
Please post a test case. What does the post look like in FireBug?

allistar
15 Apr 2009, 6:36 PM
I've noticed in 2.0 it uses "POST" if you have specified something in the "baseParams" config item, otherwise it uses GET.

Is it difficult to modify the back end to process the request as a POST instead of a GET?

evant
15 Apr 2009, 6:50 PM
You can explicitly specify the method property.

csky
16 Apr 2009, 5:33 AM
Here is a code snippet.



Ext.onReady( function()
{
var store = new Ext.data.GroupingStore(
{
url:'/stuff'
,method: 'GET' // this makes no difference
,reader: new Ext.data.JsonReader({ root: 'data', fields: ['type', 'name'] })
});

store.load();
});


I can see the POST in Firebug and Live Headers:



POST /stuff HTTP/1.1
Host: 192.168.4.247:8001
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://somehost/foo.html
Content-Length: 12
Pragma: no-cache
Cache-Control: no-cache
xaction=load

HTTP/1.x 200 OK
Content-Type: text/html
Content-Length: 3619
Date: Thu, 16 Apr 2009 13:25:40 GMT
Server: lighttpd/1.4.22


If I switch to point to Ext 2 the same code uses GET.


You can explicitly specify the method property.

I tried that and it makes no difference. I had to create a proxy with the GET method set.

Even so, I thought the idea in 3 is that Store can have a writer to push changes to the server. So, shouldn't the store be using GET, POST and DELETE as necessary?

csky
16 Apr 2009, 5:41 PM
Is it difficult to modify the back end to process the request as a POST instead of a GET?

I guess I could create urls to handle POST specifically from extjs 3. But, I'd really like to understand if I'm doing something wrong and whether the POST behavior is correct or not. No one else has mentioned a similar problem or commented, so maybe I am just doing something wrong (although its only three lines of code and it use to behave differently).

cmo
16 Apr 2009, 6:10 PM
I have a vague recollection of running into this in Ext 2.2. I believe we just configured our own HttpProxy on the store and specified the HTTP method on the proxy which worked just fine (only way we could get DELETEs working if I recall correctly).

mcduke
19 Apr 2009, 2:26 AM
In 3.0RC1, Ext.data.Store uses POST to fetch. In 2.2 it used GET. Tried to add method to config options, doesn't appear to work. Retrieve should use GET, no?

I ran into the same issue. I'm using Ext 2.2.1 client-side, communicating with a Tomcat back end, and I've designed my Servlets like this:

GET: means the client just wants to get some data
POST: means the client wants to change/update/delete something, i.e. initiate an action

Now this works perfectly with Ext 2.2.1: Stores (I mostly use a JsonReader with an implicit Store) send GET requests to fetch their data. On user interactions, I send POST requests to initiate actions.

With Ext 3.0RC1, this design breaks down however, since Stores now also use POST. Also, there seems to be no obvious way of configuring this behavior.

Seems like a bug to me.

shibubh
19 Apr 2009, 5:54 PM
instead of doing this


Ext.onReady( function()
{
var store = new Ext.data.GroupingStore(
{
url:'/stuff'
,method: 'GET' // this makes no difference
,reader: new Ext.data.JsonReader({ root: 'data', fields: ['type', 'name'] })
});

store.load();
});


try


Ext.onReady( function()
{
var store = new Ext.data.GroupingStore(
{

proxy: new Ext.data.HttpProxy({
method: 'GET',
url:'/stuff'
})
,reader: new Ext.data.JsonReader({ root: 'data', fields: ['type', 'name'] })
});

store.load();
});

giridhar
14 Jun 2009, 9:30 PM
Interchanging the 'method' and 'url' is not making any difference. Is it s bug in 3.0 RC2?