/** * Returns a JSObject for the window containing the given applet. * * @param paramApplet the paramApplet * @return result Object * @throws JSException in case or error */ public static JSObject getWindow(final Applet paramApplet) throws JSException { return new JSObject(Window_); }
/** * Returns a JSObject for the window containing the given applet. * * @param paramApplet the paramApplet * @return result Object * @throws JSException in case or error */ public static JSObject getWindow(final Applet paramApplet) throws JSException { return new JSObject(Window_); }
/** * Calls a JavaScript method. * Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript. * * @param methodName the name of the JavaScript method to be invoked * @param args an array of Java object to be passed as arguments to the method * @return result result of the method * @throws JSException in case or error */ public Object call(final String methodName, final Object[] args) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject call '" + methodName + "(" + Arrays.toString(args) + ")'"); } final Object jsResult = ScriptableObject.callMethod(scriptableObject_, methodName, args); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; }
/** * Calls a JavaScript method. * Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript. * * @param methodName the name of the JavaScript method to be invoked * @param args an array of Java object to be passed as arguments to the method * @return result result of the method * @throws JSException in case or error */ public Object call(final String methodName, final Object[] args) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject call '" + methodName + "(" + Arrays.toString(args) + ")'"); } final Object jsResult = ScriptableObject.callMethod(scriptableObject_, methodName, args); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; }
/** * Evaluates a JavaScript expression. * The expression is a string of JavaScript source code which will be evaluated in the context given by "this". * * @param expression the JavaScript expression * @return result Object * @throws JSException in case or error */ public Object eval(final String expression) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject eval '" + expression + "'"); } final Page page = Window_.getWebWindow().getEnclosedPage(); if (page instanceof HtmlPage) { final HtmlPage htmlPage = (HtmlPage) page; final ScriptResult result = htmlPage.executeJavaScript(expression); final Object jsResult = result.getJavaScriptResult(); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; } return null; }
/** * Evaluates a JavaScript expression. * The expression is a string of JavaScript source code which will be evaluated in the context given by "this". * * @param expression the JavaScript expression * @return result Object * @throws JSException in case or error */ public Object eval(final String expression) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject eval '" + expression + "'"); } final Page page = Window_.getWebWindow().getEnclosedPage(); if (page instanceof HtmlPage) { final HtmlPage htmlPage = (HtmlPage) page; final ScriptResult result = htmlPage.executeJavaScript(expression); final Object jsResult = result.getJavaScriptResult(); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; } return null; }