Reputation: 195
I am using richFaces 3.3.3.
I need to make a menuItem open a new tab with a simple URL ... for example google.com. For now I tried this code:
HtmlMenuItem menuItem = new HtmlMenuItem();
menuItem.setid("id");
menuItem.setValue("My menu link new tab");
menuItem.setSubmitMode("server");
menuItem.setTarget("_blank");
menuItem.setOnClick("document.location.href='www.gooogle.com'");
But this makes my current tab is redirected to google, and open a new tab with the context in which I was. I want to stay in my place, and the new tab "_blank" go to google.
I tried to replace onClick by onComplete, but this make new tab enter in my context too. But don't execute I tried to put an HtmlOutputLink as children of my menuItem, but not execute a click for outPutLink .. execute a click for menuItem ...
HtmlMenuItem menuItem = new HtmlMenuItem();
menuItem.setid("id");
menuItem.setValue("My menu link new tab");
HtmlOutputLink cLink = new HtmlOutputLink();
cLink.setTarget("_blank");
cLink.setValue("www.google.com");
menuItem.getChildren().add(cLink);
Upvotes: 0
Views: 1380
Reputation: 802
You can use only a OutputLink, something like:
HtmlOutputLink cLink = new HtmlOutputLink();
cLink.setValue("http://www.google.com");
cLink.setTarget("_blank");
HtmlOutputLabel label = new HtmlOutputLabel();
label.setValue("Google");
cLink.getChildren().add(label);
So, just add your link on some component. Maybe HtmlMenuItem use javascript to open the page and your browser see it like a Pop-up.
Upvotes: 3
Reputation: 107
Are you using this? <ui:include src="#{bean.link}"/>
Your question is not really precise, so I just could come up with this idea ...
Upvotes: 0