6 Replies Latest reply: Sep 5, 2013 12:44 AM by Kreetz RSS

    How to access a file via Applet and JavaScript

    user10047839
      I want to copy one file on the client machine from one place to another place from a Java Bean.
      To do this I created an applet and a Java Bean as follows:
      import java.applet.*;
      public class FileUtils extends Applet {
          public void copyFile(String src, String dest)  {
                //
          }
          private String source, destination; // setters/getters are there of course
          public void copyFile(ActionEvent actionEvent) { // Bean
              FacesContext fctx = FacesContext.getCurrentInstance();
              ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
              String command = "var s = '"+ source +"'; var d ='" + destination +"'; " +  " document.fileUtilsApplet.copyFile(s, d); ";
              erks.addScript(fctx, command);
          }
      Then I added the APPLET tag referencing the above class in the page fragment:
                      <f:verbatim>
                          <applet code="FileUtils.class" name="fileUtilsApplet" height="30"
                                  archive="/context-root/Applet.jar"
                                  width="200">
                          </applet> 
                      </f:verbatim>
      From the Java console I can see the jar is successfully downloaded, but when the code in the bean is executed, the JavaScript code does not seem to do anything, as if the "copyFile" public method was not called at all and no output in the Java Console as well.

      Note that I already followed the guidelines at http://www.oracle.com/technetwork/developer-tools/adf/learnmore/71-adf-to-applet-communication-307672.pdf .

      Do you have any ideas?