/** * Evaluates a script in the page context and returns the result. * * @param script * @param application */ public static Object eval(String script, Application application) { if (application == null) { throw new IllegalArgumentException("application is null."); } HostApplet applicationHostApplet = null; for (HostApplet hostApplet : hostApplets) { if (hostApplet.getApplication() == application) { applicationHostApplet = hostApplet; break; } } if (applicationHostApplet == null) { throw new IllegalArgumentException("No applet is hosting the given application."); } try { JSObject window = JSObject.getWindow(applicationHostApplet); return window.eval(script); } catch (Throwable throwable) { throw new UnsupportedOperationException(throwable); } }
public void init() { JSObject window = (JSObject) JSObject.getWindow(applet); document = (JSObject) window.getMember("document"); cookies = new HashMap();
JSObject window = JSObject.getWindow(applicationHostApplet); return window.eval(script); } catch (Throwable throwable) {
public void run() { while (audioInputStream == null) { try { // politely waiting for capture Thread to finish with audioInputStream. Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // reset to the beginnning of the captured data try { audioInputStream.reset(); } catch (Exception ex) { reportStatus(res.getString("Unable_to_reset") + ex); return; } if (post) postAudio(audioType, urlString); if (containingApplet != null) { JSObject window = (JSObject)JSObject.getWindow(containingApplet); window.call("callOpener", new Object[]{"clickReloadLink", window}); window.call("close", null); } } // end of run }; // end of saveAndPostThread
private void save(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save try { String methodName = getParameter("datawrite"); if (methodName.indexOf('(') > 0) { methodName = methodName.substring(0, methodName.indexOf('(') - 1); } JSObject win = JSObject.getWindow(this); win.call(methodName, new Object[]{getData()}); } catch (Throwable t) { TextFigure tf = new TextFigure("Fehler: " + t); AffineTransform tx = new AffineTransform(); tx.translate(10, 20); tf.transform(tx); getDrawing().add(tf); } }//GEN-LAST:event_save
JSObject window = (JSObject) JSObject.getWindow(containingApplet); window.call("callOpener", new String[]{"disableSubmitForGrade"}); window.call("callOpener", new String[]{"disableSave"});
private void load(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_load try { String methodName = getParameter("dataread"); if (methodName.indexOf('(') > 0) { methodName = methodName.substring(0, methodName.indexOf('(') - 1); } JSObject win = JSObject.getWindow(this); Object result = win.call(methodName, new Object[0]); if (result instanceof String) { setData((String) result); } } catch (Throwable t) { TextFigure tf = new TextFigure("Fehler: " + t); AffineTransform tx = new AffineTransform(); tx.translate(10, 20); tf.transform(tx); getDrawing().add(tf); } }//GEN-LAST:event_load // Variables declaration - do not modify//GEN-BEGIN:variables
@Override protected void finished() { Container c = getContentPane(); boolean isLiveConnect; try { Class.forName("netscape.javascript.JSObject"); isLiveConnect = true; } catch (Throwable t) { isLiveConnect = false; } loadButton.setEnabled(isLiveConnect && getParameter("dataread") != null); saveButton.setEnabled(isLiveConnect && getParameter("datawrite") != null); if (isLiveConnect) { String methodName = getParameter("dataread"); if (methodName.indexOf('(') > 0) { methodName = methodName.substring(0, methodName.indexOf('(') - 1); } JSObject win = JSObject.getWindow(DrawLiveConnectApplet.this); Object data = win.call(methodName, new Object[0]); if (data instanceof String) { setData((String) data); } } c.validate(); } }.start();
JSObject window = (JSObject) JSObject.getWindow(containingApplet); window.call("callOpener", new String[]{"enableSubmitForGrade"}); window.call("callOpener", new String[]{"enableSave"});