Parameters are displayed in the URL only if the page is classified or the specific link is bookmarked.
If you create a Link that moves to the page using setResponsePage(Page) (passing the page instance) instead of setResponsePage(Class<Page>, PageParameters) (passing the page class), the created link will not point to the classified version of the page, but in the case of condition.
To do this, you should not call the super(PageParameters) constructor (so that there is not enough information on the page to create a stateless URL).
In this example, you can go to SecretPage through two different links, one stateless, bookmarked, and other state.
SecretPage also has two constructors. One gets PageParameters and calls super , passing it. The other receives the value directly through the construcor parameter and does not pass it to super (if he called super(new PageParameters().add("message",message) , as in a commented line, it automatically redirects the bookmarked URL).
HomePage.java:
public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { add(new BookmarkablePageLink<Void>("bookmarkable", SecretPage.class, new PageParameters().add("message", "This message will appear in the URL"))); add(new Link<Void>("instance") { @Override public void onClick() { setResponsePage(new SecretPage("This message will NOT appear in the URL")); } }); } }
homepage.html:
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" > <body> <p><a wicket:id="bookmarkable">Bookmarkable link (stateless)</a></p> <p><a wicket:id="instance">Hidden parameters link (stateful)</a></p> </body> </html>
SecretPage.java
public class SecretPage extends WebPage { public SecretPage(PageParameters parameters) { super(parameters); init(parameters.get("message").toString("No message!")); } public SecretPage(String message) {
SecretPage.html
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" > <body> <p wicket:id="feedback"></p> <p><a wicket:id="back">BACK</a></p> </body> </html>
And in order to have a simple url like http://host/app/secret , you have to install it. You can do this in your WebApplication class.
WicketApplication.java
public class WicketApplication extends WebApplication { @Override protected void init() { super.init(); mountPage("home", getHomePage()); mountPage("secret", SecretPage.class); } public Class<HomePage> getHomePage() { return HomePage.class; } }
This example uses Wicket 1.5 (still RC4.2), and to work with 1.4.x some changes are needed (some methods and classes have been renamed or moved to different packages), but the idea is the same.