[ http://issues.apache.org/jira/browse/BEEHIVE-1033?page=all ]

Carlin Rogers updated BEEHIVE-1033:
-----------------------------------

    Attachment: j1033-test.zip

The zip file attached to this bug contains an annotated page flow Controller 
that was edited include multibyte Japanese characters with SJIS encoding. This 
file can be used to either repro the issue or test the fix. The test is manual 
as it depends on the user environment.

Note that this zip file also includes the expected generated files for the 
struts module config and validator rules with proper UTF-8 encoding.to use as a 
comparison with test results.

The steps to test or repro this issue on a system that does not have SJIS 
encoding as the JVM file.encoding system property...
- Place this sample Controller in your web app.
- Edit the beehive-tools.xml file and add the encoding option (using SJIS) to 
the call to the <apt> task in the <macrodef name="build-pageflows">. The line 
to add should be encoding="SJIS" (for the encoding of the sample source file). 
In the macrodef, the <apt> task should look like this...

           <apt srcdir="@{srcdir}"
                destdir="@{destdir}"
                gendir="@{tempdir}"
                classpathref="_pageflow.build.classpath"
                sourcepathref="@{sourcepathref}"
                srcExtensions="*.jpf,*.jpfs,*.app,*.jsfb,*.java"
                encoding="SJIS"
                processorOptions="[EMAIL PROTECTED]"
                debug="true"/>

- Build the web app containing the attached sample Controller.

- Compare the generated struts config and validator rule files.

> NetUI APT does not create UTF-8 encoded output in the generated XML documents 
> for other multibyte encoded source files.
> -----------------------------------------------------------------------------------------------------------------------
>
>          Key: BEEHIVE-1033
>          URL: http://issues.apache.org/jira/browse/BEEHIVE-1033
>      Project: Beehive
>         Type: Bug
>   Components: NetUI
>     Versions: V1, 1.1
>     Reporter: Carlin Rogers
>     Assignee: Carlin Rogers
>      Fix For: 1.1
>  Attachments: j1033-test.zip
>
> The struts module config files and validator rules generated by NetUI APT are 
> XML files with the encoding attribute of the declaration set to "UTF-8" 
> (<?xml version="1.0" encoding="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 your beehive home.
>     apache-beehive-svn-snapshot/ant/beehive-tools.xml
> - Add the encoding option to the call to the <apt> task in the <macrodef 
> name="build-pageflows">. The line to add should be encoding="UTF-8". In the 
> macrodef, the <apt> task should look like this...
>            <apt srcdir="@{srcdir}"
>                 destdir="@{destdir}"
>                 gendir="@{tempdir}"
>                 classpathref="_pageflow.build.classpath"
>                 sourcepathref="@{sourcepathref}"
>                 srcExtensions="*.jpf,*.jpfs,*.app,*.jsfb,*.java"
>                 encoding="UTF-8"
>                 processorOptions="[EMAIL PROTECTED]"
>                 debug="true"/>
> - Now try to build your modified sample app.
> The output for the struts config file will be in UTF-8

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to