From: smk s. <ste...@gm...> - 2014-01-30 11:38:03
|
The question also posted by me at StackOverflow and is the following: I am using HtmlUnit and I am trying to provide custom implementation for ActiveXObjects. Although I can provide custom implementation when an ActiveObject is called through javascript by name e.g. var wmi = new ActiveXObject("WMPlayer.OCX.7"); I cannot do the same when the object is declared with its classid like <object id="PlayerEx2" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="200" width="200"> I have found these threads http://comments.gmane.org/gmane.comp.java.htmlunit.general/3894 and http://sourceforge.net/p/htmlunit/bugs/691/ that describe the same problem. Also it appears that it can be done using client.setHtmlObjectMap(htmlObjectToJavaMapping); however, I am using htmlunit 2.13 and I cannot find this method. Additionally I know that i could use jacob (java-com bridge) but jacob communicates with existing/installed com-objects. I wish to provide my own mock implementations. I could not find any other information on the subject. Could you please guide me on how this could be done? |
From: Ahmed A. <asa...@ya...> - 2014-01-30 12:11:33
|
HI, How about webClient.setActiveXObjectMap() Ahmed ________________________________ From: smk smk <ste...@gm...> To: htm...@li... Sent: Thursday, January 30, 2014 1:26 PM Subject: [Htmlunit-user] Map <bject> to custom JavaClass The question also posted by me at StackOverflow and is the following: I am using HtmlUnit and I am trying to provide custom implementation for ActiveXObjects. Although I can provide custom implementation when an ActiveObject is called through javascript by name e.g. var wmi =newActiveXObject("WMPlayer.OCX.7"); I cannot do the same when the object is declared with its classid like <object id="PlayerEx2"classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"height="200"width="200"> I have found these threads http://comments.gmane.org/gmane.comp.java.htmlunit.general/3894 andhttp://sourceforge.net/p/htmlunit/bugs/691/ that describe the same problem. Also it appears that it can be done using client.setHtmlObjectMap(htmlObjectToJavaMapping); however, I am using htmlunit 2.13 and I cannot find this method. Additionally I know that i could use jacob (java-com bridge) but jacob communicates with existing/installed com-objects. I wish to provide my own mock implementations. I could not find any other information on the subject. Could you please guide me on how this could be done? ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: smk s. <ste...@gm...> - 2014-01-30 18:11:52
|
First of all thank you for your answer. webClient.setActiveXObjectMap(activeXMap) works and works fine IF the ActiveXObject is created with this declaration in javascript var wmi = new ActiveXObject("WMPlayer.OCX.7"); However it doesn't work when it gets created with the object tag e.g <object id="PlayerEx2" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="200" width="200"> 2014-01-30 Ahmed Ashour <asa...@ya...>: > HI, > > How about webClient.setActiveXObjectMap() > > Ahmed > > ------------------------------ > *From:* smk smk <ste...@gm...> > *To:* htm...@li... > *Sent:* Thursday, January 30, 2014 1:26 PM > *Subject:* [Htmlunit-user] Map <bject> to custom JavaClass > > The question also posted by me at StackOverflow and is the following: > > I am using HtmlUnit and I am trying to provide custom implementation for > ActiveXObjects. Although I can provide custom implementation when an > ActiveObject is called through javascript by name e.g. > > var wmi = new ActiveXObject("WMPlayer.OCX.7"); > > I cannot do the same when the object is declared with its classid like > > <object id="PlayerEx2" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="200" width="200"> > > I have found these threads > http://comments.gmane.org/gmane.comp.java.htmlunit.general/3894 and > http://sourceforge.net/p/htmlunit/bugs/691/ that describe the same > problem. > Also it appears that it can be done using > > client.setHtmlObjectMap(htmlObjectToJavaMapping); > > however, I am using htmlunit 2.13 and I cannot find this method. > Additionally I know that i could use jacob (java-com bridge) but jacob > communicates with existing/installed com-objects. I wish to provide my own > mock implementations. > I could not find any other information on the subject. Could you please > guide me on how this could be done? > > > ------------------------------------------------------------------------------ > WatchGuard Dimension instantly turns raw network data into actionable > security intelligence. It gives you real-time visual feedback on key > security issues and trends. Skip the complicated setup - simply import > a virtual appliance and go from zero to informed in seconds. > > http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > ------------------------------------------------------------------------------ > WatchGuard Dimension instantly turns raw network data into actionable > security intelligence. It gives you real-time visual feedback on key > security issues and trends. Skip the complicated setup - simply import > a virtual appliance and go from zero to informed in seconds. > > http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > |
From: Ahmed A. <asa...@ya...> - 2014-01-31 05:28:39
|
Hi, Fixed in SVN, thanks for reporting. Ahmed ________________________________ From: smk smk <ste...@gm...> To: Ahmed Ashour <asa...@ya...>; htm...@li... Sent: Thursday, January 30, 2014 9:11 PM Subject: Re: [Htmlunit-user] Map <bject> to custom JavaClass First of all thank you for your answer. webClient.setActiveXObjectMap(activeXMap) works and works fine IF the ActiveXObject is created with this declaration in javascript var wmi =newActiveXObject("WMPlayer.OCX.7"); However it doesn't work when it gets created with the object tag e.g <object id="PlayerEx2"classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"height="200"width="200"> |
From: smk s. <ste...@gm...> - 2014-01-31 11:38:05
|
Thanks that was fast!!!! I wll update the sources and i 'll let you know. |
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. > > > |
From: asashour <asa...@ya...> - 2014-02-05 00:39:48
|
Hi, The last fix was for the class and properties, now it is fine for methods as well. Please get latest code and hint if you have any issue. Ahmed stergios wrote > 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. > > 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 -- View this message in context: http://htmlunit.10904.n7.nabble.com/Map-bject-to-custom-JavaClass-tp32980p33061.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |
From: smk s. <ste...@gm...> - 2014-02-05 09:46:40
|
Ahmed Thank you very much for the update. I just tested the code and works as it expected. Stergios 2014-02-05 asashour <asa...@ya...>: > Hi, > > The last fix was for the class and properties, now it is fine for methods > as > well. > > Please get latest code and hint if you have any issue. > > Ahmed > > > stergios wrote > > 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. > > > > 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 > > > > > > -- > View this message in context: > http://htmlunit.10904.n7.nabble.com/Map-bject-to-custom-JavaClass-tp32980p33061.html > Sent from the HtmlUnit - General mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > > http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |