Apache Wicket

Last updated
Apache Wicket
Developer(s) Apache Software Foundation
Stable release
10.0.0 [1]   OOjs UI icon edit-ltr-progressive.svg / 2024-03-11; 9 days ago
Repository gitbox.apache.org/repos/asf?p=wicket.git%3B
Written in Java
Type Web application framework
License Apache License 2.0
Website wicket.apache.org

Apache Wicket, commonly referred to as Wicket, is a 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 2004. Version 1.0 was released in June 2005. It graduated into an Apache top-level project in June 2007. [2]

Contents

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 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 for templating (which enforces a clear separation of presentation and business logic and allows templates to be edited with conventional WYSIWYG design tools [3] ). 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 objects[ citation needed ], 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 Wicket application, with four files:

HelloWorld.html
The XHTML template.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"xml:lang="en"lang="en"><body><spanwicket:id="message"id="message">Messagegoeshere</span></body></html>
HelloWorld.java
The page component that will be bound to the template. It, in turn, binds a child component (the Label component named "message").
packageorg.wikipedia.wicket;importorg.apache.wicket.markup.html.WebPage;importorg.apache.wicket.markup.html.basic.Label;publicclassHelloWorldextendsWebPage{/**     * Constructor     */publicHelloWorld(){add(newLabel("message","Hello World!"));}}
HelloWorldApplication.java
The main application class, which routes requests for the homepage to the HelloWorld page component.
packageorg.wikipedia.wicket;importorg.apache.wicket.protocol.http.WebApplication;publicclassHelloWorldApplicationextendsWebApplication{/**     * Constructor.     */publicHelloWorldApplication(){}/**     * @see org.apache.wicket.Application#getHomePage()     */publicClassgetHomePage(){returnHelloWorld.class;}}
web.xml
The servlet application Deployment Descriptor, 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-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID"version="2.5"><display-name>WicketExample</display-name><filter><filter-name>HelloWorldApplication</filter-name><filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class><init-param><param-name>applicationClassName</param-name><param-value>org.wikipedia.wicket.HelloWorldApplication</param-value></init-param></filter><filter-mapping><filter-name>HelloWorldApplication</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>

Components

Basic components like form, links, repeaters, and so on are built-in.

Releases

Apache Wicket Versions
SeriesDescriptionLatest releaseLatest release date
Current stable version:10.xMigrated from Javax APIs to Jakarta APIs. Depedencies upgraded to support Spring Framework 6 and therefore moving to Java 17 as the required minimum platform, and compatible with Java 21. CGLib is replaced with ByteBuddy. [4] 10.0.02024-03-11
Current stable version:9.xMoving to Java 11 as the required minimum platform, migrated from JUnit 4 to 5, support for Java 12 and 13, rework page and data storage and other improvements. [5] 9.16.02023-11-23
Older version, yet still maintained: 8.xMoving to Java 8 as the required minimum platform. Support for Lambdas, required Servlet API version moving to 3.1, support for the new types for handling dates and other improvements. [6] Recommended to upgrade to 9.x version.8.14.02022-01-29
Older version, yet still maintained: 7.xMoving to Java 7 as the required minimum platform, cross site request forgery prevention, support for inline images. The release consist of almost 300 features, improvements and fixes. [7] Only security fixes, recommended to upgrade to 9.x version.7.18.02021-04-02
Old version, no longer maintained: 6.xMoving to Java 6 as the required minimum platform. Out-of-the box jQuery integration, complete control over AJAX requests, improved event registration in browsers, support for large datasets, dependency management for client side JavaScript libraries, experimental support for websockets. [8] 6.30.02018-12-05
Old version, no longer maintained: 1.5.xImprovements of the Wicket features. [9] 1.5.162016-08-05
Old version, no longer maintained: 1.4.xMoving to Java 5 as the required minimum platform. [10] 1.4.232014-02-06
Old version, no longer maintained: 1.3.x1.3.72009-07-30
Old version, no longer maintained: 1.2.x1.2.72008-03-23
Old version, no longer maintained: 1.1.x1.1.1TBD
Old version, no longer maintained: 1.0.x1.0.3TBD
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

See also

Related Research Articles

A document type definition (DTD) is a specification file that contains set of markup declarations that define a document type for an SGML-family markup language. The DTD specification file can be used to validate documents.

XHTML Basic is an XML-based structured markup language primarily designed for simple user agents, often found in mobile devices such as mobile phones, PDAs, pagers, and set-top boxes..

XInclude is a generic mechanism for merging XML documents, by writing inclusion tags in the "main" document to automatically include other documents or parts thereof. The resulting document becomes a single composite XML Information Set. The XInclude mechanism can be used to incorporate content from either XML files or non-XML text files.

<span class="mw-page-title-main">Apache Tapestry</span> Open-source web application framework

Apache Tapestry is an open-source component-oriented Java web application framework conceptually similar to JavaServer Faces and Apache Wicket. Tapestry was created by Howard Lewis Ship, and was adopted by the Apache Software Foundation as a top-level project in 2006.

Apache Velocity first released in April 2001, is a Java-based template engine that provides a template language to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a Web application.

RDFa or Resource Description Framework in Attributes is a W3C Recommendation that adds a set of attribute-level extensions to HTML, XHTML and various XML-based document types for embedding rich metadata within Web documents. The Resource Description Framework (RDF) data-model mapping enables its use for embedding RDF subject-predicate-object expressions within XHTML documents. It also enables the extraction of RDF model triples by compliant user agents.

The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. The framework does not impose any specific programming model.. The framework has become popular in the Java community as an addition to the Enterprise JavaBeans (EJB) model. The Spring Framework is free and open source software.

In computer science and web development, XML Events is a W3C standard for handling events that occur in an XML document. These events are typically caused by users interacting with the web page using a device, such as a web browser on a personal computer or mobile phone.

The Web Application Description Language (WADL) is a machine-readable XML description of HTTP-based web services. WADL models the resources provided by a service and the relationships between them. WADL is intended to simplify the reuse of web services that are based on the existing HTTP architecture of the Web. It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser. WADL was submitted to the World Wide Web Consortium by Sun Microsystems on 31 August 2009, but the consortium has no current plans to standardize it. WADL is the REST equivalent of SOAP's Web Services Description Language (WSDL), which can also be used to describe REST web services.

Haml is a templating system that is designed to avoid writing inline code in a web document and make the HTML cleaner. Haml gives you the flexibility to have some dynamic content in HTML. Similar to other template systems like eRuby, Haml also embeds some code that gets executed during runtime and generates HTML code in order to provide some dynamic content. In order to run Haml code, files need to have a .haml extension. These files are similar to .erb or .eRuby files, which also help embed Ruby code while developing a web application.

<span class="mw-page-title-main">RichFaces</span>

RichFaces was 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.

XML documents typically refer to external entities, for example the public and/or system ID for the Document Type Definition. These external relationships are expressed using URIs, typically as URLs.

Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.

Animation of Scalable Vector Graphics, an open XML-based standard vector graphics format is possible through various means:

In computing, Facelets is an open-source Web template system under the Apache license and the default view handler technology for Jakarta Faces. The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on building the JSF component tree, reflecting the view for a JSF application.

Apache Click is a page and component oriented web application framework for the Java language and is built on top of the Java Servlet API.

Java view technologies and frameworks are web-based software libraries that provide the user interface, or "view-layer", of Java web applications. Such application frameworks are used for defining web pages and handling the HTTP requests (clicks) generated by those web pages. As a sub-category of web frameworks, view-layer frameworks often overlap to varying degrees with web frameworks that provide other functionality for Java web applications.

XHTML+RDFa is an extended version of the XHTML markup language for supporting RDF through a collection of attributes and processing rules in the form of well-formed XML documents. XHTML+RDFa is one of the techniques used to develop Semantic Web content by embedding rich semantic markup. Version 1.1 of the language is a superset of XHTML 1.1, integrating the attributes according to RDFa Core 1.1. In other words, it is an RDFa support through XHTML Modularization.

Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file even in offline environments. It provides full Spring Framework integration.

A document type declaration, or DOCTYPE, is an instruction that associates a particular XML or SGML document with a document type definition (DTD). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

References

Notes

  1. Error: Unable to display the reference properly. See the documentation for details.
  2. Dashorst, Martijn (2007-07-20). "Wicket graduates from Apache Incubation" . Retrieved 2008-03-07.
  3. Carleton, Daniel (2007-10-12). "Java Web Development the Wicket Way". DevX. Archived from the original on 10 March 2008. Retrieved 2008-03-07.
  4. Announcing Apache Wicket 10: build modern web applications with Java!. wicket.apache.org. Retrieved on 2024-03-11.
  5. Announcing Apache Wicket 9: get into the modern Java world!. wicket.apache.org. Retrieved on 2020-10-05.
  6. Announcing Apache Wicket 8: Write Less, Achieve More. wicket.apache.org. Retrieved on 2018-05-22.
  7. Apache Wicket v7.0 released. wicket.apache.org. Retrieved on 2018-04-16.
  8. Apache Wicket v6.0.0 released. wicket.apache.org. Retrieved on 2020-10-05.
  9. Apache Wicket - Apache Wicket releases Wicket 1.5. Wicket.apache.org. Retrieved on 2013-08-13. Archived October 6, 2014, at the Wayback Machine
  10. Apache Wicket - Apache Wicket 1.4 takes typesafety to the next level Archived April 25, 2012, at the Wayback Machine . Wicket.apache.org. Retrieved on 2013-08-13.

Official website OOjs UI icon edit-ltr-progressive.svg