PDA

View Full Version : Question Regarding DataStores



mconnors1234
24 Jan 2008, 6:08 AM
The following code comes directly from one of the grid examples and it works fine:


var store = new Ext.data.Store({

// load using HTTP
url: 'plants.xml',

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have a "plant" tag
record: 'plant'
}, Plant),

sortInfo:{field:'common', direction:'ASC'}
});


Instead of getting the data from an XML file I want to retrieve the data using a Servlet. I changed the URL option to point to a Servlet but now the store does not seems to be working correctly (see code below.) I verified the Servlet is sending the correct XML data to the output stream. In fact, if I take the Servlet output and past it in an XML file and then point the URL to that file everything works fine. Is there something else I need to do to retrieve the data from a Servlet rather than a file?
Thanks,




var store = new Ext.data.Store({

// load using HTTP
url:'http://199.131.146.205:8988/prototypes-EXT-context-root/loadViewColumns?viewName='+viewName,

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have a "plant" tag
record: 'plant'
}, Plant),

sortInfo:{field:'common', direction:'ASC'}
});

Condor
24 Jan 2008, 6:51 AM
1. The server needs to be in the same domain (199.131.146.205:8988).
2. The response content type needs to be text/xml.
3. Add a loadexception handler to the store to identify other errors.

mconnors1234
24 Jan 2008, 7:57 AM
The server is in the same domain and I verified the content type is "text/xml".

I added a loadexception handler and received the message:

"XmlReader.read: XML Document not available"

Any suggestions?

Condor
24 Jan 2008, 8:13 AM
Please recheck the content type. Only 'text/xml' and 'application/xml' are allowed.

mconnors1234
24 Jan 2008, 8:49 AM
I double checked and the content type was incorrect.
Thanks for the help.