Thursday, 23 July 2009

More on MyFaces and ContentType

I've digged some more, debugged some more and know a little more. Whole problem with Apache MyFaces and ContentType comes from the awful idea that there is more than one moment, when, for a single request, resulting ContentType is evaluated.

MyFaces looks at Accept HTTP header, which, in my case, states text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8. MyFaces goes through that list and picks first entry which it understands, in my case that's text/html. It doesn't really matter, that next entry application/xhtml+xml is what I would really want, "text/html" was first.

But JSP mechanism, when it sees something like
<jsp:directive.page contentType="application/xhtml+xml; charset=UTF-8"/>
it does as it is instructed to do and sets ContentType to application/xhtml+xml.

I don't remember now which one comes first, MyFaces or JSP, but something is definetly wrong here. I would like to assume, that when one of those chooses ContentType, the other respects that or, if the other one changes it, the first one won't be stubborn and doesn't force it's choice. The second solution could be hard to implement, so the first one is the way to go. I would expect that MyFaces, before it selects ContentType, tries to get that information from a response that was given to them. And that I will probably file as a bug.

No comments:

Post a Comment