|
@@ -1,5 +1,7 @@
|
|
|
package hellowicket.plaintext;
|
|
|
|
|
|
+import java.nio.charset.Charset;
|
|
|
+
|
|
|
import org.apache.wicket.request.resource.AbstractResource;
|
|
|
|
|
|
/**
|
|
@@ -10,15 +12,18 @@ public class HelloTextResource extends AbstractResource
|
|
|
{
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
+ private static final String CONTENT_TYPE = "text/plain";
|
|
|
+ private static final byte[] DATA = "Hello, World!".getBytes(Charset.forName("UTF-8"));
|
|
|
+
|
|
|
protected ResourceResponse newResourceResponse(Attributes attributes)
|
|
|
{
|
|
|
ResourceResponse response = new ResourceResponse();
|
|
|
- response.setContentType("text/plain");
|
|
|
- response.setContentLength(13);
|
|
|
+ response.setContentType(CONTENT_TYPE);
|
|
|
+ response.setContentLength(DATA.length);
|
|
|
response.setWriteCallback(new WriteCallback() {
|
|
|
public void writeData(Attributes attributes)
|
|
|
{
|
|
|
- attributes.getResponse().write("Hello, World!");
|
|
|
+ attributes.getResponse().write(DATA);
|
|
|
}
|
|
|
});
|
|
|
return response;
|