Command button is not sent to "enter" only in IE <9
I have 2 <h:form> elements following each other (not one of them), for example:
<h:form id="innerHeaderForm1"> <h:inputText value="#{searchBar.eventname}" /> <h:commandButton action="#{searchBar.search1}" value="click1"/> </h:form> <h:form id="innerHeaderForm2"> <h:inputText id="last" value="#{searchBar.personname}"/> <h:commandButton action="#{searchBar.search2}" value="click2"/> </h:form> It works great. The problem is that in IE 8 (and I assume other older versions), when in the first view, and I press the enter key on my keyword, the form is not submitted. The page reloads, but does not even call #{searchBar.search1} .
The insignificant thing in all of this is that it works well in the second form. I do not receive an error message and do not receive feedback from the browser.
In my bean support, I have something like:
public String search1() { System.out.println("submitting form1"); return "success"; } public String search2() { System.out.println("submitting form2"); return "success"; } When using the enter keypress, I donโt even do it with bean support.
But: when I do the โclickโ submit button (with the mouse), everything works.
Any understanding of this would be greatly appreciated!
This is a specific MSIE anomaly in the case of single-field forms <input type="text"> . The only fix is โโto add another <input type="text"> field, which is hidden by CSS display: none; .
<h:form id="innerHeaderForm1"> <h:inputText value="#{searchBar.eventname}" /> <h:inputText style="display: none;" /> <h:commandButton action="#{searchBar.search1}" value="click1"/> </h:form> This issue is not related to JSF.