开发者

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 t开发者_开发技巧o 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

<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.js (Parent sandbox)

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 (JSP on child sandbox)

<html>
<head>
   <script type="text/javascript" src="http://localhost:8080/webapp/scripts/app/load.js"></script>
</head>

<body onload="Load.init();"></body>
</html>

load.js (Child sandbox)

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();
         };
      }
   };
}();

signin.js

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'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.

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.


may be the example "Simple Tasks"(AIR) can help u

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜