myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Bilski <>
Subject Content type of generated page
Date Wed, 08 Jul 2009 13:17:53 GMT

I have a problem with content type of pages generated by MyFaces. I'm 
struggling with proper "hiding" JavaScript in HTML or XML documents. My 
issue is that MyFaces think (I debugged my application running on Tomcat 
6.0.20), that resulting content type will be text/html, so generated 
code looks like this:

<script type="text/javascript"><!--
something here

But Tomcat itself in HTTP headers returns content type as text/xml. In 
that case code should look like:

<script type="text/javascript"><[CDATA[
something here

My Firefox (3.0, but i tried that in Opera and Konqueror as well), as it 
sees XML document, treats whole script block as comment, so no 
JavaScript code is being defined. That's why, when I use commandLink I 
get "oamSubmitForm is not defined" error.

While debugging Tomcat I also checked what contentType is being set in 
ServletResponseWrapper, and it is text/xml. Whereas in MyFaces in 
HtmlResponseWriterImpl contentType is always set to text/html.

Is there any way to force MyFaces to always assume contentType to be 
text/xml? Where from Myfaces get this value? Can someone help? I'm 
struggling with it two days already.

Best regards

Jacek Bilski

View raw message