1

私は Adob​​e Air を初めて使用するので、質問は明らかかもしれませんが、何日も苦労して仕事をすることができませんでした。

必要なコードが埋め込まれた air を使用してアプリケーションを構築し、開始プロセスを構築し、デプロイされた Web アプリケーションからランタイムに必要なリソースを取得して、メイン アプリケーションに挿入しようとしています。2 つの異なるサンドボックス (メインのエア アプリ用の親サンドボックスと、デプロイされたアプリ用の子サンドボックスとしての iframe) を構築しました。これが私がやったことです:

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 (親サンドボックス)

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

ロード (子サンドボックスの JSP)

<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 (子サンドボックス)

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

上記の「The Line」で、URLだけを挿入する、ajaxでコンテンツを取得してコンテンツを渡す、eval()-edコンテンツを親サンドボックスに渡すなど、さまざまなことを試しました。いずれにせよ、式 'App.Signin' [undefined] の結果はコンストラクターではありません。さて、Air Introspector の DOM 要素でも Not available です。

onLoad イベントの前に JavaScript をロードすることについてどこかで読んだことを覚えていますが、どこを正確に思い出すことができず、さらに重要なことに、それを実装する方法がわかりません。onLoadの前に私のアプローチではありませんか?

または、この問題を解決するためのガイドを教えてください。

4

1 に答える 1

0

「Simple Tasks」(AIR) が役立つ例かもしれません

于 2011-01-03T14:31:53.073 に答える