From: smk s. <ste...@gm...> - 2014-02-02 08:14:52
|
Hi again, I updated the source and now the Java class is initialized as it should however I was not able to call any method from the corresponding class. In more details. *This is the testing html* <html> <body> <OBJECT id="obj" classid='clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'> </OBJECT> <script> var obj = document.getElementById("obj"); if(obj != null){ document.write("Object Loaded!"+"<br>"); document.write(obj.playVideo("http://url.com")); }else{ document.write("Not Loaded"); } </script> </body> </html> *This is the Java class* public class WMP { public WMP(){ Log.info("Loaded"); } public String playVideo(String s){ return "Start playing from"+s; } } The object is mapped correctly and initialized correctly However when the method is called I get this exception *Exception* DEBUG [main] write: Object Loaded!<br> ERROR [main] runtimeError: message=[Java method "playVideo" was invoked with [object HTMLObjectElement] as "this" value that can not be converted to Java type WMP.] sourceName=[.......objecttagtesting.html from (4, 9) to (12, 10)] line=[8] lineSource=[null] lineOffset=[0] INFO [main] Caught script exception ======= EXCEPTION START ======== Exception class=[net.sourceforge.htmlunit.corejs.javascript.EvaluatorException] com.gargoylesoftware.htmlunit.ScriptException: Java method "playVideo" was invoked with [object HTMLObjectElement] as "this" value that can not be converted to Java type WMP. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:689) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602) ...........[SNIP] Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Java method "playVideo" was invoked with [object HTMLObjectElement] as "this" value that can not be converted to Java type WMP. at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:81) at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1029) at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1076) ...........[SNIP] Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Java method "playVideo" was invoked with [object HTMLObjectElement] as "this" value that can not be converted to Java type WMP. at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:81) at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1029) at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1076) ...........[SNIP] ======= EXCEPTION END ======== If I initialize the ActiveXObject as var wmi = new ActiveXObject("WMPlayer.OCX.7"); The above example works flawlessly 2014-01-31 smk smk <ste...@gm...>: > Thanks that was fast!!!! > > I wll update the sources and i 'll let you know. > > > |