Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt
hiddentrue
  • HTTP, Non-HTTP, and Displaying

How do I add custom error pages?

Non-HTTP Error Pages

In your application class that extends WebApplication, set the following in the init() method:

...

Code Block
getRequestCycle().onRuntimeException(new MyErrorPage(), theException);

HTTP Error Pages

First ensure that the wicket filter-mapping in your web.xml has the following dispatchers:

...

Code Block
public class PageNotFound extends WebPage {

	private static final long serialVersionUID = 1L;

	public PageNotFound() {
		// Add any necessary components
	}

	@Override
	protected void configureResponse() {
		super.configureResponse();
		getWebRequestCycle().getWebResponse().getHttpServletResponse().setStatus(HttpServletResponse.SC_NOT_FOUND);
	}

	@Override
	public boolean isVersioned() {
		return false;
	}

	@Override
	public boolean isErrorPage() {
		return true;
	}

}

How do I add/display errors?

Normally all that is needed to display errors in a page is to call the "error" method in the WebPage:

...

Code Block
<!-- In the HTML page -->
<div wicket:id="feedback">[Feedback Panel]</div>

// In WebPage
add(new FeedbackPanel("feedback"));

How do I add/display errors at the component level?

See ComponentFeedbackPanel, FormComponentFeedbackBorder, and FormComponentFeedbackIndicator

// TODO : add example that adds error messages to individual form components of the page

I get 'Internal error cloning object' errors

This is a debug feature to help find potential problems when the application runs clustered. It checks the component graphs to make sure everything is serializable (which is required for clustering).

...