PDA

View Full Version : Issues with using XML in a grid



azizbodal
31 Dec 2010, 8:16 AM
I am trying to run the XML example that is shown in the Example Explorer however I am not able to to get it to work. I have one modification to the code which is the path to the XML. I have modified it to :


String path = "http://www.sencha.com/examples/data/data.xml";

// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
....

When I click the 'Load XML' button, all I get is a 'Loading' message on the grid. Try to debug it, the issue seems to be orginating from the BaseLoader class LoadData Async callback which fails:

protected void loadData(final Object config) {
AsyncCallback<D> callback = new AsyncCallback<D>() {
public void onFailure(Throwable caught) {
onLoadFailure(config, caught);
}

public void onSuccess(D result) {
onLoadSuccess(config, result);
}
};
if (proxy == null) {
loadData(config, callback);
return;
}
proxy.load(reader, config, callback);
}

The exception caught onFailure is:
java.lang.RuntimeException: HttpProxy: Invalid status code 0

Any help will be greatly appreciated.

Thank you.
Aziz Bodal

sven
31 Dec 2010, 8:17 AM
RequestBuilder cannot access cross domain resources. This is a limitation by the browsers. You need to host this file on your server where you host your page too.

azizbodal
31 Dec 2010, 8:39 AM
Thank you for your quick response.
I did try to locally host but was still facing issues. I put the data.xml file in a folder \war\data and set the path to:

String path = GWT.getHostPageBaseURL() + "data/data.xml";

that resulted in:

http://127.0.0.1:8888/data/data.xml

however this still caused an exception onfailure:

com.google.gwt.xml.client.impl.DOMParseException: Failed to parse: error on line 2 at column 6: XML declaration allowed only at the start of the document

Just to give you some background, I am running my application in the GWT development mode. Anything else I can try?

On another note, is there a download location for all the Sencha examples as a complete project?

Thanks.

sven
31 Dec 2010, 8:44 AM
Make sure that the file content is correct. That exception indicated that it was able to download the file but cannot read the content.

azizbodal
31 Dec 2010, 9:50 AM
The XML had a carriage return character at the beginning of the file which prevented it from loading correctly.

Thanks!