Dear all,
Sorry for flooding this mailing list with my mails but I have found a
flaw in my set-up that caused the issue to appear:
I accidentally had the JAR file of PrimeFaces 3.4.1 in the classpath of
my web-app (but no other special configuration). After removing this
JAR, the described scrambling issue disappeared for my test page.
To see whether this is a PrimeFaces specific issue, I added the JARs of
the ICEfaces 3.1.0 distribution (after, of course, the removal of the
PrimeFaces JAR) first and then 3.2.0 beta 1. For both versions, after
adding those JARs, the scrambling appears again.
Finally, I performed the same test with adding the RichFaces 4.2.3 JARs
and here the umlauts are actually displayed correctly in the input field
after submission.
My question to the Mojarra developers is (as I hope they are reading
this too): Since it seems that the described issue might possibly be a
problem of the interaction of Mojarra with the given frameworks in the
first two cases, how should I approach this issue?
Regards,
Holger
Am 01.11.12 17:21, schrieb Holger Stenzhorn:
> Dear Alexander and all,
>
> Thank you for your advice but it did not solve the issue and so I
> further experimented:
>
> -
> "FacesContext.getCurrentInstance().getExternalContext().getRequestCharacterEncoding()"
> returns "UTF-8" as expected (without any change to the server
> configuration).
>
> - So I imagined that the string "value" might be (wrongly) encoded as
> "ISO-8859-1" (and not "UTF-8"). So, based on this assumption, I
> "tweaked" the setter for "value" as follows:
>
> public void setValue(String value) throws Exception {
> this.value = new String(value.getBytes("ISO-8859-1"), "UTF-8");
> }
>
> The result shows that my assumption might be right: When I now enter
> the umlauts "äöü" in the input text field and I submit then those
> umlauts are not scrambled but redisplayed correctly.
>
> Hence, since the string "arrives" at the bean/setter already in the
> wrong encoding, I would guess that the input component does not
> properly encode the string before handing it off.
>
> Regards,
> Holger
>
> Am 01.11.12 01:31, schrieb Alexander Hartner:
>> You need to configure your tomcat / JVM to use UTF-8
>>
>> JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
>>
>> as well as the header of the page. This should fix it.
>>
>> On 01/11/2012, at 7:34 AM, Holger
>> Stenzhorn<holger.stenzhorn_at_gmail.com> wrote:
>>
>>> Hello all,
>>>
>>> Using Mojarra 2.1.14, I have created the following JSF page (see
>>> [1]) and managed bean (see [2]).
>>>
>>> When I open that page then the umlauts ("äöü") on the command button
>>> are displayed correctly.
>>> Now I enter those same umlauts in the input text field and click on
>>> the button (see "before.png").
>>> The page is redisplayed with the umlauts in the input text field
>>> scrambled ("äöü") (see "after.png").
>>>
>>> Am I forgetting to do a certain setting here or is this a (possibly
>>> known) bug or issue?
>>> Thanks in advance for your help!
>>>
>>> Regards,
>>> Holger
>>>
>>> [1]
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <html xmlns="http://www.w3.org/1999/xhtml"
>>> xmlns:h="http://java.sun.com/jsf/html">
>>> <h:body>
>>> <h:form>
>>> <h:inputText value="#{bean.value}"/>
>>> <h:commandButton action="/pages/temp" value="äöü"/>
>>> </h:form>
>>> </h:body>
>>> </html>
>>>
>>> [2]
>>> package some.example;
>>>
>>> import javax.faces.bean.ManagedBean;
>>> import javax.faces.bean.RequestScoped;
>>>
>>> @ManagedBean(name="bean")
>>> @RequestScoped
>>> public class Bean {
>>>
>>> private String value;
>>>
>>> public String getValue() {
>>> return value;
>>> }
>>>
>>> public void setValue(String value) {
>>> this.value = value;
>>> }
>>> }
>>> <before.png><after.png>
>