Jdeveloper 12.1.2
I have a requirement to go to an external webiste. I have found a number of ways to do this, but wonder which is best, in regards to:
1. Whether it is considered a legacy way of doing it (or the method will be discontinued).
2. Whether it is the most robust and predictable.
I am wondering of the three choices (I was able to find) which is the best one to use
- Button "Destination" set to value in Java
Java
private String goURL = “www.google.com” :
public String getGoURL() {
return “www.google.com” ;
}
JSF Page
<af:button text="destination...."
id="b2"
partialSubmit="true"
immediate="true"
destination="#{backingBeanScope.myBean.goURL}"
targetFrame="_blank"/>
- Java Invoking JavaScript
JAVA
public String goURL() {
String url = “www.google.com” ;
ExtendedRenderKitService erks = (ExtendedRenderKitService) Service.getRenderKitService(FacesContext.getCurrentInstance(), ExtendedRenderKitService.class);
StringBuilder script = new StringBuilder();
script.append("window.open('" + url + "');");
erks.addScript(FacesContext.getCurrentInstance(), script.toString() );
return null; }
JSF
<af:button text="Update Personal Information"
id="b3"
targetFrame="_blank"
partialSubmit="true"
immediate="true"
action="#{backingBeanScope.myBean.goURL}"/>
- JAVA invoking externalContext
JAVA
public String openURL(){
String goURL = “www.google.com” :
try{
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.redirect(goURL );
} catch(Exception e){
throw new FacesException("Redirection failed");
}
return null ;
}
JSF
<af:button text="openURL"
id="b3"
targetFrame="_blank"
partialSubmit="true"
immediate="true"
action="#{backingBeanScope.myBean.openURL}"/>