Open new Tab when button is clicked

yoav.str picture yoav.str · Aug 8, 2013 · Viewed 8.4k times · Source

using wicket I want to open a new tab when a button or link is clicked, how can I achieve it?

what I have managed to do is to open it in a pop up like this:

 PopupSettings popupSettings = new  PopupSettings("popuppagemap").setLeft(0).setHeight(500).setWidth(500).setHeight(0);

    // Popup example
final Link<Void> setPopupSettings = new BookmarkablePageLink<Void>("searchBtn", HomePage.class)
   .setPopupSettings(popupSettings);

but this opens it in a new window.

Answer

user1387075 picture user1387075 · Aug 10, 2013

no problem to open a link in a new tab: just add 'target="_blank"' to the link.

final Link<Void> link = new BookmarkablePageLink<Void>("link", HomePage.class){
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        tag.put("target", "_blank");
    }
};
add(link);