ページ・アイテムの値の変更時に確認のダイアログを表示し、そのダイアログでキャンセルをクリックしたときに元の値に戻すようにします。
以下のような動作です。
設定の[Enter]を押すと送信はオフにします。ページの送信は、ページ・アイテムの値の変更イベントとは関係なく実行されます。また、ページ・アイテムがページに1つだけの場合は[Enter]を押すと送信がオフでもEnterを押すとページの送信が行われるため、このような実装はできません。
ページが開いたときのページ・アイテムP1_VALUEの値を保存しておきます。
ページ・プロパティのJavaScripitのファンクションおよびグローバル変数の宣言に以下を記述します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ページ・アイテムの変更をキャンセルした時に戻す値。 | |
var prevValue = $v("P1_VALUE"); |
ページ・アイテムP1_VALUEに動的アクションを作成します。
タイミングのイベントは、ページ・アイテムのデフォルトである変更を選択します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apex.message.confirm("本当に変更しますか?", | |
function(okPressed) { | |
if (!okPressed) { | |
// 第4引数にtrueを与え、変更イベントの発生を抑止する。 | |
$s("P1_VALUE", prevValue, null, true); | |
} | |
else | |
{ | |
// ページ・アイテムの変更をキャンセルした時に戻す値。 | |
prevValue = $v("P1_VALUE"); | |
} | |
} | |
); |
今回作成したAPEXアプリケーションのエクスポートを以下に置きました。
https://github.com/ujnak/apexapps/blob/master/exports/cancel-and-revert.zip
Oracle APEXのアプリケーション作成の参考になれば幸いです。
完