voyent
menuItem target="_blank"  XML
Forum Index -> Components
Author Message
vaughn_preddy

Joined: 08/Sep/2008 00:00:00
Messages: 20
Offline


Hi,
I have a menuitem
Code:
 <ice:menuItem value="yahoo" alt="open new window for yahoo"
  action="#{bean.redirectToYahoo}" target="_blank">
 


I know one can redirect to a url in the bean with the following code.


Code:
FacesContext context=FacesContext.getCurrentInstance();
 			ExternalContext externalContext=context.getExternalContext();
 			externalContext.redirect("http://www.yahoo.com");


The above code redirects the url to yahoo.

My question is how do you open a new window that points to yahoo.

[Email]
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


if you want to do it from the Java side, use
Code:
JavascriptContext.addJavascriptCall(FacesContext.getInstance(), "javascript_code")
where javascript_code should be something similar to Code:
window.open('http://www.yahoo.com', '_blank', 'some_other_options')


Check window.open method in a Javascript reference

And don't forget: since you're opening a new window, this is not a redirect anymore ... (and you might have some problems with popup blockers too).

Eduard
mark.collette


Joined: 07/Feb/2005 00:00:00
Messages: 1692
Offline


Are you sure you want to do a postback to the server, and then navigate to that external website? If you use the url attribute on menuItem, then the user would immediately browse to that external website.
[Email]
vaughn_preddy

Joined: 08/Sep/2008 00:00:00
Messages: 20
Offline


Thanks for the input with regard to the JavascriptContext.

For now it will do. Im sure my requirements will change at a later stage.
[Email]
asherwin

Joined: 27/Jun/2008 00:00:00
Messages: 108
Offline


mark.collette wrote:
Are you sure you want to do a postback to the server, and then navigate to that external website? If you use the url attribute on menuItem, then the user would immediately browse to that external website.
 


I'm trying to do the same type of thing, and ice:menuItem does not have a url attribute. Atleast, not according to the 1.7.2 TLD docs.

The link attribute appears to work though. Mind you, the TLD doc just describes it as "link"
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team