Apache Wicket

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.[5]

Apache Wicket
Developer(s)Apache Software Foundation
Stable release
6.x6.30.0 / 5 December 2019 (2019-12-05)[1]
7.x7.16.0 / 4 January 2020 (2020-01-04)[2]
8.x8.7.0 / 3 January 2020 (2020-01-03)[3]
Preview release
9.0.0-M5 / April 6, 2020 (2020-04-06)[4]
RepositoryWicket Repository (Mirror)
Written inJava
TypeWeb application framework
LicenseApache License 2.0
Websitewicket.apache.org

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[6]). 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, 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">
<html xmlns="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>
    <span wicket:id="message" id="message">Message goes here</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").
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!"));
    }
}
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 {
    /**
     * Constructor.
     */
    public HelloWorldApplication() {
    }

    /**
     * @see org.apache.wicket.Application#getHomePage()
     */
    public Class getHomePage() {
        return HelloWorld.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-app xmlns: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>Wicket Example</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
Series Description Latest release Latest release date
Latest preview version of a future release: 9.x Moving to Java 11 as the required minimum platform, migrated from JUnit 4 to 5, suport for Java 12 and 13, rework page and data storage and other improvements.[7] 9.0.0-M5 2020-04-05
Current stable version: 8.x Moving 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.[8] 8.7.0 2020-01-07
Older version, yet still maintained: 7.x Moving 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.[9] 7.16.0 2020-01-08
Older version, yet still maintained: 6.x Moving 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.[10] Only security fixes, recommended to upgrade to 7.x or 8.x versions. 6.30.0 2018-12-10
Old version, no longer maintained: 1.5.x Improvements of the Wicket features.[11] 1.5.16 2016-08-05
Old version, no longer maintained: 1.4.x Moving to Java 5 as the required minimum platform.[12] 1.4.23 2014-02-06
Old version, no longer maintained: 1.3.x 1.3.7 2009-07-30
Old version, no longer maintained: 1.2.x 1.2.7 2008-03-23
Old version, no longer maintained: 1.1.x 1.1.1 TBD
Old version, no longer maintained: 1.0.x 1.0.3 TBD
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release
gollark: I was thinking about generating eggs procedurally, which would mean I wouldn't have to art, but that's not practical for the dragons.
gollark: *eats chocolate chip cookies whilst refreshing forums*
gollark: Ironic.
gollark: The 96rd of Octubury.
gollark: Be careful to not get banned for "disrespect" or something.

See also

References

  • Ceregatti Longo, João Sávio (August 26, 2013). Instant Apache Wicket 6 (1st ed.). Packt Publishing. p. 54. ISBN 978-1783280018.
  • Mader, Jochen (March 28, 2012). Wicket: Komponentenbasiert und objektorientiert (1st ed.). Entwickler. p. 220. ISBN 978-3868020816. Archived from the original on 2010-12-23. Retrieved 2009-01-23.
  • Vaynberg, Igor (May 15, 2011). Apache Wicket Cookbook (1st ed.). Packt Publishing. p. 312. ISBN 978-1-84951-160-5.
  • Dashorst, Martijn; Hillenius, Eelco (September 15, 2008). Wicket in Action (1st ed.). Manning Publications. p. 392. ISBN 978-1-932394-98-6.
  • Gurumurthy, Karthik (September 7, 2006). Pro Wicket (1st ed.). Apress. p. 328. ISBN 1-59059-722-2. Archived from the original on 2010-12-23. Retrieved 2009-01-23.

Notes

  1. "Apache Wicket 6.30.0 Release". Retrieved 12 April 2020.
  2. "Apache Wicket 7.16.0 Release". Retrieved 12 April 2020.
  3. "Apache Wicket 8.7.0 Release". Retrieved 12 April 2020.
  4. Apache Wicket 9.0.0-M5 released. wicket.apache.org. Retrieved on 2020-04-12.
  5. Dashorst, Martijn (2007-07-20). "Wicket graduates from Apache Incubation". Retrieved 2008-03-07.
  6. Carleton, Daniel (2007-10-12). "Java Web Development the Wicket Way". DevX. Archived from the original on 10 March 2008. Retrieved 2008-03-07.
  7. Apache Wicket 9.0.0-M1 released. wicket.apache.org. Retrieved on 2018-05-22.
  8. Announcing Apache Wicket 8: Write Less, Achieve More. wicket.apache.org. Retrieved on 2018-05-22.
  9. Apache Wicket v7.0 released. wicket.apache.org. Retrieved on 2018-04-16.
  10. https://wicket.apache.org/news/2012/09/05/wicket-6.0.0-released.html. Retrieved April 16, 2018. Missing or empty |title= (help)
  11. Apache Wicket - Apache Wicket releases Wicket 1.5. Wicket.apache.org. Retrieved on 2013-08-13. Archived October 6, 2014, at the Wayback Machine
  12. 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

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.