Build web applications from Java components and plain HTML

Apache Wicket is a component-oriented Java web framework, open source since 2004 and a project of the Apache Software Foundation since 2007. Every component keeps its behaviour and state in Java and its markup in plain HTML, so there is no JavaScript build chain to maintain.

In service: the Apache Wicket release lines that receive releases, and until when each is supported
Release line Supported until
Wicket 10 LTS Jul 2027
Wicket 11 Jan 2027

Just endedWicket 9Wicket 8 Upgrade paths

All releases and downloadsHow the release schedule works

Why Wicket

  1. A page is a Java class and an HTML file

    Use what you know about Java and your favourite HTML editor. Behaviour lives in Java, markup stays plain HTML, and no JavaScript build is needed.

    • The wicket:id joins each tag to the Java component with the same id. The HTML stays plain HTML that any editor opens.
    • A click runs onClick() on the server, and Wicket renders the page again.
    • The field clicks keeps its value between requests, because Wicket keeps the page object for you.
    • A part you reuse on many pages is a Panel: again a Java class and an HTML file. Components and markup shows how.

    See the examples running

    HomePage.java

    public class HomePage extends WebPage {
        private int clicks;
    
        public HomePage() {
            add(new Link<Void>("count") {
                @Override
                public void onClick() {
                    clicks++;
                }
            });
            add(new Label("clicks", () -> clicks));
        }
    }

    HomePage.html

    <p>
      You clicked <span wicket:id="clicks">0</span> times.
      <a wicket:id="count">Click me</a>
    </p>
  2. Components for complex pages

    Pages and components are real Java objects with encapsulation, inheritance and events. Build a panel once and use it on every page, and bundle a component with its stylesheets, JavaScript and other resources into one reusable package.

    AddressPanel.java

    public class AddressPanel extends Panel {
        public AddressPanel(String id, IModel<Address> address) {
            super(id, new CompoundPropertyModel<>(address));
            add(new TextField<String>("street"));
            add(new TextField<String>("city"));
        }
    }
    
    // one component, used twice on the same form
    form.add(new AddressPanel("billing", billingAddress));
    form.add(new AddressPanel("shipping", shippingAddress));
  3. Ajax without writing JavaScript

    Update selected parts of a page from Java, without a single line of JavaScript. An Ajax request re-renders only the components you add to it, and Wicket comes with a large set of ready-made Ajax components.

    CounterPage.java

    Label count = new Label("count", () -> clicks);
    add(count.setOutputMarkupId(true));
    
    add(new AjaxLink<Void>("increment") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            clicks++;
            target.add(count);
        }
    });
  4. Secure by default

    URLs do not expose sensitive information and component paths are session-relative. Wicket supports a Content Security Policy without unsafe-inline: it adds a nonce to every header contribution itself, and you add only the sources your application needs. Configure the Content Security Policy shows how.

    MyApplication.java

    @Override
    protected void init() {
        super.init();
        // the default policy allows images from your own origin;
        // allow one extra image host
        getCspSettings().blocking()
            .add(CSPDirective.IMG_SRC,
                 "https://images.example.com");
    }
  5. Tested without a browser

    WicketTester renders your pages and components in a unit test, without a browser or a container, and checks their markup, attributes and contents. It clicks links and submits forms as a visitor would.

    HomePageTest.java

    WicketTester tester = new WicketTester(new MyApplication());
    tester.startPage(HomePage.class);
    tester.assertLabel("clicks", "0");
    
    tester.clickLink("count");
    tester.assertLabel("clicks", "1");

Also included

  • Translations in over 25 languages
  • Safe use of multiple tabs and windows
  • Injection with CDI, Spring and Guice
  • Jakarta EE integration
  • Component-local JavaScript and CSS

Coming from Spring MVC, Jakarta Faces or Vaadin? Why component-oriented compares Wicket with request-based and other component frameworks, what it gains and what it costs, and the glossary gives each Wicket term with what other frameworks call it.

Built with Wicket

Many applications run on Wicket without saying so. These say so, collected through the Built with Wicket feed. Submit your own project.

Learn Wicket in five lessons

The lessons build one application, from an empty project to a tested page with Ajax.

Start here in the documentation

  1. Build your first application
  2. Give every page the same layout
  3. Build a form that saves data
  4. Update a page with Ajax
  5. Test a page with WicketTester

Built by the people who use it

Apache Wicket is developed in the open by volunteers. Answer a question on the users list, report a bug with a quickstart, improve the documentation, or send a pull request to apache/wicket: a committer reviews it, and it goes out with the next release of its line.

How to contribute · Community and support