-
3 Jan 2011 6:12 AM #1
How to load external ExtJS built app into Air sandbox
How to load external ExtJS built app into Air sandbox
I'm new to Adobe Air, so the question might be obvious, but I couldn't get to work for days of struggling with it.
I'm trying to build an application with air which has the embedded required code, to build the starting process and fetching runtime-required resources from the deployed web application and inject it in the main application. I've build the two different sandboxes (parent sandbox for main air app, and an iframe as child sandbox for deployed app). here's what I've done:
air.html
load.js (Parent sandbox)HTML Code:<html> <head> ... <script type="text/javascript" src="/scripts/app/load.js"></script> </head> <body id="baseBody" onload="Load.init();"> <iframe id="sandbox" sandboxRoot="http://localhost:8080/webapp/" style="width:0;height:0;display:none;" ondominitialize="Load.bridge();"> </iframe> </body> </html>
load (JSP on child sandbox)PHP Code:Load = function() {
return {
sandbox: null,
bridge: function() {
document.getElementById('sandbox').contentWindow.parentSandboxBridge = {
initChild: function() {
sandbox = document.getElementById('sandbox').contentWindow.childSandboxBridge;
sandbox.loadSignin();
sandbox.buildParent();
},
buildBase: function() {
signin = new App.Signin({
...
});
new Ext.air.Window({
...
items: [signin],
...
});
},
importing: function(url) {
// Creating Script tag and Append it to Head tag
}
};
},
init: function() {
document.getElementById('sandbox').src = './load';
}
};
}();
load.js (Child sandbox)HTML Code:<html> <head> <script type="text/javascript" src="http://localhost:8080/webapp/scripts/app/load.js"></script> </head> <body onload="Load.init();"></body> </html>
signin.jsPHP Code:Load = function() {
return {
init: function() {
window.childSandboxBridge = {
loadSignin: function() {
// "The Line"
window.parentSandboxBridge.importing('/path/to/signin/script/on/web/server');
},
buildParent: function() {
window.parentSandboxBridge.buildBase();
}
window.parentSandboxBridge.initChild();
};
}
};
}();
I've tried different thing on "The Line" mentioned above, such as inserting just the url, getting the content by ajax and passing the content, passing the eval()-ed content to parent sandbox. and no matter which, I got Result of expression 'App.Signin' [undefined] is not a constructor. And well, it is Not available in the DOM element in Air Introspector as well.PHP Code:Ext.namespace('App.Signin');
App.Signin = Ext.extend(Ext.form.FormPanel, {
initComponent: function() {
var formPanelConfig = {
items: [{
...
}]
};
Ext.apply(this, Ext.apply(this.initialConfig, formPanelConfig));
App.Signin.superclass.initComponent.apply(this, arguments);
}
});
I remember reading somewhere about loading javascript before onLoad event but I couldn't recall where exactly, and more important I don't know how to implement it. Isn't my approach before onLoad?
Or could you please show me the guide to solve this problem.
-
4 Jan 2011 8:41 AM #2
Hi pestilencia,
According to the Adobe Help you cannot access dynamically created scripts.
To communicate to external scripts you have to use the sandbox bridge (as you created). The properties there are the only accessible ones.
But even if you map the App variable in the signin.js to a childSandboxBridge property, its properties (like Signin) are not accessible. Why, I'm not 100% sure.
But I've got another solution. Create the instance of App.Signin in the non-application sandbox content and return it to the application sandbox.
load.js (Parent sandbox)
load (JSP on child sandbox)Code:Load = function() { var signin; return { sandbox: null, bridge: function() { document.getElementById('sandbox').contentWindow.parentSandboxBridge = { initChild: function() { sandbox = document.getElementById('sandbox').contentWindow.childSandboxBridge; signin = sandbox.loadSignin(someOptionalConfigurationObject); sandbox.buildParent(); }, buildBase: function() { signin = new App.Signin({ ... }); new Ext.air.Window({ ... items: [signin], ... }); }, importing: function(url) { // It is a useless function now // Creating Script tag and Append it to Head tag } }; }, init: function() { document.getElementById('sandbox').src = './load.html'; } }; }();
load.js (Child sandbox)HTML Code:<html> <head> <!-- we need the extjs script files as well here, because we're loading local content --> <!-- http://localhost:8080/webapp/ can be left out --> <script type="text/javascript" src="http://localhost:8080/webapp/scripts/app/signin.js"></script> <script type="text/javascript" src="http://localhost:8080/webapp/scripts/app/load.js"></script> </head> <body onload="Load.init();"></body> </html>
Hope that helps!Code:Load = function() { return { init: function() { window.childSandboxBridge = { loadSignin: function(config) { // "The Line" window.parentSandboxBridge.importing('/path/to/signin/script/on/web/server'); return new App.Signin(config); }, buildParent: function() { window.parentSandboxBridge.buildBase(); } }; // consider the changes in these lines here (order) window.parentSandboxBridge.initChild(); } }; }();
Greets
makanaProgramming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)
Enhanced ExtJS adapter for Adobe AIR
-
9 Jan 2011 12:36 PM #3
Hello Makana,
Thanks for your fast response. I was so busy with something else and honestly I've forgotten about checking the thread!
Anyway, I've had changed the structure a little bit and made it working by change the way "importing: function()" from:
toCode:document.createElement()...
I believe your ways should be better than my work around solution? Isn't it?Code:Ext.get('predefined-empty-script-element').update(responseText);
All in all, I just changed the code as you proposed now, but I'm getting 'comp.getItemId' [undefined].
TypeError: Result of expression 'comp.getItemId' [undefined] is not a function.
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 12765
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 8937
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 12782
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 12775
at app:/scripts/extjs/3.3.1/ext-base-debug.js : 458
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 12776
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 12701
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 16936
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 5185
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 10626
at app:/scripts/extjs/3.3.1/ext-base-debug.js : 246
at app:/scripts/extjs/3.3.1/ext-base-debug.js : 246
at app:/scripts/extjs/3.3.1/ext-base-debug.js : 246
at app:/scripts/extjs/3.3.1/ext-base-debug.js : 246
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 5706
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 5686
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 4068
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 3675
at app:/scripts/extair/3.3.0/ext-air-wo-xlayer-debug.js : 5656
at app:/scripts/app/load.js : 50
at app:/scripts/app/load.js : 101
at app:/scripts/extjs/3.3.1/ext-all-debug.js : 5949
undefined at undefined : undefined
And load.js, line 50 would be: "items: [signin]"
Then what do you believe is wrong with the code?
Best Regards,
Khosrow
-
11 Jan 2011 11:24 AM #4
If your version works, it is good if you want to create the signin form with the local extjs framework and so with the overrides that you have in your air app. With my version the form is created remote with the remote extjs loaded.
I don't want to say which version is best.
Your error means, that your "signin" object is no component. i.e. the signin form instance is not created remote. Make sure, you have (additionally to load.js and signin.js) the extjs framework included in your remote load.html.
That's very important for my solution. If you take yours it doesn't matter.Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)
Enhanced ExtJS adapter for Adobe AIR
-
14 Jan 2011 1:57 PM #5
Similar Threads
-
How to compile an ExtJs App into Adobe Air ?!?
By scaron in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 1 Nov 2010, 7:21 AM -
Air DateField (AIR runtime security violation for JavaScript code in sandbox)
By courtneyt in forum Ext.air for Adobe AIRReplies: 7Last Post: 30 Dec 2009, 6:19 PM -
The easiest way to convert an j2ee app to an AIR app
By ngontro86 in forum Ext.air for Adobe AIRReplies: 0Last Post: 28 Mar 2009, 3:40 AM -
AIR runtime security violation with sandbox issu!! plz help me.
By Erica in forum Ext.air for Adobe AIRReplies: 8Last Post: 20 Feb 2009, 3:23 PM -
Raptr: Adobe AIR app built with Ext 2.2
By funkadelic in forum Community DiscussionReplies: 3Last Post: 7 Oct 2008, 11:26 AM


Reply With Quote