Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


Wicket uses Java classes to represent pages. Most of the time, you will create a subclass of WebPage:

Code Block
package org.wicket-wiki.example;
public class MyPage extends WebPage {}

And the markup:

Code Block
     ... content ...

You can reach this class under the following URL:


See Newuserguide / An interactive HelloWorld for a verbose example.

Pages are objects

Because pages are Java objects, you can create new instances and pass them around like any other object. You can use the constructor, for instance:

Code Block
public class MyPage extends WebPage {
   public MyPage(String name) {
      add(new Label("name", name));


Code Block
titleLink handler in
public void onClick() {
   // creating another page instance and going to that page
   setResponsePage(new MyPage("keuner"));

Because the entire page stays in the session, you do not have to put client related state in the session explicitly.

Page types

In Wicket pages can have two characteristics, they can be bookmarkable and / or stateless.

Bookmarkable pages are pages which have a constructor with no arguments or a constructor that accepts a PageParameters argument (which wraps any query string parameters for a request). In case the page has both constructors, the constructor with PageParameters will be used only if there are parameters in the URL, though you should not rely on this behavior and both constructors should do the same thing.

Code Block
public class MyPage extends WebPage...
    public MyPage() {
        this(new PageParameters());

    public MyPage(final PageParameters parameters) {

See also Bookmarkable pages and links.

Stateless pages are pages which are bookmarkable and contain only stateless components and stateless behaviors. Unlike stateful page Wicket doesn't store stateless pages in Session (to be precise in a PageMap). See Stateless pages for more information.

Here is a simple table showing how bookmarkability and statelessness are related:





may be



may be

may be

Page URLs

For this discussion of page URLs I found it useful to distinguish between three "types" of page URLs:

  1. URL to page class (requesting it will cause page creation)
  2. URL to page instance (requesting it retrieves page instance from Session where it is stored)
  3. URL to component on a page (requesting it calls component event handler)

Stateful bookmarkable pages

For stateful bookmarkable pages URL to page class will look like :
http://<...>/?wicket:bookmarkablePage=<page class>
This type of pages can also be "mounted". Mounting means assigning a URL to bookmarkable page (not-bookmarkable pages cannot be mounted).

Code Block
public class MyApplication extends WebApplication...
    protected void init() {
        mountBookmarkablePage("mountedURL", MyPage.class);
        mountBookmarkablePage("login", LoginPage.class);

For mounted pages URL to page class will look like:

URL to page instances for stateful bookmarkable pages will look like:
http://<...>/?wicket:interface=<data to get page from Session>
URL to components on the page will look like:
http://<...>/?wicket:interface=<data to get page from Session including path to component>

Not-bookmarkable pages

There are no URLs to page class for stateful not-bookmarkable pages (note that not-bookmarkable always implies stateful). Since non-bookmarkable pages don't have constructor which can be used by Wicket to create them, they can be only created explicitly in user code. The only way user can go to not-bookmarkable page is to be redirected from bookmarkable page with code like:

Code Block
add(new Link("linkToNotBookmarkablePage") {
    public void onClick() {
        setResponsePage(new MyNotBookmarkablePage(... some constructor parameters ...));

URL to page instances and components for not-bookmarkable pages is the same as for bookmarkable pages, i.e.:

Stateless bookmarkable pages

For stateless bookmarkable pages (note that stateless always implies bookmarkable) URL to page class will look the same as for bookmarkable stateful pages, i.e.:
http://<...>/?wicket:bookmarkablePage=<page class> or http://<...>/mountedURL
Since stateless pages instances are not stored in Session, there are no URLs to instances of stateless pages.
URL to components on stateless pages will look like:
http://<...>/?wicket:bookmarkablePage=<page class>&wicket:interface=<path to component>

titleThis is description of URLs as they are used by default

The way URLs look for bookmarkable pages may be changed by using different "URL coding strategies" (though the logic of page creation remains the same). For example see HybridUrlCodingStrategy.

Code Block
public class MyApplication extends WebApplication...
    protected void init() {
        mount(new HybridUrlCodingStrategy("mypage", MyPage.class));

Pages creation

As mentioned above, all pages are objects and can be created with java "new" keyword.

Stateful bookmarkable pages are created by Wicket (using IPageFactory) every time they are requested by URL pointing to page class. This means that you do not control how many different instances of page are created and there is no out-of-the-box solution to do that.

Not-bookmarkable page are not created by Wicket. They can only be created explicitly by user.

Stateless bookmarkable pages are created every time they are requested (though it's not something you should rely on).