Open public URL programatically using javascript in ADF

Scenario:  Suppose you want to open some public URL like www.google.com programatically from you ADF application.

Write the following code in bean on Action event.

    public void openURL(ActionEvent actionEvent) {
        openUrlInNewWindow("http://www.google.com");
    }
 
 
    private void openUrlInNewWindow(String url) {
           if (url != null) {
               String javaScriptText =
                   "window.open('" + url + "', 'Window', 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');";
               writeJavaScriptToClient(javaScriptText);
           }
       }
 
    public static void writeJavaScriptToClient(String script) {
          FacesContext fctx = FacesContext.getCurrentInstance();
          ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
          erks.addScript(fctx, script);
      }

Comments

Popular posts from this blog

Setting up the environment for Angular2 and Hello World Example in Angular2

Build a Simple ReactJS application using react-cli

Showing number of rows or row count on top and bottom of table in ADF.