私のフォームは次の要素で構成されています。
- 検索条件を入力するためのicefacesテキストフィールド。
- icefacesコマンドボタン(検索)を使用して、部分的に送信し、一致したユーザーの新しいリストをdivに入力します。
- 他の2つのicefacesテキストフィールド、フォーム全体を送信するときは、それらの値が必要です。
要件:ユーザーがテキスト入力フィールドでEnterキーを押すと、検索ボタンがクリックされます(ボタンがマウスでクリックされると、自動的に部分的に送信されます)
これが私が試したことです:
<ice:inputText id="recipient" value="#{myBean.searchValue}" size="60"
onkeydown="handleEnter(event,this.form);" >
</ice:inputText>
<ice:commandButton id="find" value="Find" action="#{myBean.findEmployees}" partialSubmit="true"
>
<f:ajax execute="@this" render="employees" />
</ice:commandButton>
JSメソッド:
function handleEnter(event,form){ if (event.keyCode == 13){ document.getElementById(form.name+':find').click(); } }
生成されたiceコマンドボタン:
<input type="submit" value="Find" style="width: 60px;" onfocus="setFocus(this.id);" onclick="iceSubmitPartial(form, this, event);return false;" onblur="setFocus('');" name="myForm:find" id="myForm:find" class="iceCmdBtn findButton">
問題:ユーザーがEnterキーを押すと、検索ボタンが呼び出されますが、フォーム全体が送信されるため、他の2つのテキストフィールドに必要な検証エラーが表示されます。
フォーム全体が送信される理由と、そのような問題の処理方法を教えてください。