dev@javaserverfaces.java.net

Re: Unicode in JSF

From: Norbert Truchsess <norbert.truchsess_at_t-online.de>
Date: Thu, 13 Oct 2011 22:38:34 +0200

use encoding-attribute in view-tag to tell jsf which character-encoding
is being used when encoding the page content.

<?xml version='1.0' encoding='utf-8'?>
<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">
<f:view encoding="utf-8" contentType="application/xhtml+xml">
<head>...</head>
<body>...</body>
</f:view>

Setting database-encoding to utf-8 is also important. While the encoding
in the database has no(!) influence on the encoding that is used in Java
(the jdbc-driver takes care that the Java-representation is convertet to
the database-encoding and back) it also has no influence on how this
data is encoded by jsf. But not using utf-8 (or utf-16/32 depending what
your db supports) as database-encoding may result in data-loss whenever
the data to be stored contains characters that are not supported by the
db-encoding.

regards,

Norbert

Am Mittwoch, den 12.10.2011, 00:23 +0700 schrieb Phạm Thanh Tùng:
> Dear JSF Experts,
> I don't know send mail to this email address is exactly but hope is true.
> Current i developing a website and have trouble, that is unicode. I
> search and tried few ways but fail. Eg: set meta tag (both cases html
> and xhtml), set acceptCharset="utf-8" in tag form, edit web.xml but
> seem nothing change.
> I hope soon received solution for this.
> Thank you,
>