私は最初に入力フィールド(ルックアップ)のみを表示し、ページの他の部分はレンダリングされないVFページを持っています。ユーザーがフィールドに値とタブを入力すると、
onchange
イベントは( actionSupport
)経由でコントローラを呼び出します。再レンダリング中に、ページの他の部分は入力値に基づいて条件付きでレンダリングされます。
私のVFページの一部です:
これは完全に動作しています…ユーザーがフィールドから外れて、onchangeイベントが発生した場合。しかし、ユーザーが値を入力した後で単に戻り値を押した場合(この時点でページ上の唯一のコントロールである可能性が高いため)、ページ全体が送信されています。この結果、reRenderの代わりにページ全体がリフレッシュされ、アクション(
{!checkSalesOrderAccount}
)は決して実行されません。私は次のような動作が欲しいです:
- ユーザーがenterを押すと、フォームは送信されません。
- ユーザーがenterを押すと、
{!checkSalesOrderAccount}
アクションが呼び出されます。
Note that there is no submit button on the page, but I assume
that pressing enter is firing the form’s submit action? Which leads
me to one more requirement/constraint: all of this code is part of
an which is shared by a couple of pages; the tag is in the
containing page, not in the component, so I can’t use the form’s
onsubmit
, even if it would work for the return
key.
inputFieldの onkeypress
イベントハンドラが押されているのを見ることを検討しています。 actionSupport
を
{!checkSalesOrderAccount}
にスワップすると、キーの押下がキャンセルされて(
code> actionFunction
をクリックします。しかし、これを行うより良い方法があるのだろうかと思います。
単純なjavascript関数を使用して、標準入力がEnterキーでフォームを送信しないようにし、代わりに
apex:actionFunction
を実行します。
<script>
function submitListener(e){
var keynum = 0;
if (window.event){
keynum = window.event.keyCode;
}
else if (e.which){
keynum = e.which;
}
//Here we check whether the Enter button was pressed
if (keynum == 13){
onFormSubmit();
}
}
</script>