0
votes

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!

1
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.
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

1 Answers

1
votes

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.