Apache Wicket, commonly referred to as Wicket, is a component-based
web application framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and ...
for the
Java programming language
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers ''write once, run an ...
conceptually similar to
JavaServer Faces
Jakarta Faces, formerly Jakarta Server Faces and JavaServer Faces (JSF) is a Java specification for building component-based user interfaces for web applications and was formalized as a standard through the Java Community Process being part o ...
and
Tapestry
Tapestry is a form of textile art, traditionally woven by hand on a loom. Tapestry is weft-faced weaving, in which all the warp threads are hidden in the completed work, unlike most woven textiles, where both the warp and the weft threads may ...
. It was originally written by Jonathan Locke in April 2004. Version 1.0 was released in June 2005. It graduated into an
Apache top-level project in June 2007.
Rationale
Traditional
model-view-controller (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 specialized
template markup. This keeps the application's
flow-of-control simple and clear, but can make
code reuse in the controller difficult.
In contrast, Wicket is closely patterned after
stateful GUI frameworks such as
Swing. Wicket applications are trees of ''components'', which use listener
delegates to react to
HTTP
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
requests against links and forms in the same way that Swing components react to mouse and keystroke events. Wicket is categorized as a component-based framework.
Design
Wicket uses plain
XHTML
Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.
While HTML, prior ...
for templating (which enforces a clear separation of presentation and
business logic In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed. It is contrasted with the remainder of the software that might ...
and allows templates to be edited with conventional
WYSIWYG
In computing, WYSIWYG ( ), an acronym for What You See Is What You Get, is a system in which editing software allows content to be edited in a form that resembles its appearance when printed or displayed as a finished product, such as a printed d ...
design tools
). 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. Using a special tag, a group of individual components may be abstracted into a single component called a ''panel'', which can then be reused whole in that page, other pages, or even other panels.
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
Hibernation is a state of minimal activity and metabolic depression undergone by some animal species. Hibernation is a seasonal heterothermy characterized by low body-temperature, slow breathing and heart-rate, and low metabolic rate. It most ...
objects,
EJBs or
POJOs as models.
In Wicket, all server side state is automatically managed. You should never directly use an HttpSession object or similar wrapper to store state. Instead, state is associated with components. Each server-side page component holds a nested hierarchy of stateful components, where each component's model is, in the end, a POJO (Plain Old Java Object)
Wicket aims for simplicity. There are no configuration files to learn in Wicket. Wicket is a simple class library with a consistent approach to component structure.
Example
A
Hello World
''Hello'' is a salutation or greeting in the English language. It is first attested in writing from 1826. Early uses
''Hello'', with that spelling, was used in publications in the U.S. as early as the 18 October 1826 edition of the '' Norwich ...
Wicket application, with four files:
; HelloWorld.html
: The XHTML template.
Message goes here
; HelloWorld.java
: 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
; HelloWorldApplication.java
: 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
; web.xml
: The
servlet
A Jakarta Servlet (formerly Java Servlet) is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web applicatio ...
application
Deployment Descriptor A deployment descriptor (DD) refers to a configuration file for an artifact that is deployed to some container/engine.
In the Java Platform, Enterprise Edition, a deployment descriptor describes how a component, module or application (such as a w ...
, which installs Wicket as the default handler for the servlet and arranges for HelloWorldApplication to be instantiated at startup.
Wicket Example
HelloWorldApplication
org.apache.wicket.protocol.http.WicketFilter
applicationClassName
org.wikipedia.wicket.HelloWorldApplication
HelloWorldApplication
/*
Components
Basic components like form, links, repeaters, and so on are built-in.
Releases
See also
*
Vaadin
*
Tapestry
Tapestry is a form of textile art, traditionally woven by hand on a loom. Tapestry is weft-faced weaving, in which all the warp threads are hidden in the completed work, unlike most woven textiles, where both the warp and the weft threads may ...
*
Click
*
ZK
*
Richfaces
RichFaces is an open source Ajax-enabled component library for JavaServer Faces, hosted by JBoss. It allows easy integration of Ajax capabilities into enterprise application development. It reached its end-of-life in June 2016.
RichFaces is ...
*
Echo
In audio signal processing and acoustics, an echo is a reflection of sound that arrives at the listener with a delay after the direct sound. The delay is directly proportional to the distance of the reflecting surface from the source and the li ...
References
*
*
*
*
*
Notes
External links
{{Authority control
Java enterprise platform
Free software programmed in Java (programming language)
Web frameworks
Wicket
In cricket, the term wicket has several meanings:
* It is one of the two sets of three stumps and two bails at either end of the pitch. The fielding team's players can hit the wicket with the ball in a number of ways to get a batsman out. ...