Skip to content

Categories:

BookmarkablePageLink - make sure your PageParameters are initialized

Something I just came across today whilst creating a BookmarkablePageLink, was an issue where it appeared that the parameters I was passing to the constructor where not being passed to the new instance. I orginally had something like:

PageParameters map = new PageParameters();
BookmarkablePageLink link = new BookmarkablePageLink(”team”, TeamPage.class, map);
if (testCondition) {
map.put(TeamtPage.TEAMID, teamId);
}

This did not work. However a quick look at the source code for BookmarkablePageLink reveals why:
this.parameters = pageParametersToMiniMap(parameters);

It is essentially creating a new Map which is stored in the class, and hence when adding items to the Map after calling the constructor does not work. Obvously the good code is:

PageParameters map = new PageParameters();
if (testCondition) {
map.put(TeamtPage.TEAMID, teamId);
}
BookmarkablePageLink link = new BookmarkablePageLink(”team”, TeamPage.class, map);

Anyhow whats the moral of this? make sure you have the source to Wicket in your IDE as one of the great things about this framework is that you can look at the very understandable source and see what is happening straight away

Share and Enjoy:
  • Digg
  • Print this article!
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Slashdot

Posted in wicket. Tagged with , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.