FIX TextStreamResponse public InputStream getStream() throws IOException { ContentType ct = new ContentType(_contentType); String charset = ct.getParameter("charset"); if (StringUtils.isNotBlank(charset)) { return new ByteArrayInputStream(_text.getBytes(charset)); } else { return new ByteArrayInputStream(_text.getBytes()); }
} USE: return new TextStreamResponse("text/html;charset=UTF-8", writer.toString()); 2007/11/14, thanos <[EMAIL PROTECTED]>: > > > Yes, forcing the encoding to "UTF-8" inside a ByteArrayInputStream did the > trick. > It works now! > > I will soon make some tests to compare the two approaches (Template based > XML vs StreamResponse), since perfomance was the main reason I switched to > Tapestry. Will keep you posted. > > Many thanks to all of you guys :) > > > Nick Westgate wrote: > > > > > The problem is the that I can't make TextStreamResponse to show UTF-8 > > (greek > > > in my case) characters. > > > Dont know if it's related with this post: > > > > > > > > > http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004 > > > > Yes, my previous post pointed out a solution. Here's some source ... > > > > Cheers, > > Nick. > > > > > > // Copyright 2007 The Apache Software Foundation > > // > > // Licensed under the Apache License, Version 2.0 (the "License"); > > // you may not use this file except in compliance with the License. > > // You may obtain a copy of the License at > > // > > // http://www.apache.org/licenses/LICENSE-2.0 > > // > > // Unless required by applicable law or agreed to in writing, software > > // distributed under the License is distributed on an "AS IS" BASIS, > > // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > > implied. > > // See the License for the specific language governing permissions and > > // limitations under the License. > > > > package yourapp.tapestry.utility; > > > > import static org.apache.tapestry.ioc.internal.util.Defense.notBlank; > > import static org.apache.tapestry.ioc.internal.util.Defense.notNull; > > > > import java.io.ByteArrayInputStream; > > import java.io.IOException; > > import java.io.InputStream; > > > > import org.apache.tapestry.StreamResponse; > > import org.apache.tapestry.services.Response; > > > > public class TextStreamResponseFix implements StreamResponse > > { > > private final String _contentType; > > > > private final String _text; > > > > private String _encoding; > > > > public TextStreamResponseFix(final String contentType, final String > > text) > > { > > notBlank(contentType, "contentType"); > > notNull(text, "text"); > > > > _contentType = contentType; > > _text = text; > > } > > > > public TextStreamResponseFix( > > final String contentType, > > final String text, > > final String encoding) > > { > > this(contentType, text); > > > > _encoding = encoding; > > } > > > > public String getContentType() > > { > > return _contentType; > > } > > > > public InputStream getStream() throws IOException > > { > > return new ByteArrayInputStream((_encoding == null) ? > > _text.getBytes() > > : _text.getBytes(_encoding)); > > } > > > > public void prepareResponse(Response response) > > { > > // No-op by default. > > } > > } > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13746317 > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >