struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qunhuan Mei" ...@qm18.wanadoo.co.uk>
Subject Struts 2.1 utf-8 validation messages (in Arabic, Chinese etc) displayed in "?" when using Ajax validation, a bug or wrong setting?
Date Tue, 03 Mar 2009 18:06:24 GMT

Hi all, 

I am going to use Struts-blank-2.1.6 to demonstrate a localisation problem
when doing Ajax validation in maybe 10 minutes. I am not sure if it is a bug
(from dojo-plugin?) or just a wrong setting somewhere. Hope some expert
could shed some light here. Much appreciated.

Steps to reproduce the problem (using eclipse): 

1. Create a project by importing struts2-blank-2.1.6.war from
...\struts-2.1.6\apps" 
2. Copy the form code from Login.jsp into Welcome.jsp, right before </body>
tag: 

<s:form action="Login"> 
    <s:textfield key="username" /> 
    <s:password key="password" /> 
    <s:submit/> 
</s:form> 

At this point, build and run the project, everything works as it should be
and 
None of the messages are encoded using utf-8.

3. Prepare some utf-8 encoded validation message
Using Google translator to translate “register” into Arabic we get “???” and
into Chinese we get “??”. Then using command “native2ascii -encoding utf-8”
turn these two internationalised message into unicode encoded:
\u0633\u062c\u0644 and \u6ce8\u518c. Simply copy the unicode message into
the end of every message line of package.properties (and
package_es.properties if you want).

4. See message correctly displayed, without using Ajax
At this point: build and run the project, everything works as it should be -
correct behavior and unicode message also displayed correctly (graphically
recognizable).

5. Turn the validation into using Ajax:
(1) Adding dojo taglib to line 3 of Welcome.jsp: 
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> 

(2) Adding <sx:head /> right before </head> to enable ajax validation on the
page 
(3) Replace <s:submit> with <sx:submit validate="true"
ajaxAfterValidation="true" showLoadingText="false"/> 

(4) Adding do-jo jar file "struts2-dojo-plugin-2.1.6.jar" to the project's
lib (from "...\struts-2.1.6\lib") and refresh the project 
(5) Adding following two lines to example.xml, just below <action
name="Login_*" method="{1}" class="example.Login"> 
   <interceptor-ref name="i18n"/>
     <interceptor-ref name="jsonValidationWorkflowStack"/> 

Rebuild and run the project and click submit without any input, the right
error messages are displayed correctly for English and Spanish. But both
Arabic and Chinese are displayed in question marks (“?”). 

What caused the problem?

(My working environment: windows xp pro, eclipse 3.4.1, java 1.6.)

Thanks,

Qunhuan




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message