-
1. Re: JSF facelets and Seam
schlegel Apr 18, 2008 4:54 PM (in response to hanabi)Did you try utf-8...
<?xml version="1.0" encoding="utf-8"?> <!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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <head> <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/> <meta http-equiv="Content-Script-Type" content="text/javascript"/> <meta http-equiv="Content-Style-Type" content="text/css"/> <meta http-equiv="expires" content="0"/> <meta http-equiv="cache-control" content="no-cache, no-store"/> <meta http-equiv="pragma" content="no-cache"/>
-
2. Re: JSF facelets and Seam
hanabi Apr 21, 2008 2:15 AM (in response to hanabi)yes
and I get
auブランドの京セラ製携帯電話</td>instead of Japanese
and still
Content-Type: application/xhtml+xml;charset=ISO-8859-1
in response header from server -
3. Re: JSF facelets and Seam
svadu Apr 21, 2008 9:49 PM (in response to hanabi)I have an application that uses cyrillics (also non latin alphabet, so the problem is similar).
Note the problems are often also (may sound strange to some but it's actually true) vendor specific, i.e. under one vendor/server it may work and under another you you need a different configuration.
I had some problems with an application working perfectly and 'according to design' under Tomcat and then suddenly giving encoding problems when switching to Resin.
This is what I have:
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
Note, it's not xhtml (not sure if it will help, I actually took it over from plain html).
I do remember I had problems with regular html forms request which I solved with the following:
<form action="rus_win/destination.jsp" method="get" accept-charset="UTF-8" lang="ru">
You might also try:
<html lang="<YOUR LANGUAGE CODE>">
But TBH I would really start from checking the default codepage of your server...
-
4. Re: JSF facelets and Seam
svadu Apr 21, 2008 9:52 PM (in response to hanabi)Another tip, if you can use resources (from resource files or database) - use them :)
-
5. Re: JSF facelets and Seam
hanabi Apr 28, 2008 11:44 AM (in response to hanabi)no. i cannot use resources. the form data is comming from user not from server
-
6. Re: JSF facelets and Seam
hanabi Apr 28, 2008 11:51 AM (in response to hanabi)still pages are arriving with
Content-Type: text/html;charset=ISO-8859-1
-
7. Re: JSF facelets and Seam
gimco May 5, 2008 6:00 PM (in response to hanabi)Try using a filter in your web.xml:
<filter> <filter-name>UTF8 Filter</filter-name> <filter-class>com.foo.UTF8Filter</filter-class> </filter> <filter-mapping> <filter-name>UTF8 Filter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping>
This filter must be the first.
The UTF8Filter is this simple class:
public class UTF8Filter implements Filter { public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); } public void init(FilterConfig arg0) throws ServletException { } }
It's the only way that I had success.
-
8. Re: JSF facelets and Seam
hanabi May 7, 2008 2:00 AM (in response to hanabi)that's exactly what i did. Found this solution couple of days ago on another forum. Thanx anyway
-
9. Re: JSF facelets and Seam
zaya May 7, 2008 4:31 AM (in response to hanabi)Or just add
<web:character-encoding-filter encoding="UTF-8" override-client="true"/>
in your components.xml file
-
10. Re: JSF facelets and Seam
hanabi May 7, 2008 4:32 AM (in response to hanabi)no, this is not working
-
11. Re: JSF facelets and Seam
angelolloqui May 16, 2008 7:08 PM (in response to hanabi)<filter> <filter-name>UTF8 Filter</filter-name> <filter-class>com.foo.UTF8Filter</filter-class> </filter> <filter-mapping> <filter-name>UTF8 Filter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping>
public class UTF8Filter implements Filter { public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); } public void init(FilterConfig arg0) throws ServletException { } }
Thank you very much!!
This way finally works for me too!! with spanish chracters!!
I have spent a lot of time with this issue since
<web:character-encoding-filter encoding="UTF-8" override-client="true"/>
doesn't work. -
12. Re: JSF facelets and Seam
rave Jun 23, 2008 2:34 PM (in response to hanabi)works if you replace *.jfs by *.seam:
<filter-mapping> <filter-name>UTF8 Filter</filter-name> <url-pattern>*.seam</url-pattern> </filter-mapping>
-
13. Re: JSF facelets and Seam
damianharvey.damianharvey.gmail.com Oct 28, 2008 6:50 PM (in response to hanabi)I also couldn't get the <web:character-encoding-filter> working (using Seam 2.0.2.SP1).
I've placed breakPoints in CharacterEncodingFilter and can see that the request encoding is set to UTF-8 however the value is still not being set correctly when it reaches the model. If I use the standard filter as above (ie. defined in web.xml) then it works.
Any thoughts? Anywhere else that I can look?
I'll test on later versions when I get some time this week and report back. Can anyone confirm that this works on 2.0.2?
Thanks,
Damian.
-
14. Re: JSF facelets and Seam
jkronegg Jul 30, 2009 11:22 AM (in response to hanabi)I had the similar problem. I wanted to write accented characters in european language (e.g. french) in XHTML files and also allow accented characters in HTML forms. The problem was that encoding problems occurs not in standard forms but only in Seam-generated EntityList.xhtml files which uses redirect with page parameters.
There is some things to know about Seam when dealing with encoding of page parameters:
- Seam Manager's default encoding for URLs (and so for page parameters specified in the page.xml file) is UTF-8.
- when submitting a form, a POST query with parameters is done, with a redirect to a GET page which does not specify the charset, so the URL page parameters is encoded using the Seam's default encoding (UTF-8 as defined in 1), which may introduce bad characters.
This is how I solved the problem:
- In order to allow accented characters in european languages in the source, I added on the top of my XHTML page:
<?xml version="1.0" encoding="ISO-8859-1"?>
- In order to get URLs and page parameters encoded with the correct charset, I added in components.xml:
<core:manager uri-encoding="ISO-8859-1" ...>
- I did not use
<web:character-encoding-filter encoding="UTF-8" override-client="true"/>in components.xml because it worked without it
Note: requires Seam 2.1.0 or higher (maybe you upgraded since 2008).
References:
- JBSEAM-4330
- JBSEAM-2710
- JBSEAM-3148
- encoding Problem with german special characters ... again
- pages.xml navigation encoding problem
- Charset encoding problem in URL parameters