You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dreamltf <h9...@gmail.com> on 2008/06/19 08:37:29 UTC

StringBufferResourceStream character encoding question

Hi all

I found a encoding question in the StringResourceStream, but it works fine
when I use the DynamicWebResource

-----StringResourceStream-----
@Override
	protected void init() {
		super.init();
		this.getMarkupSettings().setCompressWhitespace(true);
		this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
		this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
		this.getResourceSettings().setThrowExceptionOnMissingResource(false);
		this.mountSharedResource("/Test", new ResourceReference("Test") {
			private static final long serialVersionUID = 1L;

			@Override
			protected Resource newResource() {
				return new Resource() {
					private static final long serialVersionUID = 1L;

					@Override
					public IResourceStream getResourceStream() {
						return new StringResourceStream("這是第一題");
					}
				};
			}
		}.getSharedResourceKey());
	}


-----StringResourceStream-----
@Override
	protected void init() {
		super.init();
		this.getMarkupSettings().setCompressWhitespace(true);
		this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
		this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
		this.getResourceSettings().setThrowExceptionOnMissingResource(false);
		this.mountSharedResource("/Test", new ResourceReference("Test") {
			private static final long serialVersionUID = 1L;

			@Override
			protected Resource newResource() {
				return new DynamicWebResource() {
					private static final long serialVersionUID = 1L;

					@Override
					protected ResourceState getResourceState() {
						ResourceState state = new ResourceState() {

							@Override
							public String getContentType() {
								return "text/html";
							}

							@Override
							public byte[] getData() {
								try {
									return "這是第一題".getBytes("UTF-8");
								} catch (UnsupportedEncodingException e) {
									e.printStackTrace();
								}
								return null;
							}
						};
						return state;
					}
				};
			}
		}.getSharedResourceKey());
	}

Thanks!
-- 
View this message in context: http://www.nabble.com/StringBufferResourceStream-character-encoding-question-tp17998234p17998234.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: WebResource vs DynamicWebResource character encoding question

Posted by Dreamltf <h9...@gmail.com>.
Oh no...

I found when I use the StringResourceStream, it works fine

but when I use the StringBufferResourceStream, it still return a wrong
length


Dreamltf wrote:
> 
> Thanks Wicket!
> 
> I found the answer in the Wicket 1.3.4 release notes
> 
> * [WICKET-1704] - ResourceStreamRequestTarget.configure set wrong
> ContentLength for non-ascii characters 
> 
> now, it works fine at Wicket 1.3.4
> 
> Thanks All
> 

-- 
View this message in context: http://www.nabble.com/WebResource-vs-DynamicWebResource-character-encoding-question-tp17998234p18146875.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: WebResource vs DynamicWebResource character encoding question

Posted by Dreamltf <h9...@gmail.com>.
Thanks Wicket!

I found the answer in the Wicket 1.3.4 Release Notes

* [WICKET-1704] - ResourceStreamRequestTarget.configure set wrong
ContentLength for non-ascii characters 

now, it works fine at Wicket 1.3.4

Thanks All
-- 
View this message in context: http://www.nabble.com/WebResource-vs-DynamicWebResource-character-encoding-question-tp17998234p18063242.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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