I'm using richfaces and jsf.
I've a form which look like that :
<h:form><h:inputText id="id1" value="#{mybean.1}" />
<h:commandButton id="button1" action="#{otherBean.goToPage1}">
<f:ajax execute="id1" render="id1" />
</h:commandButton>
<h:inputText id="id2" value="#{mybean.2}" />
<h:commandButton id="button2" action="#{otherBean.goToPage2}">
<f:ajax execute="id2" render="id2" />
</h:commandButton>
<h:inputText id="id3" value="#{mybean.3}" />
<h:commandButton id="button3" action="#{otherBean.goToPage3}">
<f:ajax execute="id3" render="id3" />
</h:commandButton>
</h:form>
My problem is that when I'm writing something on the input "id3" and I press ENTER, the commandButton for "id1" is reading.
Or what I want is, when I press Enter in an input, the good commandButton is reading (input1 for button1, input2 for button2, ...)
For my project I have to use just one form.
Have anyone an idea ?
I find what was missing :
<h:inputText id="id1" value="#{mybean.1}"
onkeyup="if (event.keyCode == 13) { #{rich:element('button1')}.click();}"
onkeydown="if (event.keyCode == 13) { #{rich:element('button1')}.click();}"/>
<h:commandButton id="button1" action="#{otherBean.goToPage1}">
<f:ajax execute="id1" render="id1" />
</h:commandButton>
the two lines "onkeyup" and "onkeydown" have to be add on every inputText and #{rich:element('button1')} replace document.getElementById('button1')
For Internet Explorer I add : onblur="#{rich:element('button1')}.click();"
<h:inputText id="id1" value="#{mybean.1}"
onkeyup="if (event.keyCode == 13) { #{rich:element('button1')}.click();}"
onkeydown="if (event.keyCode == 13) { #{rich:element('button1')}.click();}"
onblur="#{rich:element('button1')}.click();" />
It works on IE8 and IE11.