About Us
Contact us

Facebook profile


A First Look at the Wicket Framework
Bookmark and Share

Page 1 Page 2 Page 3 Page 4

To be able to manipulate the user-entered values, the onSubmit() method of the wicket.markup.html.form.Form method must be overwritten. The onSubmit() method of the PizzaForm class follows:

protected void onSubmit() { PizzaModel pizzaModel = (PizzaModel) getModelObject(); setResponsePage(new WicketTestConfPage(pizzaModel)); }

Of interest here are the getModelObject() and requestCycle.setResponsePage() methods.
The getModelObject() method call obtains an instance of the Model object populated with the user-entered values. The requestCycle.setResponsePage() directs the browser to a new page. The WebPage instance that the browser will be redirected to must have a constructor taking an instance of the Model object as a parameter.

Here is the source for the confirmation page:

public class WicketTestConfPage extends WebPage

  public WicketTestConfPage(PizzaModel pizzaModel)
    add(new Label("crust", pizzaModel.getCrust()));
    add(new Label("pepperoni", new Boolean(pizzaModel.getPepperoni())
    add(new Label("sausage", new Boolean(pizzaModel.getSausage()).toString()));
    add(new Label("onions", new Boolean(pizzaModel.getOnions()).toString()));
    add(new Label("greenPeppers", new Boolean(pizzaModel.getGreenPeppers())
    add(new Label("comments", pizzaModel.getComments()));
All it does is create some labels to displaying the values of the Model object it takes as its sole constructor parameter.

Here are the relevant sections of the corresponding HTML file:

<table style="text-align: left; width: 427px; height: 112px;" border="1"
    cellpadding="0" cellspacing="0">
            <td style="font-weight: bold; text-align: right;">Crust:</td>
            <td><span wicket:id="crust">Hello</span></td>
            <td style="font-weight: bold; text-align: right;">Toppings:</td>
            <td>Pepperoni:&nbsp; <span wicket:id="pepperoni"></span>
            Sausage:&nbsp;<span wicket:id="sausage"></span>&nbsp;Onions: &nbsp;<span
                wicket:id="onions"></span>&nbsp;Green Peppers:&nbsp;<span
            <td style="font-weight: bold; text-align: right;">Comments:</td>
            <td><span wicket:id="comments"></span></td>

Of interest here are the <span> fields, these correspond to the labels in the WicketTestConfPage java class. You may notice some of the <span> tags have text inside them, this text will only be displayed in the browser when mocking up the pages, when displayed from the Wicket application, they will display whatever value the corresponding Label instances have.

After entering some arbitrary data and submitting the form, here is how the confirmation page looks:
Pizza builder confirmation page.


Wicket provides the following advantages over other web application frameworks:

Some disadvantages of Wicket:
Page 1 Page 2 Page 3 Page 4


Thanks to Gregg Bolinger, Johan Compagner and Eelco Hillenius for providing valuable feedback.


Java EE 6 Development With NetBeans 7
Java EE 6 Development With NetBeans 7

Java EE 6 with GlassFish 3 Application Server
Java EE 6 with GlassFish 3 Application Server

JasperReports 3.5 For Java Developers
JasperReports 3.5 For Java Developers