my form consists of following elements:
Requirement: i want when user press enter in the text input field, that find button gets clicked (when the button gets clicked by mouse it makes partial submit automatically)
so here's what i tried:
<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>
the JS method:
function handleEnter(event,form){
if (event.keyCode == 13){
document.getElementById(form.name+':find').click();
}
}
the generated ice command button:
<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">
ISSUE: what happens is the when user press enter, find button is invoked, but whole form gets submitted, so a required validation error appears for the other two text fields.
please advise why whole form is getting submitted, and how to handle such issue.
to get the enter button working fine with partial submit, i have to remove the 'required=true' tag from the inputs and make the validation with JS.