Problem

By default, Wicket generated URL is suck, long and ugly, and contains the fully qualified class name of the page. It look something like this :

http://localhost:8080/mkyong?wicket:bookmarkablePage=:com.mkyong.page.ResultPage&url=google.com
Note
What the heck is “wicket:bookmarkablePage” in URL, and why Wicket generated such an ugly URL structure? After deployed Wicket application to client site, many clients’ emails sending in and complaint about the ugly bookmarkablePage URL structure. It’s just sound wired and doesn’t make sense at all, what is the advantages of this? Are you going to ask my visitor to bookmark this ugly URL address?.

Solution

Fortunately, Wicket provides “URL mounting” feature to cloak the ugly URL bookmarkable pages to a specific path in our application.

To fix it, change the default ugly URL structure in Wicket application class, “init()” method, as follows

import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.target.coding.QueryStringUrlCodingStrategy;
import com.mkyong.user.SuccessPage;
 
public class WicketApplication extends WebApplication {
 
	@Override
	protected void init() {
		super.init();
		mount(new QueryStringUrlCodingStrategy("result",ResultPage.class));
	}
}

Uses QueryStringUrlCodingStrategy() to mount “ResultPage.class” page to a neat and friendly URL structure “result“, see output :

http://localhost:8080/mkyong/result?url=google.com
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
[ Read More ] You can find more similar articles at Apache Wicket Tutorials