アプリケーション・ブートストラップ
ナビゲータの「フレーム」クラスを選択してJClientアプリケーションを実行し、「実行」を選択すると、main()
メソッドがアプリケーションをブートストラップします。 アプリケーションはDatabindings.cpx
ファイルのエントリに基づいて、BindingContext
を開始してdataControls
をロードします。 次に初期化されたdataControls
でbindingContext
をpanelBinding
に渡し、UIModel
コンポーネント・バインディングを作成します。
次のコード・リストはブートストラップ・コードを示しています。これはHRスキーマのEmployeesおよびDepartments表の選択された列を使用して、フォーム作成ウィザードによって作成されます。
// bootstrap application
JUMetaObjectManager.setBaseErrorHandler(new JUErrorHandlerDlg());
// Lookup the *.cpx file and create all data controls listed in this file.
JUMetaObjectManager mgr = JUMetaObjectManager.getJUMom();
// Use the definition classes provided by JClient. Change only if you do not want to use custom DefClasses.
mgr.setJClientDefFactory(null);
// Create a new binding context that extends java.util.Hashtable.
BindingContext ctx = new BindingContext();
// Get user connection information if available. If not, display logon dialog.
ctx.put(DataControlFactory.APP_PARAM_ENV_INFO, new JUEnvInfoProvider());
// Set locale to the default locale of the JVM.
ctx.setLocaleContext(new DefLocaleContext(null));
// Load data binding container data binding file.
HashMap map = new HashMap(4); map.put(DataControlFactory.APP_PARAMS_BINDING_CONTEXT, ctx);
mgr.loadCpx("DataBindings.cpx", map);
// Get handle to the Business Components application module.
DCDataControl app = (DCDataControl)ctx.get("model_AppModuleDataControl");
app.setClientApp(DCDataControl.JCLIENT);
// Despite the following line of code, attribute sets and fetches are normally
// performed in one batch operation. This requires only one network round
// trip. Attributes that aren't needed are not loaded to the client. The code
// line below is added only when using the JClient Form wizard. Declaratively creating
// the frame, starting with an empty form wizard does not add the following lines.
app.getApplicationModule().fetchAttributeProperties(new String[] {"DepartmentsView1", "EmployeesView3"}, new String[][] {{"DepartmentId", "DepartmentName" }, {"EmployeeId", "FirstName", "LastName" "DepartmentId" }}, null);
// Initialize application root class.
FormDepartmentsView1EmployeesView3 frame = new FormDepartmentsView1EmployeesView3();
// Set binding context to the frame.
frame.setBindingContext(ctx);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
フレームの初期化
フレームは、デフォルトではどの引数も必要としないそのコンストラクタによって初期化されます。 アプリケーションのバインディング・コンテキストは、フレームのsetBindingContext()
メソッドに渡されます。
このフレームを初期化すると、複数のデータ・コントロールのデータにバインドされるコンポーネントを含むUIModel定義に基づいて、panelBinding
オブジェクト(JUPanelBinding)になります。パネル・バインディングの作成は、Swingコンポーネントへのデータ・バインディングと、データ・パネルの連鎖を可能にするJClientの重要な機能です。
データ・パネルまたはフォームを配置した後、フォームにfetchAttributeProperties()
メソッドを定義することでJClientアプリケーションのパフォーマンスを改善できます。 これにより、フォームはバッチモードで属性値をフェッチします。
Copyright © 1997, 2004, Oracle. All rights reserved.