Encoding problem with RichFaces
simafe_2000 Feb 11, 2009 3:54 PMHello.
************************************************
Note: The romanian characters are not correctly displayed on this forum.
Please see the same post on www.javaranch.com:
http://www.coderanch.com/t/430758/JSF/java/Encoding-with-RichFaces
************************************************
I am developing a web application using JBoss 5.0.0.GA + RichFaces 3.2.2.GA and I want to use romanian characters on my pages.
The problem is that on my pages these characters are not displayed correctly. More precisely, if I put these characters directly on my page
they are displayed correctly, but if I use
... <h:outputText value="#{customMessages.judet}"/> ...
then they are not correctly displayed.
I have tried to instruct RichFaces to use UTF-8 encoding, but seems like I am missing something.
My JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <f:view> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ... <h:outputText value="#{customMessages.judet}"/> ...
I have specified the below filter on my web.xml to be used instead of the default one
... import org.ajax4jsf.Filter; public class UTF8Filter extends Filter { private final String ENCODING = "UTF-8"; public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding(ENCODING); response.setCharacterEncoding(ENCODING); super.doFilter(request, response, chain); } }
web.xml
... <filter> <display-name>UTF-8 RichFaces Filter</display-name> <filter-name>utf8richfaces</filter-name> <filter-class>com.javawebwizard.common.view.jsf.UTF8Filter</filter-class> </filter> <filter-mapping> <filter-name>utf8richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> ...
On the run.bat script that launches JBoss application server I added
-Dfile.encoding=UTF-8
I don't know if it is important, but my page (the welcome page of my application) is display after a redirect, like this:
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <jsp:forward page="/welcome.faces"/>
Am I missing something? Or is there any error on my code above?
Any help would be highly appreciated.
Thanks.
Best regards,
Felix
Use www.jaaava.com - A Google for Java !!!