This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ding="UTF-8"?>). However, if a different multibyte encoding is used in the source files, NetUI APT does not create UTF-8 encoded output in the generated XML documents. Instead, the encoding of the input source file is used for the output, even though we set the declaration attrbute as UTF-8. Then, when this XML file is parsed there will be errors such as SAXParseException about an incorrect byte sequence for UTF-8. The problem occurs with the difference in the file encoding of the input Java file and the charset used by our APT processor to write out the struts config file. We just delegate to APT to create the file and have it use the encoding of the source file. We get a PrintWriter for the generated XML output by calling com.sun.mirror.apt.Filer.createTextFile() with null as the charset name. The null charset name tells APT to use the charset used to encode source files when we wite the file. For example, on a Japanese Windows box the JVM file.encoding property may be SJIS. When a source file is edited and multybite characters are used for the names of actions, the encoding is SJIS. The beehive ant task for compiling a Controller file with annotations will use the JVM file.encoding of the system (SJIS) and correctly compile the source file. However, during the annotation processing, when we get the PrintWriter to output the generated XML, it will also use SJIS, regardless of the fact that we write a declaration that says the output file encoding is UTF-8. Note, you can set the encoding of the APT process with an option. So, one possible workaround is to write your Controller.java file using the UTF-8 encoding (or use the native2ascii converter in the JDK). Then explicitly set the encoding to UTF-8 for the APT processor (and javac) in our ant macrodef for "build-pageflows". To try this out, please follow these steps... - Before building your sample app, edit the beehive-tools.xml file in your Beehive distribution. It's in the ant subdirectory of yo...
View Full Document
- Spring '09