Gary VanMatre wrote:
From: Tomasz Pasierb <[EMAIL PROTECTED]> Hello, Could any of you guys explain how I can use the shale-clay composition features with html tiles that are encoded in utf-8 or any other encoding than iso-8859-1? From what I have found so far it seems that it's actually a problem of jsp spec and tomcat implementation (or the fact that it strictly implements the spec). With html templates I have no option of setting the pageEncoding or contentType page directives (those apply to jsps). I've got shale configured to proccess *.html and *.faces requests. Underneath all those requests go through jasper (when deployed on tomcat). Jasper reads the tile (html), and as it cannot find the page directives that would make it set encoding to utf-8 it defaults to iso-8859-1 (jsp spec) which as I've found I cannot change. As a result the utf-8 encoded file is read as iso-8859-1 and garbage is displayed on screen. The solution would probably be to set uft-8 as the default encoding for jasper but that's not JSP specification compliant as Craig McClanahan stated here: http://mail-archives.apache.org/mod_mbox/tomcat-dev/200105.mbox/%3cPine.BSF.4.21 [EMAIL PROTECTED]

During my "investigation" I found that I could use the switch -Dfile.encoding=utf-8 which actually makes tomcat use utf-8 encoding internally and myfaces doesn't convert non-ascii characters to html entities any longer but those characters are still not converted correctly when they are read from hdd. I've tried filtering all requests and in my desparation ;-) I've set both request's and response's characterEncoding to utf-8 and response's contentType to "text/html;charset=utf-8" but it doesn't seem to work. I've tried the following thing on tomcat to actually check this: I prepared a utf-8 encoded html file with non-ascii characters. I viewed this page with standard tomcat web.xml and server.xml settings plus the -Dfile.encoding=utf-8 option. The page was read by tomcat correctly from disk and displayed correctly in the browser. Then I mapped the *.html extension to jsp servlet. When I requested the page, the response had the wrong characters in it and was not displayed correctly in the browser. Is there any solution to this problem? Please tell me those composition features of shale-clay can actually be used with something else than iso-8859-1. Maybe an configuration option could be introduced in shale for encoding that would be used when shale generates jsps dynamically (the page directive). I guess this would make the problem go away.

The Clay full html views don't generate JSP's.  They build the JSF component
tree and the components invoke rendering.

However, Clay is a JSF component and can be used within a JSP page. I think that would be a good test for us to help narrow down where the
fault lies.

I'd like you to try using clay within a JSP page. The entire page would look like the following:

<[EMAIL PROTECTED] contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="clay" uri="http://shale.apache.org/clay"%>
<f:view>
   <clay:clay id="page1" jsfid="/pages/page1.html"/>
</f:view>
I've tried what you suggested above.

I have prepared a page with the following content:
 <[EMAIL PROTECTED] pageEncoding="utf-8" contentType="text/html;charset=UTF-8"%>
 <%@ taglib uri="http://shale.apache.org/clay"; prefix="clay" %>
 <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h" %>
 <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>

 <f:view>
    <clay:clay id="page1" jsfid="/some.html"/>
    <f:verbatim><br /></f:verbatim>
    <h:outputText value="śłóężźćń" />
    <f:verbatim><br />śłóężźćń</f:verbatim>
 </f:view>
and saved it as whatever.jsp
The file some.html contained the same set of characters as h:outputText element's value attribute in the above jsp (one line of text). I don't know if you will see those characters correctly here in this email but those are a few of the Polish language specific characters that are non-ascii and as such are encoded as two-byte utf-8 characters. Both whatever.jsp and some.html were saved with utf-8 encoding.

When I requested this page (/whatever.faces) I got the response with:
- first line of bad characters (the line from some.html)
- second and third line with good characters.

Clay loads those components from hdd at some point and that's probably the moment where the characters are read wrongly. I guess it reads those files assuming they are iso-8859-1 or something and that's why they look bad in the generated response. The characters that are in the jsp directly are read correctly (as utf-8) thanks to the @page directive at the top of the file. If I omit the whole first line all of the characters do not display correctly.

If that's the case, then as I wrote in my previous email maybe there should be an element one could include in html file that would tell clay what encoding to use for reading the file (something like the page directive for jsps) or an application wide config option informing clay what encoding it should use for reading html templates (that might be easier for html developers). Does clay use request's characterEncoding when loading those files? This way one could set the request's characterEncoding in a filter and then clay would use this when loading those files. As for now setting utf-8 encoding for the request object in a filter doesn't work (the characters do not display correct). I'm not sure what would be the best solution if any of those are any good (I'm not an expert :-)) but I do hope for some change that would correct this.
Another task would be to create a JIRA Shale issue (https://issues.apache.org/struts/secure/Dashboard.jspa) and attach the utf encoded template examples.

I'd be grateful if you told me briefly what else apart from the utf encoded templates I should include in this issue on JIRA as I have never filed an issue in any JIRA system before (that's going to be my first time ;-))

Regards,
Tom Pasierb

----------------------------------------------------------------------
Jestes kierowca? To poczytaj! >>> http://link.interia.pl/f199e

Reply via email to