例えば、あるページの本体構造を定義するMainFormのUI定義ファイルを以下のように定義されていたとします。
MainForm.ui.xml
- <g:verticalpanel>
- <g:label>header</g:label>
- <g:horizontalpanel>
- <g:label>left</g:label>
- <g:label>center</g:label>
- <g:label>right</g:label>
- </g:horizontalpanel>
- </g:verticalpanel>
このヘッダ領域に表示する内容を別のUIBinderで下記のように設計したとします。
HeaderArea.ui.xml
- <ui:uibinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
- <ui:style>
- </ui:style>
- <g:htmlpanel>
- <h2>試作システムのヘッダ</h2> </g:htmlpanel>
- </ui:uibinder>
このようにUIBinderで定 義したUIを一部は、下記のようにすることでMainFormに記述することができます。
MainForm.ui.xml(変更後)
- <ui:uibinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:o="urn:import:org.ochilab.client.widget">
- <ui:style>
- </ui:style>
- <g:verticalpanel>
- <o:headerarea>
- <g:horizontalpanel>
- <g:label>left</g:label>
- <g:label>center</g:label>
- <g:label>right</g:label>
- </g:horizontalpanel>
- </o:headerarea></g:verticalpanel>
- </ui:uibinder>
こ のように、定義したUIBinderのクラスのパッケージをimportによりXMLのNamespaceに関連付け、利用するクラス名をタグ名として記 述することで、呼び出すことができます。こ れは、インタフェース部分の分業をはかる際に非常に強力になりますので、そういった意味でもUIBinderはおすすめだと思います。
0 件のコメント:
コメントを投稿