Ajax response charset problem PATCH

UI Components for JSF
Post Reply
monakhv
Posts: 42
Joined: 08 Feb 2010, 14:01

10 Feb 2010, 15:35

Hi, All!

Recently two ajax charset response problem have been discovered.
See http://primefaces.prime.com.tr/forum/vi ... f=3&t=1312
and
http://primefaces.prime.com.tr/forum/vi ... f=3&t=1304

After code digging I've found the problem in org.primefaces.application.PrimeFacesPhaseListener class
in the method initPartialResponseWriter. It set character encoding for the response writer but not for response itself.
The character encoding for the response will be always ISO-8859-1!

The correct method code is below

Code: Select all

private void initPartialResponseWriter(FacesContext facesContext) {
		if(facesContext.getResponseWriter() != null)
			return;
		
		try {
			ServletResponse response = (ServletResponse) facesContext.getExternalContext().getResponse();
			ServletRequest request = (ServletRequest) facesContext.getExternalContext().getRequest();
			response.setCharacterEncoding(request.getCharacterEncoding());
			RenderKit renderKit = facesContext.getRenderKit();
			ResponseWriter responseWriter = renderKit.createResponseWriter(response.getWriter(), null, request.getCharacterEncoding());
			facesContext.setResponseWriter(responseWriter);
		}catch(IOException exception) {
			exception.printStackTrace();
		}
	}
I add the only line

Code: Select all

response.setCharacterEncoding(request.getCharacterEncoding());

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Feb 2010, 16:36

I'll look into this today, thanks for the patch. This might help fixing chartset issues without a servlet filter.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

24 Feb 2010, 14:22

cagatay.civici wrote:I'll look into this today, thanks for the patch. This might help fixing chartset issues without a servlet filter.
Please look into this issue, Cagatay. It's a big problem for us too because some german characters (umlauts) cause empty page (nothing is rendered). Although request character encoding has UTF-8 I always get ISO-8859-1 in the response. I've debugged this problem. The patch above helps us.

At the moment I've buit in a workaround with entities. For instance a sign ü has to be coded as ü ä as ä etc.

Thanks. Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

24 Feb 2010, 16:35

I've checked it again. Only PATCH can help us. Without patch we can not use partial update and other languages except english because nothing appears (empty page area to be updated). But just single line and it works fine

Code: Select all

response.setCharacterEncoding(request.getCharacterEncoding());
Is there a ticket in the issue tracker? This is a very urgent bugfixing. Maybe you could put this line this week. We would use then 2.0.1-SNAPSHOT from your repository. Thanks!
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

monakhv
Posts: 42
Joined: 08 Feb 2010, 14:01

25 Feb 2010, 11:04

Oleg wrote:
Is there a ticket in the issue tracker? This is a very urgent bugfixing. Maybe you could put this line this week. We would use then 2.0.1-SNAPSHOT from your repository. Thanks!
Hi, Oleg!

I did not create the issue tracker in the tracker system. The issue is resolve and patch is published. Everybody can use it.
However it will be nice to put it in main stream PrimeFaces code. This is the question to PrimeFaces developers.

Dmitry.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

25 Feb 2010, 11:48

monakhv wrote:
Oleg wrote:
Is there a ticket in the issue tracker? This is a very urgent bugfixing. Maybe you could put this line this week. We would use then 2.0.1-SNAPSHOT from your repository. Thanks!
Hi, Oleg!

I did not create the issue tracker in the tracker system. The issue is resolve and patch is published. Everybody can use it.
However it will be nice to put it in main stream PrimeFaces code. This is the question to PrimeFaces developers.

Dmitry.
http://code.google.com/p/primefaces/iss ... %20Summary
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Mar 2010, 11:47

I've updated issue regarding target version and status.

http://code.google.com/p/primefaces/iss ... ail?id=546

This will be checked in today or tomorrow after testing.

Thanks for the feedback everyone!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Mar 2010, 17:07

This is fixed now, in our PrimeFaces apps we have character encoding servlet filter to enforce charsets so we didn't see the issue in our apps. Now after the fix, it even works without the filter, thanks for the patch and feedback.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

07 Mar 2010, 19:32

cagatay.civici wrote:This is fixed now, in our PrimeFaces apps we have character encoding servlet filter to enforce charsets so we didn't see the issue in our apps. Now after the fix, it even works without the filter, thanks for the patch and feedback.
Great! Can we use nightly build 2.0.1-SNAPSHOT?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Mar 2010, 19:46

Yes sure, starting from tomorrow.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests