Platform 4.2 以上が必要
...
Code Block |
---|
<modifications document="nxml"> <remove select="id(‘‘MyWindow’’)"> </modifications> |
このマクロを呼び出す場合: |
onCommand= |
”macro://mymacro.execute()" |
次の例では、パラメータを使用するマクロの使用方法を示します。
マクロ:
Code Block
Code Block |
---|
<modifications document=”nxml”> <remove select="id(''{0}'')"> </modifications> このマクロを呼び出す場合: |
onCommand=”macro://mymacro.execute (‘Window1’) |
マクロの定義の概要
次に、マクロの定義に使用される基本フォーマットを示します。
...
次の例では、パラメータを使用したマクロへの呼び出しを示します。
Code Block |
---|
<macro:macroCall name="generic-dialog" xmlns:macro="http://nexaweb.com/macro" > <macro:parameter>ThisIt</macro:parameter> <macro:parameter>true</macro:parameter> <macro:parameter>true</macro:parameter> <macro:parameter>false</macro:parameter> <macro:parameter>Answer</macro:parameter> </macro:macroCall> |
次の例では、パラメータを使用したマクロへのイベントハンドラの呼び出しを示します。
<button onCommand="macro://generic-dialog.execute( 'ThisIt', 'true', 'true', 'false', 'Answer' )" />
<button onCommand="macro://generic-dialog.execute( 'ThisIt', 'true', 'true', 'false', 'Answer' )" />
...
<button onCommand="macro://generic-dialog( {id('myDialogTitleField')/@text}, 'true', 'true', 'false', {MyDataDocument:id('myTextField')/@text} )" />
プログラムを使用したマクロの定義と呼び出し
次に、プログラムを使用してマクロを定義する例を示します。
Code Block |
---|
MacroContainer macroContainer = ClientSession.getMacroContainer(); Macro macro = macroContainer.createMacro ("<xu:modifications xmlns:xu=\"http://nexaweb.com/xupdate\" document=\"nxml\">" + " <xu:append select=\"/nxml/rootPane[1]\">" + " <dialog>" + " <label text=\"Call me Ishmael.Some years ago- never mind how long precisely...\" />" + " </dialog>" + " </xu:append>" + "</xu:modifications>" ); macroContainer.putMacro("nexaweb-examples-herman-melville-dialog", macro); |
次に、プログラムを使用してマクロを呼び出す例を示します。
Code Block |
---|
MacroContainer macroContainer = clientSession.getMacroContainer(); Macro melvilleMacro = macroContainer.getMacro( "nexaweb-examples-herman-melville-dialog" ); melvilleMacro.execute(); Macro genericXUpdateMacro = macroContainer.getMacro( "nexaweb-examples-generic-xupdate" ); genericXUpdateMacro.execute( new Object [] { "remove-element", "id('anElementId')", "" } ); genericXUpdateMacro.execute( new Object [] { "append", "/nxml/rootPane[1]", "<dialog><label text=\"Mylabel\"/></dialog>" } ); |
マクロのデバッグとトラブルシューティング
マクロをデバッグするには、アプリケーションのクライアントコンフィギュレーションファイル、nexaweb-client.xmlで、次のようにマクロのデバッグロギングを有効にします。
Code Block |
---|
<log-configuration> <log name="Macro" log-level="debug"/> </log-configuration> |
...
次はマクロログからのアウトプットサンプルになります。(全てのクライアント側のロギングはブラウザのjava コンソールに行きます) :
...