0

My web applications is currently using:

  • JBoss AS7
  • JSF2
  • PrimeFaces

Due to this bug UTF-8 form submit in JSF is corrupting data I setup a @WebFilter doing

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

as suggested by BalusC (thank you).

In a simple it always works right. I come to another problem when I need to use the same form for file upload, too (e.g. http://www.primefaces.org/showcase-labs/ui/fileUploadDnd.jsf)

Here's the main difference

 <h:form enctype="multipart/form-data">

WITHOUT the enctype attribute, special unicode characters remains readable.

WITH the enctype attribute, I find "ciaò" instead of "ciaò".

My filter @WebFilter("/*") EncodingFilter is always called however.

Could a possible solution be setting JBoss default encoding to utf-8? How can I do that?

*** * EDIT ****

I also tried putting -Dfile.encoding=UTF-8 in my JAVA_OPTS but nothing.... it won't work :(( Please help me!

Community
  • 1
  • 1
Fabio B.
  • 9,138
  • 25
  • 105
  • 177
  • http://stackoverflow.com/a/11206837/617373 , might help ya – Daniel Aug 09 '12 at 14:30
  • nice but.... 1) what do you mean by "platform"? the os? jboss-as? how can I change the "default encoding" 2) I don't want to convert each of my form strings... what's the actual better solution? How can I modify primefaces? isn't there another way to go? – Fabio B. Aug 09 '12 at 14:35
  • there is an explanation in that answer of what you should fix in primefaces jar in order to fix that issue (just saw that answer i don't really know if its exact issue as yours..) – Daniel Aug 09 '12 at 14:48

1 Answers1

1

This is caused by another bug in PrimeFaces. See also this answer for explanation and solution.

Could a possible solution be setting JBoss default encoding to utf-8? How can I do that?

Yes. How to do that depends on JBoss version. In the ones who have a server.xml (until with version 6.x), it's a matter of adding URIEncoding="UTF-8" to the <Connector> element. In the ones who have a standalone.xml (7.x and newer), it's a matter of adding <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/> to the <system-properties> element.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555