すべての Rich UI ハンドラーを単一の HTML ファイルにデプロイする代わりに、実行時の Rich UI ハンドラー・コードのダウンロードを制御することができます。 これは大規模なアプリケーションの場合、スケーラビリティーとパフォーマンスにおいてかなりの利点があります。
それぞれの動的ロードは非同期です。 ロードの完了時に応答するリスナー関数をコードし、ロードが完了するまでは、ユーザーは Web ページとの対話を続行します。
// a simple declaration
mySecondary Secondary{};
// the as keyword, in a usage described later in this topic
mySecondary Secondary = theHandler as Secondary;
handler MainHandler type RUIhandler {onConstructionFunction = start }
function start()
// Load the first page
DynamicLoader.loadHandler("myPkg.Secondary");
end
型の参照を指定し、動的ロード用の EGL デプロイメント記述子を構成しない場合、型の参照によって、参照されるハンドラーは即時ダウンロード・コードに組み込まれます。
後述のサンプル・コードで示すとおり、型の参照は、動的にロードされるハンドラーで、コードがフィールドまたは関数に直接アクセスする場合に必要です。 ただし、コードが、動的にロードされるハンドラーの initialUI プロパティーに割り当てられたウィジェット配列にのみアクセスする場合は、型の参照は不要です。
動的ロードは、ModuleLoaderService という EGL 専用サービスにより実行時に処理されます。 この製品の将来のバージョンで変更される可能性がある内部の詳細を処理するため、このサービスは変更しないでください。
動的ローダーのサンプル使用については、『EGL Dojo ウィジェット』を参照してください。特にそこで説明されている GalleryDynamicLoading.egl ファイルの説明を参照してください。
この関数はハンドラーをロードします。
この関数は、ハンドラー型定義をロードしますが、ハンドラー・インスタンスはロードしません。 この関数は、ランタイムのパフォーマンスを向上させるために使用できます。 例えば、ハンドラー・タイプをアプリケーションで使用可能にするとしても、ハンドラー自体は、ハンドラーを必要とするメニュー項目をユーザーがクリックした場合にのみ作成されるようにできます。
この関数は、ハンドラーをアンロードしますが、そのハンドラーのインスタンスは破棄しません。 EGL ライブラリーはアンロードできません。これはアプリケーションが終了するまで使用できます。
たいていの場合、メモリーは EGL ランタイム・コードにより解放されます。 ただし、『Rich UI メモリー管理』のトピックでは、さらに高度なメモリー管理を行う方法について説明します。
この関数により、動的ローダーの内部で生じていることを示す詳細が表示されます。 これはメインのハンドラーの on-construction 関数に設定することができます。
function start()
// Set handler for the event that the page has been loaded
DynamicLoader.loadDoneListeners ::= processLoadDone;
DynamicLoader.loadHandler("myPkg.Secondary");
end
function processLoadDone (event HandlerLoadedEvent in)
// attach the initialUI widgets to the current page.
// this step does not require use of a type reference.
div.children = event.initialUI;
// access a function in the loaded handler
theHandler any = event.theHandler;
// the use of a handler (or other container) of type any requires
// a type reference so that your code can directly access a field
// or function that is embedded in that container
if (theHandler isa Secondary)
p1 Page1 = theHandler as Secondary;
p1.doTask();
end
end
record HandlerLoadedEvent
// The name of the handler
name String;
// The widgets defined by the Rich UI handler.
initialUI Widget[];
// A reference to the Rich UI handler
theHandler any;
end
delegate
LoadDoneListener (event HandlerLoadedEvent in)
end
delegate
LoadFailListener (handlerName string in, msg string in)
end
function start()
DynamicLoader.loadFailListeners ::= processLoadFail;
DynamicLoader.loadHandler("myPkg.Secondary");
end
Function processLoadFail (handlerName string in, msg string in)
Syslib.writeStdErr(handlerName + “ failed to load. ” + msg);
end
delegate
LoadInfoListener (handlerName string, resourceName string,
code string, msg string)
end
function start()
DynamicLoader.loadInfoListeners ::= processLoadInfo;
DynamicLoader.loadHandler("myPkg.Secondary");
end
function processLoadInfo (handlerName string,
resourceName string, code string, msg string)
if (code == DynamicLoader.INFO_UNLOAD)
Syslib.writeStdErr(resourceName + “ unloaded.”);
end
end
function createPage1() returns (Secondary)
anotherPage1 Secondary = new Secondary{};
return(anotherPage1);
end
handler MainHandler type RUIhandler {onConstructionFunction = start }
// error!
anotherPage1 Page1 = new Secondary{};
end
EGL デプロイヤーがハンドラー用の HTML ファイルを作成する場合、このファイルには Rich UI アプリケーションで使用されるすべての CSS ファイルのリストが含まれます。 CSS ファイルは動的にはロードされません。
{ includeFile = "config/includeDojo.html" }