Yeah I was using this function to send JSON from a page.

protected void setJsonResponse(final String jsonString, final Duration
cacheDuration) {
        getRequestCycle().scheduleRequestHandlerAfterCurrent(new
IRequestHandler() {

            @Override
            public void respond(IRequestCycle requestCycle) {
                AbstractResourceStreamWriter rstream = new
AbstractResourceStreamWriter() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void write(OutputStream output) throws
IOException {
                        output.write(jsonString.getBytes());
                    }

                    @Override
                    public String getContentType() {
                        return MimeType.JSON.toString();
                    }

                };

                ResourceStreamRequestHandler handler = new
ResourceStreamRequestHandler(rstream);
                handler.setContentDisposition(ContentDisposition.INLINE);
                handler.setCacheDuration(cacheDuration);
               
getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
            }

            @Override
            public void detach(IRequestCycle requestCycle) {
                // Do nothing here, move along...
            }
        });
    }

Maybe resources have a better way of doing it though so I'll try doing it
with a resource.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Use-Wicket-as-a-REST-API-tp4660894p4660921.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to