1 Reply Latest reply on Nov 8, 2010 3:31 AM by ilya_shaikovsky

    Using Javascript to open a window

    ibstmt

      In our old JSF application, we had menu items to run reports. The reports would open up in a second browser window. We had Java code to format the URL:

       

      public void runReport(String reportName) {
              String url = getReportURL(reportName); // format the URL needed to call the report server to run the report
              try {
                  FacesContext facesContext = FacesContext.getCurrentInstance();
                  String javaScriptText = "window.open('" + url + "', 'popupWindow', 'dependent=yes, menubar=yes, toolbar=yes, scrollbars=yes');";
                  // Add the Javascript to the rendered page's header for immediate execution
                  AddResource addResource = AddResourceFactory.getInstance(facesContext);
                  addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javaScriptText);
              } catch (Exception e) {
              }
          }

       

       

      In our RichFaces application, I want to create a menu item to do something similar. However, things like AddResource are part of the org.apache.myfaces.renderkit package, and are not available here. How can I do something similar with a RichFaces menu item? The menu item would simply have to pass the name of the report, and the method call would do the rest.