You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Poulsen <ma...@nesluop.dk> on 2007/05/24 00:09:20 UTC

T5 preferred way to make sure response content-type is utf-8?

Hi All,

I have had some trouble submitting some characters that are not included 
in iso-8859-1.

My test page has a text field and an expansion showing the value from 
the text field. If i enter some random characters not included in 
iso-8895-1 then tapestry just displays "?" instead.

Traditionally I have solved problems like this by setting the response 
Content-Type to utf-8.

To change the default behavior of all pages I replaced the following 
line in org.apache.tapestry.internal.services.PageResponseRendererImpl

PrintWriter pw = response.getPrintWriter("text/html);

with

PrintWriter pw = response.getPrintWriter("text/html; charset=utf-8");

This makes the browser aware of which encoding it should use during 
submit and as the maven-jetty-plugin defaults to utf-8 for request 
character encoding nothing else has to be done when using the jetty plugin.

However it does not feel really nice that I have to hack the framework 
src to get it in; perhaps I could override the PageResponseRenderer 
using my AppModule but I think it would be better if something like this 
was handled by default by the framework. (I guess some of the people 
posting about their troubles regarding submits of non iso-8859-1 
characters are also suffering from this?)

Judging from the comment in the 
PageResponseRendererImpl.renderPageResponse() method it is not in its 
final form so my addition may be too naive.

Could someone tell me the right/preferred way of doing this? :)

Thanks.
-- 
Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 preferred way to make sure response content-type is utf-8?

Posted by Nick Westgate <ni...@key-planning.co.jp>.
It also works with 5.0.4, but to use 5.0.5-SNAPSHOT you might need:

     <repository>
       <snapshots><enabled>true</enabled></snapshots>
       <id>tapestry-snapshots</id>
       <url>http://people.apache.org/~hlship/tapestry-snapshot-repository/</url>
     </repository>

Cheers,
Nick.


Davor Hrg wrote:
> I tried it but had trouble with getting 5.0.5-SNAPSHOT in my pom...
> 
> what is correct url for repository with tapestry snapshots now ?
> 
> Hrg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 preferred way to make sure response content-type is utf-8?

Posted by Davor Hrg <hr...@gmail.com>.
I tried it but had trouble with getting 5.0.5-SNAPSHOT in my pom...

what is correct url for repository with tapestry snapshots now ?

Hrg

On 5/24/07, Nick Westgate <ni...@key-planning.co.jp> wrote:
>
> Hi Chris.
>
> Refer to this HowTo I just threw on the wiki:
> http://wiki.apache.org/tapestry/Utf8EncodingInT5
>
> ... and feel the power of tapestry-ioc! ;-)
> It's still just a hack, but does the job for now.
>
> Cheers,
> Nick.
>
>
> Chris Poulsen wrote:
> > Hi All,
> >
> > I have had some trouble submitting some characters that are not included
> > in iso-8859-1.
> >
> > My test page has a text field and an expansion showing the value from
> > the text field. If i enter some random characters not included in
> > iso-8895-1 then tapestry just displays "?" instead.
> >
> > Traditionally I have solved problems like this by setting the response
> > Content-Type to utf-8.
> >
> > To change the default behavior of all pages I replaced the following
> > line in org.apache.tapestry.internal.services.PageResponseRendererImpl
> >
> > PrintWriter pw = response.getPrintWriter("text/html);
> >
> > with
> >
> > PrintWriter pw = response.getPrintWriter("text/html; charset=utf-8");
> >
> > This makes the browser aware of which encoding it should use during
> > submit and as the maven-jetty-plugin defaults to utf-8 for request
> > character encoding nothing else has to be done when using the jetty
> plugin.
> >
> > However it does not feel really nice that I have to hack the framework
> > src to get it in; perhaps I could override the PageResponseRenderer
> > using my AppModule but I think it would be better if something like this
> > was handled by default by the framework. (I guess some of the people
> > posting about their troubles regarding submits of non iso-8859-1
> > characters are also suffering from this?)
> >
> > Judging from the comment in the
> > PageResponseRendererImpl.renderPageResponse() method it is not in its
> > final form so my addition may be too naive.
> >
> > Could someone tell me the right/preferred way of doing this? :)
> >
> > Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5 preferred way to make sure response content-type is utf-8?

Posted by Nick Westgate <ni...@key-planning.co.jp>.
Hi Chris.

Refer to this HowTo I just threw on the wiki:
http://wiki.apache.org/tapestry/Utf8EncodingInT5

... and feel the power of tapestry-ioc! ;-)
It's still just a hack, but does the job for now.

Cheers,
Nick.


Chris Poulsen wrote:
> Hi All,
> 
> I have had some trouble submitting some characters that are not included 
> in iso-8859-1.
> 
> My test page has a text field and an expansion showing the value from 
> the text field. If i enter some random characters not included in 
> iso-8895-1 then tapestry just displays "?" instead.
> 
> Traditionally I have solved problems like this by setting the response 
> Content-Type to utf-8.
> 
> To change the default behavior of all pages I replaced the following 
> line in org.apache.tapestry.internal.services.PageResponseRendererImpl
> 
> PrintWriter pw = response.getPrintWriter("text/html);
> 
> with
> 
> PrintWriter pw = response.getPrintWriter("text/html; charset=utf-8");
> 
> This makes the browser aware of which encoding it should use during 
> submit and as the maven-jetty-plugin defaults to utf-8 for request 
> character encoding nothing else has to be done when using the jetty plugin.
> 
> However it does not feel really nice that I have to hack the framework 
> src to get it in; perhaps I could override the PageResponseRenderer 
> using my AppModule but I think it would be better if something like this 
> was handled by default by the framework. (I guess some of the people 
> posting about their troubles regarding submits of non iso-8859-1 
> characters are also suffering from this?)
> 
> Judging from the comment in the 
> PageResponseRendererImpl.renderPageResponse() method it is not in its 
> final form so my addition may be too naive.
> 
> Could someone tell me the right/preferred way of doing this? :)
> 
> Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org