Thursday, March 22, 2007

Tapestry 4 localization problem

I decided to add localization to my web application. I created file .properties, where I added some pairs : key - value. When I again entered on some of my pages - exception happened : No message found under code 'alt' for locale 'ru_RU' (org.springframework.context.NoSuchMessageException). This problem occurred cause to DatePicker component, which wanted to find localization parameter called "clear" and couldn't find it in .properties file. The simpliest solution for this problem was to all fictive parameter called "clear" with any value (for instance, "CLEAR"). In finding the root of this problem I didn't succeed.

Tuesday, March 20, 2007

MySQL encoding problem

This problem is very common and solution for it can be found very easily. But when I faced it, it was not so easy to find appropriate solution for me. So, I have MySQL db. I saved there data (for instance, strings) written in Russian (or Ukrainian). But when I wanted to view data (through MySQL console or browser in my web application) there were only ???????? (question marks). I tested all posted solutions in Internet (to change my.ini, to change sql script), but none helped. My founded solution was simply to set char set while creating db. For example :
CREATE DATABASE DEFAULT CHARSET=utf8;
USE ;
SET NAMES utf8;

Encoding problem with tomcat

Recently I had problem with encoding. Now I'm going to describe it. I created simple html template which used russian (or ukrainian) letters. Saved this template in UTF-8 encoding. When I view this template file in firefox or IE everything was written good. But when I wrapped it into war and put it into tomcat/webapp directory and tried to view it like localhost:8080/domain/site, I could not read a word. Firefox or IE also showed that current encoding is UTF-8. Changing of all encodings didn't help. The solution for current problem was to add option to JAVA_OPTS in catalina.bat (or catalina.sh in Linux) like -Dfile.encoding=UTF-8.