Posts Tagged ‘wicket’

AppFuse 3.0 has been released. It refreshes used technologies (Java 7+, Spring 4, Spring Security 3.2) and adds a bunch of new (Bootstrap 3, PrimeFaces, wro4j, WebJars and finally Apache Wicket).

AppFuse logo

From the project home page:

AppFuse is a full-stack framework for building web applications on the JVM. It was originally developed to eliminate the ramp-up time found when building new web applications for customers. Over the years, it has matured into a very testable and secure system for creating Java-based webapps. At its core, AppFuse is a project skeleton, similar to the one that’s created by your IDE when you click through a wizard to create a new web project.

I you are looking for some foundation for your project or just would like to see how the same things look in different technologies you can give AppFuse a try. A quick start page should be a good starting point.

There is also a personal thread in this story. Steadfast readers can remember that over 3 years ago I started working on Wicket frontend for AppFuse. I definitely prefer working on backends, but I wanted to get know Wicket (and its famous ability to being tested without Selenium) better and an engagement in the AppFuse development seemed to be a good way to practice these skills. There are still places in a Wicket frontend which need to be polished, but the work is mostly done (what I’m happy about :) ).

As a summary of my work I can write that even Wicket (where all page logic is written in Java or Groovy classes – no more c:forEach tags!) cannot completely remove the pain which comes with the limitation of HTTP (which wasn’t designed for the “enterprise applications”) and differences between browsers (although with jQuery and Bootstrap it is much easier). In addition 3 years is a lot of time in IT and currently there are even more use cases where component-based server side frameworks aren’t the best solution to make a good looking, responsible, scalable and trendy UI. Maybe it is time to work on an AngularJS frontend ;).

I am currently working on a Wicket frontend for AppFuse. I wanted to get know Wicket better and AppFuse seemed to be a good start to make some “real” application. Besides educational benefits for me it should be helpful for AppFuse and Wicket communities as well. In this and following post I will try to describe some of the problems I’ve met on my way.

Generally speaking every Wicket page has to have corresponding markup (html file with placed components). Without it MarkupNotFoundException is thrown in runtime. Implementing Wicket frontend in AppFuse I have found some pages which don’t have corresponding view (like logout or reload cache) and making an empty markup looked at least artificial for me. I tried to find some information how to avoid it, but the most interesting results were some old pages from mailing list archive with broken subsequential links. After some time I’ve dug out TextTemplate. It was the simplest class I’ve found that allows to dynamically generate markup for a Wicket page. It requires to override only two methods: getString() – which returns page template and interpolate() which allows to parametrize template (in our case does nothing). Because I needed only empty template a skeleton implementation was enough.

public class EmptyMarkup extends TextTemplate {

    public String getString() {
        return "";

    public TextTemplate interpolate(Map<String, Object> variables) {
        return this;

Wicket very often uses interfaces which indicate that given class has it own custom implementation of given feature. In case of dynamic markup IMarkupResourceStreamProvider was a key. Sample page with empty markup could look like:

public class NoMarkupPage extends WebPage implements IMarkupResourceStreamProvider {

//normal page implementation

    public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
        return new EmptyMarkup();

It worked fine. It could be discussable if it’s worth to write new class and one additional method instead of the empty html file, but I’ve got to know some Wicket internals by the way of my digging and educational effect was achieved. Nevertheless I knew Wicket has some nice tricks, so a asked on the mailing list if there is a better way. The answer came very fast. Igor Vaynberg posted much more compact solution.

public class Logout extends WebPage {

    protected void onInitialize() {

        //some "business logic"

        //the key line
        throw new RestartResponseException(Login.class);