A new Quarkus extension: Wicket
As you might expect from one of the earliest contributors to Apache Wicket, it is hard to let go of such a great product (especially if you work every day with it).
And if you also enjoy working with Quarkus, it is only logical that you want to combine the two of them. So I did.
I’ve crafted an extension for Quarkus for Wicket. This enables injection of CDI beans into your Wicket components, behaviors and sessions. It also configures Wicket based on the Quarkus profile (prod, dev, …).
Getting started with the extension
As the extension is as of yet not officially released, you have to mvn install
it into your local repository after checking out the source.
gh repo clone dashorst/quarkus-wicket && cd quarkus-wicket && mvn install
cd ..
mvn io.quarkus.platform:quarkus-maven-plugin:3.23.0:create \ ─╯
-DprojectGroupId=com.martijndashorst.quarkus \
-DprojectArtifactId=wicket-getting-started \
-Dextensions='io.quarkiverse.wicket:quarkus-wicket:999-SNAPSHOT,jdbc-h2,hibernate-orm-panache' \
-Dcode \
-Djava=21
cd wicket-getting-started
This generates a project with the following structure:
pom.xml
src/main/java/com/martijndashorst/quarkus/
MyApplication.java
MyEntity.java
MyPage.java
src/main/resources/
application.properties
import.sql
src/main/resources/META-INF/
web.xml
The MyApplication
class is the Wicket Application you use to configure Wicket and provide the home page to Wicket, which is the default page that gets rendered when the user hits your application.
The codestart defines that the MyPage
class is the home page and is automatically generated for you.
The MyEntity
class is a Panache ORM entity generated by the codestart.
The web.xml
file defines the servlet filter that directs traffic to Wicket.
The file import.sql
is the sql script generated by Panache to provide an initial filling for your database.
[!NOTE]
you should uncomment the lines in the import.sql script to get an initial database filling.
When you start the application using quarkus the following happens:
quarkus dev
2025-05-28 21:27:04,440 INFO [io.qua.hib.orm.dep.dev.HibernateOrmDevServicesProcessor] (build-13) Setting quarkus.hibernate-orm.database.generation=drop-and-create to initialize Dev Services managed database
********************************************************************
*** WARNING: Wicket is running in DEVELOPMENT mode. ***
*** ^^^^^^^^^^^ ***
*** Do NOT deploy to your live server(s) without changing this. ***
*** See Application#getConfigurationType() for more information. ***
********************************************************************
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2025-05-28 21:27:04,550 INFO [io.qua.wic.run.arc.ArcInjector] (Quarkus Main Thread) ArcComponentInjector initialized
2025-05-28 21:27:04,556 INFO [org.apa.wic.Application] (Quarkus Main Thread) [wicket.wicket-quarkus] init: Wicket core library initializer
2025-05-28 21:27:04,556 INFO [org.apa.wic.pro.htt.WebApplication] (Quarkus Main Thread) [wicket.wicket-quarkus] Started Wicket version 10.5.0 in DEVELOPMENT mode
2025-05-28 21:27:04,598 INFO [io.quarkus] (Quarkus Main Thread) wicket-getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.19.4) started in 0.300s. Listening on: http://localhost:8080
2025-05-28 21:27:04,598 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2025-05-28 21:27:04,598 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, jdbc-h2, narayana-jta, servlet, smallrye-context-propagation, vertx, wicket]
2025-05-28 21:27:04,599 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (vert.x-worker-thread-1) Live reload total time: 0.656s
And when you open the browser and go to http://localhost:8080, you get this image
Getting data into and from the database
So the import script takes care of getting the first data into the database.
Now we want to show that on the page in a list, so the MyPage
class gets the following code:
import java.util.List;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.LoadableDetachableModel;
public class MyPage extends WebPage {
private static final long serialVersionUID = 1L;
public MyPage() {
add(new ListView<MyEntity>("entities", LoadableDetachableModel.of(this::getEntities)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<MyEntity> item) {
item.add(new Label("field", item.getModel().map(MyEntity::getField)));
}
});
}
private List<MyEntity> getEntities() {
return MyEntity.listAll();
}
}
This creates a ListView
and adds a Label
component for each entity found in the database.
I had to add a getter/setter to MyEntity
in order to bind the getter to the label.
This also needs some markup to go with it:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org" lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>
<body>
<h1>My Page</h1>
<ul>
<li wicket:id="entities"><span wicket:id="field"></span></li>
</ul>
</body>
</html>
So if you refresh the page now, this will show the 3 entities that have been added to the database using the import script as shown in the following screen shot.
Conclusion
In this article I presented you with the Quarkus Wicket extension. I showed how to use that to generate a Quarkus + Wicket + Hibernate + Panache application to display a list of entities on a Wicket page.
The Quarkus Wicket extension is a very young technology, and comes with some limitations you can read in the project’s documentation.
Now go ahead and try Wicket and Quarkus yourself!