You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2007/06/05 15:23:12 UTC
[Tapestry Wiki] Trivial Update of "Utf8EncodingInT5" by DavidPeterson
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by DavidPeterson:
http://wiki.apache.org/tapestry/Utf8EncodingInT5
------------------------------------------------------------------------------
- = How to use UTF-8 encoding in T5 =
+ Renamed to Tapestry5Utf8Encoding for naming consistency
- At the time of writing, T5 (version 5.0.5-SNAPSHOT) doesn't have built-in support for UTF-8 encoding, but this will certainly be included in one of the upcoming releases.
-
- In the meantime, follow the instructions below to use "foreign" characters, i.e. ones outside ISO-8859-1.
-
- == In your AppModule.java file, add the following methods ==
-
-
- {{{
-
- 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);
- }
- };
- }
-
- public static PageResponseRenderer decoratePageResponseRenderer(
- @InjectService("PageMarkupRenderer") final PageMarkupRenderer markupRenderer,
- @InjectService("MarkupWriterFactory") final MarkupWriterFactory markupWriterFactory,
- final Object delegate)
- {
-
- return new PageResponseRenderer()
- {
- public void renderPageResponse(Page page, Response response) throws IOException
- {
- MarkupWriter writer = markupWriterFactory.newMarkupWriter();
- markupRenderer.renderPageMarkup(page, writer);
- PrintWriter pw = response.getPrintWriter("text/html; charset=UTF-8");
- writer.toMarkup(pw);
- pw.flush();
- }
- };
- }
-
- }}}
-
- == Now update your contributeRequestHandler() method ==
-
- (Note that in earlier versions this was called contributeRequestFilters.)
-
- {{{
-
- public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
- @InjectService("TimingFilter") final RequestFilter timingFilter,
- @InjectService("Utf8Filter") final RequestFilter utf8Filter)
- {
- configuration.add("Utf8Filter", utf8Filter); // handle UTF-8
- configuration.add("Timing", timingFilter);
- }
-
- }}}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org