开发者

Problem with a ZK Theme and IE Behavior (.htc) content-type

BASIC QUESTION:

Is there a way to set the mime-type (content-type) of elements inside a jar that are pulled into a ZK theme?

Extended background (already posted to ZK Forums with no response)

We are building a theme .jar for our application, and I have gotten everything to work pretty well using zkTheme.bat. The problem I'm having, however, is that we are using PIE.htc (http://www.css3pie.com) in order to provide CSS3 capabilities to IE 7 and IE 8 (specifically just rounded corners, gradients, and box-shadow). The only way to link this inside the theme is to point it to the relative resource inside the jar like so:

  behavior:url(${c:encodeURL(c:cat3('~./',project,'/PIE.htc'))});

where c: is the namespace for core, and project is the 开发者_开发知识库root directory of the project. This points to the correct file resource, but the header is not being set correctly. Doing a wget on the file, we get the following:

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Last-Modified: Thu, 28 Apr 2011 12:36:54 GMT
  Cache-Control: public, max-age=31536000
  Expires: Fri, 27 Apr 2012 12:36:07 GMT
  Content-Type: ;charset=UTF-8
  Content-Language: en-US
  Content-Length: 28284
  Date: Thu, 28 Apr 2011 14:08:23 GMT
  Connection: keep-alive
Length: 28284 (28K) []

As you can see, the content-type is blank. This is probably because most of the files inside the .jar that are being served up are image resources, not behavior files. Here is what we get if we wget just the file itself.

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Accept-Ranges: bytes
  ETag: W/"28280-1299679133268"
  Last-Modified: Wed, 09 Mar 2011 13:58:53 GMT
  Content-Type: text/x-component
  Content-Length: 28280
  Date: Thu, 28 Apr 2011 14:10:34 GMT
  Connection: keep-alive
Length: 28280 (28K) [text/x-component]

So underlying issue is that Internet Explorer doesn't see the content-type header of "text/x-component" and therefore doesn't utilize the code inside the .htc to parse the CSS correctly. My question is therefore: is there a way to make zk serve up this file from the .jar as the proper content-type? Looking around at configurations I don't see a way to do it. Also, I can't find the underlying code that powers the extraction from the theme.jar in order to alter the code to figure out this content-type. I realize I can just drop the PIE.htc somewhere on the webserver and point to it outside of the theme jar, but that makes this code much less portable and therefore eliminates a pretty good portion of our logic to use the theme jar at all.

Please note: we're serving this up on Tomcat, and I've already checked web.xml to make sure text/x-component is bound, which it is (which is obviously the case or else the second wget wouldn't have turned out what it did).


So I discovered the workaround that fit my needs as quickly and easily as possible. Basically, I just replaced the behavior.htc file with a behavior.htc.dsp file, and added the following line to the top:

<%@ page contentType="text/x-component;charset=UTF-8" %> 

My initial fear was that IE would not parse this as the proper filetype because of the extension, but apparently all it cares about it the content-type in the header, so this worked.


You can provide a EL function like c:encodeURL to manually specify the content type yourself. You may refer to this tutorial of Defining Functions .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜