I have a problem when call applet method from javascript..
I used this function to load applet
$("body").append('<applet id="asra" name="asra" code="akorbulsoundrecorder/recorder.class" archive="http://localhost/.../java/akorbulSoundRecorder.jar" width="300" height="400" MAYSCRIPT></applet>');
and I can call applet function javascript there is no problem;
but
alert(1);
document.asra.stopCapture();
alert(2);
alert(1) and document.asra.stopCapture(); is working but alert(2) doesn't work?
stopCapture function
public void stopCapture() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
if(!test)
jso.call("__appletRecord", new String[] {"stop"});
targetDataLine.stop();
targetDataLine.close();
String filename = audioFile.getAbsolutePath();
try {
final ArrayList < String > cmd = getCommand(filename);
if(!test)
jso.call("__appletRecord", new String[] {"convertMp3"});
Main.main(cmd.toArray(new String[cmd.size()]));
if(!test)
jso.call("__appletRecord", new String[] {"deleteWav"});
//audioFile.delete();
} catch (IOException e1) {
System.err.println(e1.getMessage());
}
try {
// Establish a connection
if(!test)
jso.call("__appletRecord", new String[] {"upload"});
httpUrlConnection = (HttpURLConnection) new URL("http://localhost/.../java/upload.php").openConnection();
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setRequestMethod("POST");
outputStream = httpUrlConnection.getOutputStream();
// Buffered input stream
fileInputStream = new BufferedInputStream(new FileInputStream("c:\\junk.mp3"));
// Get the size of the image
totalBytes = fileInputStream.available();
// Loop through the files data
for (int i = 0; i < totalBytes; i++) {
// Write the data to the output stream
outputStream.write(fileInputStream.read());
bytesTrasferred = i + 1;
}
// Close the output stream
outputStream.close();
if(!test)
jso.call("__appletRecord", new String[] {"success"});
// New reader to get server response
serverReader = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream()));
// Read the servers response
serverResponse = "";
while ((response = serverReader.readLine()) != null) {
serverResponse = serverResponse + response;
}
if(!test)
jso.call("__appletPHPResponse", new String[] {response});
// Close the buffered reader
serverReader.close();
// Close the file input stream
fileInputStream.close();
} catch (IOException ex) {
jLabel1.setText(ex.getMessage());
}
return null; // nothing to return
}
});
}
document.asra.someMethod();is working? Do you print something to STDOUT? If not add print at the beginning and at the end of methodsomeMethod(). Then run your JS code, open the Java Console and see the result. I believe that you will find exception that will explain you everything.