Versions Compared


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

This was a problem I encounter while developing on wicket.  This example is based on wicket 1.2.4.

The problematic was the use of a pop-up to use for searching.  The search result are link that will make change the page under the pop-up to display the item clicked but without closing the pop-nor, nor we want to change it because we still want to access all the link.

This is the code to load the pop-up :

Code Block
PopupSettings popupSettings = new PageMap.forName("popuppagemap")).setHeight(500).setWidth(500);
PageParameters popupparameters = new PageParameters();
popupparameters.put("parent_page_map", getPage().getPageMap ().getName ());
add(new BookmarkablePageLink ("basicSearchLink", SearchPopUp.class, popupparameters).setPopupSettings(popupSettings));

As we can see, there is nothing new in this code except that we have to make sure to enter in the page parameters the name of the current pagemap.

Now here is the way to create the pop-up with a link that will make change the browser window (not the pop-up)

Code Block
String target = "wicket:default";
String parentPageMap = null;
if(pp != null)
    parentPageMap = (String)pp.get ("parent_page_map");
    if(parentPageMap != null)
Class pageClass = SomePage.class;
BookmarkablePageLink bpl = new BookmarkablePageLink("link", pageClass);
bpl.setPageMap (PageMap.forName (parentPageMap));
bpl.add(new SimpleAttributeModifier("target", target));

If we want the link to work, we have to put the pageMap in the BPL. Also, we have to modify the attribute "target" of the link to be sure it will modify the good window.

Now the not so instinctive thing about this is the parentPagMap name. It is that Wicket will not create a pagemap name by default. The default page map will have a name set to null. This is not a problem because we are able to fetch the pageMap with a null key. The problem is that we need to communicate to the window. Since the target is normally equal to the pageMap name, if the pageMap name is null, Wicket will set the to "wicket:default". This issue is linked with JIRA :

This code will be obsolete when the JIRA issue will be resolved so this page will need updating.