It was <t:buffer> that caused the encoding problem. I used <t:buffer> in my code.
 
I tried the following simple example without <t:buffer>, it worked fine without problem in typing/displaying back East asia characters. If I wrap the code with <t:buffer>, and output the buffer, it will not work, displaying  East Asia characters back as question marks.
 
I thought <t:buffer> is just a piece of memory without any character conversion. How does <t:buffer> work exactly? what OutputStream is being used? is it possibly involving data conversion? If yes, is there any workaround?
 
Thanks!
 
------------without <t:buffer>, works!----
 
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<HTML>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8">
</head>
<body>
<f:view>
<h:outputText value="#{testBean.name}" />
<h:form>
<h:inputText value="#{testBean.name}"/>
<h:commandButton value="Submit" />
</h:form>
</f:view>
</body>
</HTML>
 
------------------------------------use <t:buffer>, does not work ----
 
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<HTML>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8">
</head>
<body>
<f:view>
<t:buffer into="#{buf}">
<h:outputText value="#{testBean.name}" />
<h:form>
<h:inputText value="#{testBean.name}"/>
<h:commandButton value="Submit" />
</h:form>
</t:buffer>
<h:outputText value="#{buf}" escape="false" />
</f:view>
</body>
</HTML>


Dave <[EMAIL PROTECTED]> wrote:
Thanks!
 
I followed the link and tried the filter solution, unfortunately it did not work for me.
all East Asia characters are still question marks. have you tried East Asia characters in your environment, such as Chinese characters?
 
I tried the following JSP outside JSF. It worked great.  I typed Chinese characters into the input box, and click submit, they displayed back correctly in Chinese, both text and inside the input box. But it did not work in JSF environment.
 
Name: (chinese characters)
Name:[input box]
(submit button)
 
What is difference between regular JSP and JSF in terms of encoding? anything to do with locale? JSF view root has a locale.
 
Thanks!
 
 
<%@ page contentType="text/html; charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
%>
req enc: <%= request.getCharacterEncoding() %><br />
rsp enc: <%= response.getCharacterEncoding() %><br />
 
name: <%= name %><br />
<form method="POST" >
Name: <input type="text" name="name" value="<%= name %>" >
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>


Harald Müller <[EMAIL PROTECTED]>< /I> wrote:
Hi!

I had to implement a "CharsetFilter" like mentioned here: http://wiki.apache.org/tomcat/Tomcat/UTF-8 (had some problems with "east-european" characters)!

Hope this helps,
H





________________________________________
Von: Dave [mailto:[EMAIL PROTECTED]
Gesendet: Samstag, 07. Jänner 2006 01:21
An: MyFaces Discussion
Betreff: Re: JSF support East Asian characters ?

Hi Laurie,
 
Thanks.
I added the following to the beginning of each jsp page.
 
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
 
After the page shows up, the browser says UTF-8. This is great.
 
when I typed in some chinese characters using InputText, and left another InputText empty(required) that would cause validation error and force JSF to re-display the page,  the chinese characters became question marks(?) after display back.
 
The page says UTF-8. Will browser(IE) encode everything in UTF-8? How about server-side (JSF)? any character conversions?
 
I tried to add encoding="UTF-8" to , but it is not allowed.
 
Thanks for help.
 


Laurie Harper <[EMAIL PROTECTED]>wrote:
> Does the browser(IE) or do the encoding of characters?

If the inputText component has an initial value, it will be encoded
server-side using the view's output encoding. When you submit the form,
the browser will encode the current value of the inputText using
whatever encoding it chooses to submit with -- usually the same as the
encoding of the page containing the form.

>> I set the browser(IE) enc oding to Unicode before typing the East Asia
>> characters, after submit, the browser encoding changed to Western
>> Europe(ISO).
So it looks like you're sending the browser a page that's encoded as
ISO-8859-something, not UTF-8. That wont work for Asian characters, of
course.

>> From browser view/source,
>>
>> > CONTENT="text/html;charset=UTF-8">
>>
>> it says UTF-8.

That's in your 'meta' tag in the HTML 'head'? What do you have in your
JSP to specify the page encoding, other than the meta tag? Are you using
a page directive? The meta tag is not enough by itself to tell the JSP
engine to use UTF-8 encoding.

The JSP engine needs to know the correct output encoding to use. If it's
using one encoding (ISO-8859-?), but your meta tag specifies the page
uses a different encoding (UTF-8), things are going to get messed up;
the data is sent in IS0-8859-? but the bro wser is trying to decode it
using UTF-8.

L.

Dave wrote:
> In my configuration I have only English. The locale config is for re source bundle. But the problem I have is the East Asia input and display, not locale support.
> I can type East Aisa characters such as Chinese into the without prob lems, but when they display back after submit, the characters becomes something like:
> &3435;&3489;&3988;&8987;
> They seemed to be encoded somehow.
>
> Does the browser(IE) or do the encoding of characters? Thanks.
>
> ----------------------
>
>
> de
> de
> en
>
>
>
> Thomas Spiegl wrote: Did you add a locale-config to your faces-config.xml ?
>
>
>
> de
> de
> en
>
>
> Thomas
>
> On 12/23/05, Dave wrote:
>> I have a [input] . when I type some East Asia characters into it, they
>> are displaying correctly. But after clicking submit button, they did not
>> show back correctly.
>>
>> One thing I noticed.
>>
>> I set the browser(IE) encoding to Unicode before typing the East Asia
>> characters, after submit, the browser encoding changed to Western
>> Europe(ISO). From browser view/source,
>>
>> > CONTENT="text/html;charset=UTF-8">
>>
>> it says UTF-8.
>>
>> Note: submit did not store data in database, everything is in memory.
>> Browser does character conversion ? or JSF does some conversion?
>>
>> Confused !! What needs to be done for JSF web application to support
>> characters other than English?
>>
>> Thanks in advance for advice.
>> Dave
>>
>> ________________________________
>> Yahoo! DSL Something to write home about. Jus t $16.99/mo. or less
>
>
> --
> http://www.irian.at
>
> Your JSF powerhou se -
> JSF Consulting, Development and> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
>
> ---------------------------------
> Yahoo! for Good - Make a difference this year.

________________________________________
Yahoo! DSL Something to write home about. Just $16.99/mo. or less


Yahoo! DSL Something to write home about. Just $16.99/mo. or less


Yahoo! DSL Something to write home about. Just $16.99/mo. or less

Reply via email to