This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • How to write JSON response
Skip to end of metadata
Go to start of metadata

In your WebPage...


public class JsonWebPage extends WebPage {

	public JsonWebPage(PageParameters pageParameters) {

		getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() {

			public void detach(RequestCycle requestCycle) {
				// Nothing to do here.

			public void respond(RequestCycle requestCycle) {
				// Add JSON-encoded string to the response.
				Response response = requestCycle.getResponse();

You can use TextRequestHandler to simplify the code above.

NOTE: You DO NOT need to manually write JSON response, there are libraries like available that will allow you to convert an object hierarchy to something more useful in terms of JSON rather easily. For details, check the documentation at:

Another library for JSON processing/generation is jackson.

NOTE Wicket >= 1.5.x: see for an example

  • No labels