PDA

View Full Version : UpdateManager and IE6



ines
5 Feb 2007, 6:40 AM
Hello

I have a problem with the xml request returned by the UpdateManager in IE 6 browser (and not with FF) : when i display the request.responseText, i see my xml tags, the request.status is set to 200 but my request.responseXML is empty ...
(and this one is not empty when i use FF...).




var tree = {
load : function load(){
qualifierTreeManager = new YAHOO.ext.UpdateManager('qualifierTree');
qualifierTreeManager.setRenderer({
render: function(el, response, um){
tree.processResult(response);
}
});
qualifierTreeManager.update(qualifierTree_builder);
qualifierTreeManager.onFailure.subscribe(this.onCallFailure);
},
onCallFailure: function onCallFailure(elt,request){
window.document.getElementById('qualifierTree').innerHTML = request.statusText;
},
processResult: function processResult(request){
if (request.status == 200) {
if (request.responseXML.getElementsByTagName("error")[0] != null) {
error.load(request, 'qualifierTree');
} else {
var root = request.responseXML.getElementsByTagName("treenode")[0];
buildQualifierTree(root);
}
}
}
};

function buildQualifierTree(treeNode) {
var tree = new YAHOO.widget.TreeView('qualifierTree');
createNode(treeNode, tree.getRoot());

// Trees with TextNodes will fire an event for when the label is clicked:
tree.subscribe("labelClick", function(node) {datagrid.load(node.data.id)});

tree.draw();
}


Thanks!
Ines.

Animal
5 Feb 2007, 6:56 AM
It;'s failed to parse your XML. What does the XML look like? What headers did you send back from the server with your XML response?

ines
5 Feb 2007, 7:25 AM
result of getAllResponseHeaders:
Content-Type: text/xml; charset=ISO-8859-1 Cache-Control: no-cache Content-Length: 16348 Connection: keep-alive Server: Jetty(6.1.0pre0)

and an extract from my XML (it is very long):


<tree>
<treenode>
<label><![CDATA[Catégories]]></label>
<id>639413360</id>
<children>
<treenode>
<label><![CDATA[Non renseigné]]></label>
<id>639421056</id>
<children>
...
</children>
</treenode>
</children>
</treenode>
</tree>

Animal
5 Feb 2007, 7:30 AM
Shouldn't it be



<?xml version="1.0"?>
<tree>
<treenode>
<label><![CDATA[Catégories]]></label>
<id>639413360</id>
<children>
<treenode>
<label><![CDATA[Non renseigné]]></label>
<id>639421056</id>
<children>
...
</children>
</treenode>
</children>
</treenode>
</tree>


:?:

ines
5 Feb 2007, 7:37 AM
No, my reponseXml is still empty :(

Condor70
5 Feb 2007, 7:42 AM
Could you also check the result of:


request.responseXML.parseError.errorCode (should be 0)
request.responseXML.parseError.reason (should be empty)
request.responseXML.xml (should contain data)
(these checks are IE only)

ines
5 Feb 2007, 7:59 AM
:)
I didn't know this checks, and i have this result:


Errorcode: -1072896760
reason: An invalid character was found in text content.
xml:

But, it is possible to have the line number or more information ?

tryanDLS
5 Feb 2007, 8:14 AM
That sounds like you have badly formed XML. If you save the XML generated from the server to a text file and open with IE, you should see where it's failing.

ines
5 Feb 2007, 8:21 AM
An invalid character was found in text content...
<tree><treenode><label><![CDATA[Catégories]]></label>

FF has no problem with accents when they are in a CDATA, but it isn't supported by IE ... :?

Animal
5 Feb 2007, 8:29 AM
I don't think that's so. It's complaining about an invalid character - that could be one that is not part of the character set that it is told that it's receiving. CDATA sections accept all characters in the character set.

Just because that accent glyph appears in the error message, doesn't mean that what was sent is valid ISO-8895-1. It might be interpreting UTF-8 data.

How is the backend generating this XML? If you are using Java, you'll have to explicitly tell the servlet to encode using ISO-8859-1 because it will use UTF-8 by default.

ines
5 Feb 2007, 8:46 AM
The XML is generated by a Shale controller. And i just set:


FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml;");
response.setHeader("Cache-Control", "no-cache");
...
context.responseComplete();

And i thought the accents are valid UTF-8...

Animal
5 Feb 2007, 8:55 AM
Well there's your problem (Though I don't know how it could be happening)



result of getAllResponseHeaders:
Content-Type: text/xml; charset=ISO-8859-1
...


But you use



response.setCharacterEncoding("UTF-8");


So that SHOULD send the charset as UTF-8 too.

It's nothing to do with accents not being "valid". UTF-8 is a way of encoding a string into a byte stream. Bytes take values 0-255, and so some kind of encoding must be used to make a byte stream contain the information contained in a String object.

If the content is correctly encoded in UTF-8, and the header specifies that the encoding is UTF-8, then the XML will be parsed.