Versions Compared

Key

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

Bookmarkable vs non-bookmarkable pages

Pages can be constructed with any constructor when they are being used in a Wicket session, but if you wish to link to a Page using a URL that is "bookmarkable" (which implies that the URL will not have any session information encoded in it, and that you can call this page directly without having a session first directly from your browser), you need to implement your Page with a no-arg constructor or with 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.

...

A recommended approach is that bookmarkable pages do nothing in their default behaviour (construction time) that can harm you (like deleting records etc), and that everything you want to hide, should be either put in protected pages, or in handlers such as links and forms on the pages. Note that those handlers are protected too, as they can never be called directly without having created the page instance first.

Linking to pages can be done in multiple ways:

...

You can also use PageLink class that one can be used , in three ways:

Code Block
public PageLink(final String id, final Class c)

...

Code Block
    Link customize = new Link("customize")
    {
      public void onClick()
      {
        setResponsePage(new CustomizeProduct(imageID));
      }
    
      public boolean linksTo(Page page)
      {
        if (!(page instanceof CustomizeProduct))
          return false;
        CustomizeProduct typedPage = (CustomizeProduct) page;
        return typedPage.getImageID()==imageID();
      }
    };

As last Lastly, if your page has a default constructor or if you must push state to it that can be mapped into strings, then you could also use the BookmarkablePageLink with PageParameters. Then you push This results in pushing a bit more state to the client and youre url , and the URL's looks a bit different.