8

Let me share my unique disapointment with the primefaces 3.1, until now... I'm using a phew components in a RichFaces app, everthing fine when i realized an issue, some characters in my native language are displayed wrong, even UTF-8 charset being declared in all places i know it's required.

The problem occur when is entered some special character like "São Paulo" in a and submited the page. The data after submit is redisplays as "São Paulo"

I already tried the folowing work-around:

1)Eclipse IDE : text file enconding option

2)jsf files:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

3)JBOSS server.xml:

<Connector protocol="HTTP/1.1" URIEncoding="UTF-8" port="${jboss.web.http.port}" address="0.0.0.0" 
         redirectPort="${jboss.web.https.port}" />

4)web.xml:

<?xml version="1.0" encoding="UTF-8"?>

5)jsf file:

<h:form acceptcharset="UTF-8" enctype="application/form-data">

6)upgrade the primefaces version to 3.2

Thanks for any help! ;-)

Guilherme
  • 593
  • 1
  • 6
  • 23
  • 1
    It's worth noting that PrimeFaces 3.2 has been released. I don't know if that fixes your problem, but I guess it can't hurt to try. – Steve Mar 15 '12 at 04:04
  • tried that right now, doesn't fix my issue...thanx anyway! – Guilherme Mar 15 '12 at 12:17
  • 1
    Are you using RichFaces or PrimeFaces? You yelled "RICHFACES" which is rather confusing. If RichFaces, are you using JSP or Facelets? Please describe the problem in more detail, it's not clear how and where exactly the problem is occurring. Describe the steps in detail how to reproduce the problem. Describe the expected/unexpected results in detail. E.g. "I entered XYZ in a `h:inputText`, after submit it redisplays as ZYX in `h:outputText`" and so on. – BalusC Mar 15 '12 at 12:33
  • Yes i'm using both, facelets. ok i'll edit the post with more detail... – Guilherme Mar 15 '12 at 12:37
  • Thank you. What exactly does `Content-Type` response header contain? You can find it in Network tab of webbrowser's developer tool (press F12 in Chrome/IE9/Firebug). Is the form submit request been issued by ajax or a normal synchronous request? What if you try the other type of request? – BalusC Mar 15 '12 at 12:55
  • `Server: Apache-Coyote/1.1 X-Powered-By: Servlet/3.0; JBossAS-6, JSF/2.0 Pragma: No-cache Cache-Control: no-cache Expires: Wed, 31 Dec 1969 21:00:00 BRT Content-Type: text/html;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 15 Mar 2012 13:17:39 GMT 200 OK` I'm using a normal request, but i've tried with ajax and also occured the issue. Let me tell more details, when i put a break-point at the ManageBean the field returns the right value, but when it will be send back to the view its encoding is corrupted. – Guilherme Mar 15 '12 at 13:19

2 Answers2

11

i've been forced to create a filter who sets the charset for every request...

public class CharacterEncodingFilter implements Filter {

    @Override
    public void destroy() {
        // TODO Auto-generated method stub
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        response.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");
        chain.doFilter(request, response);
    }

    @Override
    public void init(FilterConfig arg0) throws ServletException {
        // TODO Auto-generated method stub
    }

}

that's solve my issue

Aleksandr Erokhin
  • 1,904
  • 3
  • 17
  • 32
Guilherme
  • 593
  • 1
  • 6
  • 23
1

I just uncomment that portion in conf/web.xml (Tomcat server web.xml) that filter all request and convert into UTF-8.

 <!-- A filter that sets character encoding that is used to decode URIs-->
 <!-- parameters in a POST request -->
 <filter>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
 </filter>

  <!-- The mapping for the Set Character Encoding Filter -->
  <filter-mapping>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
  </filter-mapping>
Divyesh Kanzariya
  • 3,629
  • 3
  • 43
  • 44