cancel
Showing results for 
Search instead for 
Did you mean: 

Encoding issue

brasseur
Champ in-the-making
Champ in-the-making
I have implemented a custom JSP under Alfresco 1.4 which contains some inputText.

When I am typing a word containing an accent (i.e 'été') in these inputText with the browser configuration set to the encoding ISO-8859-1, the word is bad encoded and it appears with some '?' character instead of the accent.

The tricky thing is that it doesn't occurs in the alfresco user interface's inputText like in the advanced search page with the same configuration.

I already put in my jsp the same stuff as in the JSPs from alfresco like:

<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>

<h:form acceptCharset="UTF-8" id="customJSP">


Is there something more I have to add to my JSP or to my backing bean to force the UTF-8 encoding?
5 REPLIES 5

kevinr
Star Contributor
Star Contributor
I already put in my jsp the same stuff as in the JSPs from alfresco like:

<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>

<h:form acceptCharset="UTF-8" id="customJSP">

Is there something more I have to add to my JSP or to my backing bean to force the UTF-8 encoding?

This looks correct. There is nothing to add to the backing bean. I'm not sure why this isn't working for you. Can you provide any more details on the changes you are making?

Thanks,

Kevin

brasseur
Champ in-the-making
Champ in-the-making
Thanks for your quick response!

In fact, the problem happens only under SUN environment when the environment parameter 'locale' is defined to 'ISO-8859-15'.

Despite, we are forcing the endoding to UTF-8 in the JSP, it appears that the session parameter 'javax.faces.request.charset' is re-defined automatically to 'ISO-8859-1' when submiting the form we created. Moreover, the first time we are accessing our custom JSP, that parameter 'javax.faces.request.charset' is set to 'UTF-8'.

Do you have any idea why the encoding value stored in the session is changing after submitting the form? Is there something we can do to prevent it?

Thanks,
Fred

brasseur
Champ in-the-making
Champ in-the-making
I just discover another thing:

In the beginning of the JSP browse.jsp from alfresco, there is the following peace of java code after the tag <f:view>:

<%
      FacesContext fc = FacesContext.getCurrentInstance();
    
      // set locale for JSF framework usage
      fc.getViewRoot().setLocale(Application.getLanguage(fc));
   %>

I don't have this code in my own JSP. Could it resolve my problem if I had it in the beginning of my own jsp?

Thanks,
Fred

kevinr
Star Contributor
Star Contributor
In the beginning of the JSP browse.jsp from alfresco, there is the following peace of java code after the tag <f:view>:

<%
      FacesContext fc = FacesContext.getCurrentInstance();
    
      // set locale for JSF framework usage
      fc.getViewRoot().setLocale(Application.getLanguage(fc));
   %>

I don't have this code in my own JSP. Could it resolve my problem if I had it in the beginning of my own jsp?

No this code will not affect the page rendering encoding.

Thanks,

Kevin

brasseur
Champ in-the-making
Champ in-the-making
OK, do you see anything else that can solve the problem?

One more thing I can add is that the text entered in the inputText in my own jsp is transfered to my own backing bean with already a bad encoding. So it does not seem only a problem of page rendering encoding.

Thanks,
Fred