I did some digging on what may have caused this problem. And I found possible Cayenne & Tapestry issues. URL issue (#2 below) is the most likely candidate. I used Cayenne-Tapestry tutorial with Tomcat run on Windows. Browser was Mozilla.

1. Getting right value from the form.

I would get the String twice as long as the unicode string entered (I used Cyrillic Unicode characters). This happens even when page charset is set to UTF:

<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">

To fix it I had to patch RequestContext.getParameter() using the tip at http://jguru.com/faq/viewquestion.jsp?EID=537645.

This is not very clean, and I am pretty sure there is a better way to handle it (or maybe this is a Tomcat bug?). Anyone?



2. Saving/reading values from the database.

MySQL driver requires a few properties to be set to work with unicode properly. The easiest way is to add them to URL. So instead of

jdbc:mysql://localhost/mydb

you would use

jdbc:mysql://localhost/mydb?useUnicode=true&amp;characterEncoding=UTF8

This seems like the main cause of the problem. Let me know if this works.


3. Displaying values.

Once I have a valid Java Unicode string, I had no problems at all displaying it as HTML. It just worked.


Andrus



At 07:58 PM 10/31/2002 +0000, Andrus Adamchik wrote:
Hi Chris,
What component are you using that displays *incorrect* characters? Is it still the form field, or is this just text (Insert component?).
Andrus
Chris Schwarzfischer writes:
Hi,
I'm currently evaluating tapestry and cayenne an alternative to WO5.1 but
can't figure out the necessary character conversions.
after reading the posts about unicode and tapestry I still can't figure out
what went wrong:
I built the cayenne-tapestry-example and let it run
When input german umlaut chars (like ���) into one of the forms, it gets
written into the database.
When the record is shown on the following page the umlaut char is displayed
as two completely different (also special) chars.
My debugging output (in the setters and getters) shows, that the char is
written into the java object as unicode, then to the database and after that
correctly retrieved from the database (mysql) as unicode again. This leads
me to the conclusion that something is going really wrong with the
transformation between tapestry and the html output. This behavior also
shows up in the workbench example.
the changes I made are as follows:
I tried overriding get ResponseWriter
    public IMarkupWriter getResponseWriter(OutputStream out) {
        HTMLWriter writer = new HTMLWriter("text/html; charset=iso-8859-1",
out);
        return writer;
    }
I also tried:
    public IMarkupWriter getResponseWriter(OutputStream out) {
        HTMLWriter writer = new HTMLWriter("text/html; charset=utf-8", out);
        return writer;
    }
but no difference.
the forms on the page are enctype="multipart/form-data
TIA
System: MacOS X 10.2, Tomcat 4.1.12 JDK 1.3.1 or 1.4.1 (tried both), mysql
3.23.53a max
- - - - - - - - - - - -
 Chris Schwarzfischer
- - - - nwt.ac - - - -



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to