命令按钮不提交“输入”仅在IE中按下< 9 [英] Command button does not submit on "enter" press only in IE < 9
问题描述
我有2个< h:form>
元素彼此跟随(不是另一个),例如:
I have 2 <h:form>
elements following each other (not one within the other) such as :
<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>
这很好用。我遇到的问题是在IE 8中(我假设其他旧版本)在第一种形式时,我点击了我的键盘上的输入键,表单未提交。页面重新加载,但甚至没有调用#{searchBar.search1}
。
This works fine. The problem I have is that in IE 8 (and I'm assuming other older versions) when in the first form and I hit the "enter" key on my keybord, the form is not submitted. The page reloads, but does not even call #{searchBar.search1}
.
这一切都很奇怪这是第二种形式的工作正常。我没有收到错误消息,也没有从浏览器获得任何反馈。
The odd thing in all this is that this works fine in the second form. I don't get an error message nor do I get any feedback from the browser.
在我的支持bean中,我有类似的东西:
In my backing bean I have something of the sort :
public String search1() {
System.out.println("submitting form1");
return "success";
}
public String search2() {
System.out.println("submitting form2");
return "success";
}
当使用点击回车键时,我甚至没有使用它支持bean。
When using hitting the "enter" key, I don't even make it to the backing bean.
但是:当我点击提交按钮(用鼠标)时,一切正常。
But : when I do "click" the submit button (with the mouse) everything works.
对此有任何见解将不胜感激!
Any insight on this would be greatly appreciated!
推荐答案
如果只有表格,这是一个MSIE特定的异常一个< input type =text>
字段。唯一的解决方法是添加另一个< input type =text>
字段,该字段由CSS隐藏 display:none;
。
This is a MSIE specific anomaly in case of forms with only one <input type="text">
field. 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>
此问题与JSF无关。
这篇关于命令按钮不提交“输入”仅在IE中按下< 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!