The Full Wiki

Apache Wicket: Wikis


Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.


From Wikipedia, the free encyclopedia

Apache Wicket
Apache Wicket logo.png
Developer(s) Apache Software Foundation
Stable release 1.4.7 / March 3, 2010; 10 day(s) ago (2010-03-03)
Written in Java
Operating system Cross-platform
Development status Active
Type Web application framework
License Apache License 2.0

Apache Wicket, commonly referred to as Wicket, is a lightweight component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry. It was originally written by Jonathan Locke in April of 2004. Version 1.0 was released in June 2005. It graduated into an Apache top-level project in June 2007.[1]



Traditional MVC frameworks work in terms of whole requests and whole pages. In each request cycle, the incoming request is mapped to a method on a controller object, which then generates the outgoing response in its entirety, usually by pulling data out of a model to populate a view written in specialised template markup. This keeps the application's flow-of-control simple and clear, but can make code reuse in the controller difficult.


Wicket, on the other hand, is closely patterned after stateful GUI frameworks such as Swing. Wicket applications are trees of components, which use listener delegates to react to HTTP requests against links and forms in the same way that Swing components react to mouse and keystroke events.

Wicket uses plain XHTML for templating (which enforces a clear separation of presentation and business logic and allows templates to be edited with conventional WYSIWYG design tools[2]). Each component is bound to a named element in the XHTML and becomes responsible for rendering that element in the final output. The page is simply the top-level containing component and is paired with exactly one XHTML template. Reuseable parts of pages may be abstracted into components called panels, which can then be pulled whole into pages or other panels with a special tag.

Each component is backed by its own model, which represents the state of the component. The framework does not have knowledge of how components interact with their models, which are treated as opaque objects automatically serialized and persisted between requests. More complex models, however, may be made detachable and provide hooks to arrange their own storage and restoration at the beginning and end of each request cycle. Wicket does not mandate any particular object-persistence or ORM layer, so applications often use some combination of Hibernate objects, EJB beans or POJOs as models.


A Hello World Wicket application, with four files:

The XHTML template.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" 
 xml:lang="en" lang="en"> 
    <span wicket:id="message" id="message">Message goes here</span>
The page component that will be bound to the template. It, in turn, binds a child component (the Label component named "message").
package org.wikipedia.wicket;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
public class HelloWorld extends WebPage {
     * Constructor
    public HelloWorld() {
        add(new Label("message", "Hello World!"));
The main application class, which routes requests for the homepage to the HelloWorld page component.
package org.wikipedia.wicket;
import org.apache.wicket.protocol.http.WebApplication;
public class HelloWorldApplication extends WebApplication {
     * Constructor.
    public HelloWorldApplication() {
     * @see org.apache.wicket.Application#getHomePage()
    public Class getHomePage() {
        return HelloWorld.class;
The servlet application definition, which installs Wicket as the default handler for the servlet and arranges for HelloWorldApplication to be instantiated at startup.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" 
id="WebApp_ID" version="2.5">
    <display-name>Wicket Example</display-name>


  1. ^ Dashorst, Martijn (2007-07-20). "Wicket graduates from Apache Incubation". Retrieved 2008-03-07. .
  2. ^ Carleton, Daniel (2007-10-12). "Java Web Development the Wicket Way". DevX. Retrieved 2008-03-07. .


See also

External links


Introductory articles




Got something to say? Make a comment.
Your name
Your email address