You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nick Westgate <ni...@key-planning.co.jp> on 2007/04/23 15:04:06 UTC

Re: Does the form support utf-8? (T5)

Hi Will.

This isn't in T5 yet, but it can be added with a RequestFilter.
In your AppModule.cpp add the code below.

There may already be a "contributeRequestFilters" method,
but it _must_ be renamed to "contributeRequestHandler".
Note that the TimingFilter is optional - it is something
already present from the maven archetype project.

     public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
         @InjectService("TimingFilter")
         RequestFilter timingFilter,
         @InjectService("Utf8Filter")
         RequestFilter utf8Filter)
     {
         configuration.add("Utf8Filter", utf8Filter);
         configuration.add("Timing", timingFilter);
     }

     public RequestFilter buildUtf8Filter(
         @InjectService("RequestGlobals")
         final RequestGlobals requestGlobals)
     {
         return new RequestFilter()
         {
             public boolean service(Request request, Response response, RequestHandler handler)
                 throws IOException
             {
                 requestGlobals.getHTTPServletRequest().setCharacterEncoding("UTF-8");
                 return handler.service(request, response);
             }
         };
     }

Cheers,
Nick.


Donyee wrote:
> Hey , may  I ask  another  question? How to read  a utf-8 char from
> the form?  a TextField? I fill the form with a utf-8 char,then it
> couldn't display right!
> 
> 


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


Re: Does the form support utf-8? (T5)

Posted by Donyee <xy...@gmail.com>.
Thank you so much! Nick!
I will try to dig the code!
 Cheers!

2007/4/23, Nick Westgate <ni...@key-planning.co.jp>:
> Hi Will.
>
> This isn't in T5 yet, but it can be added with a RequestFilter.
> In your AppModule.cpp add the code below.
>
> There may already be a "contributeRequestFilters" method,
> but it _must_ be renamed to "contributeRequestHandler".
> Note that the TimingFilter is optional - it is something
> already present from the maven archetype project.
>
>      public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
>          @InjectService("TimingFilter")
>          RequestFilter timingFilter,
>          @InjectService("Utf8Filter")
>          RequestFilter utf8Filter)
>      {
>          configuration.add("Utf8Filter", utf8Filter);
>          configuration.add("Timing", timingFilter);
>      }
>
>      public RequestFilter buildUtf8Filter(
>          @InjectService("RequestGlobals")
>          final RequestGlobals requestGlobals)
>      {
>          return new RequestFilter()
>          {
>              public boolean service(Request request, Response response, RequestHandler handler)
>                  throws IOException
>              {
>                  requestGlobals.getHTTPServletRequest().setCharacterEncoding("UTF-8");
>                  return handler.service(request, response);
>              }
>          };
>      }
>
> Cheers,
> Nick.
>
>
> Donyee wrote:
> > Hey , may  I ask  another  question? How to read  a utf-8 char from
> > the form?  a TextField? I fill the form with a utf-8 char,then it
> > couldn't display right!
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Chinese name:徐 依伟
English name: will