View Full Version : Calling ExtJs method in Applet using JsObject

14 Aug 2013, 6:51 AM

I am embedding applet in an ExtJs window. I have a functionality where in i need to invoke a function written in the window from applet, but this doesnt seem to work with the below code.

Ext.onReady(function () { Ext.create('Ext.window.Window', {
title : "iframe",
width : 300,
height: 300,
layout : 'fit',

items : [{
xtype : "component",
autoEl : {
tag: 'applet',
archive: 'resources/helloworld.jar',
code: 'HelloWorld',
codebase: "."
sayHello : function(content) {

I tried to use the same applet with a simple html code which worked perfectly.


<html><title>The Hello, World Applet</title>
function sayHello(content) {
<applet archive="helloworld.jar" code="HelloWorld" width="320" height="120"/>


public void paint(Graphics g) { try {
JSObject window = JSObject.getWindow(this);
Object[] args = new String[] { "Hello World from Javascript" };
window.call("sayHello", args);
catch(Exception e) {
g.drawString(e.getMessage(), 10, 10);
g.drawString("Hello world! :: "+new Date(), 10, 25);

Please let me know what changes are to be done to get the function invoked in ExtJs Window.


Gary Schlosberg
19 Aug 2013, 1:23 PM
I'm know little Java, but seems like a scope issue. Thinking that the JSObject.getWindow() call in your applet needs to be modified to get the Ext.window.Window scope instead of the global window?

19 Aug 2013, 1:29 PM
Why not communicate with a controller instead of a view?

Appname.GetApplication().getController('Controllername').doSomething() will probably work, provided you have setup your application correctly.