Red Hat Training

A Red Hat training course is available for Red Hat Virtualization

C.2.4. Red Hat Virtualization ユーザーインターフェイスプラグインブートストラップ

一般的なプラグインブートストラップシーケンスは、次の手順で設定されます。

手順C.1 プラグインブートストラップシーケンス

  1. 指定されたプラグインの pluginApi インスタンスを取得します
  2. ランタイムプラグイン設定オブジェクトを取得 (オプション)
  3. 関連するイベントハンドラー関数の登録
  4. UI プラグインインフラストラクチャーにプラグインの初期化を進めるよう通知します。
次のコードは、上記の手順を実際に示すものです。
// Access plug-in API using 'parent' due to this code being evaluated within the context of an iframe element.
// As 'parent.pluginApi' is subject to Same-Origin Policy, this will only work when WebAdmin HTML page and plug-in
// host page are served from same origin. WebAdmin HTML page and plug-in host page will always be on same origin
// when using UI plug-in infrastructure support to serve plug-in resource files.
var api = parent.pluginApi('MyPlugin');

// Runtime configuration object associated with the plug-in (or an empty object).
var config = api.configObject();

// Register event handler function(s) for later invocation by UI plug-in infrastructure.
api.register({
	    // UiInit event handler function.
		UiInit: function() {
				// Handle UiInit event.
					window.alert('Favorite music band is ' + config.band);
					    }
});

// Notify UI plug-in infrastructure to proceed with plug-in initialization.
api.ready();