我有 2 个相互跟随的
元素(不是一个在另一个),例如:
<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 中(我假设还有其他旧版本),当我在第一个表单中按下键盘上的“enter”键时,表单不会提交。页面会重新加载,但甚至不会调用 #{searchBar.search1}
。
奇怪的是,这在第二种形式中工作得很好。我没有收到错误消息,也没有从浏览器收到任何反馈。
在我的支持 bean 中,我有这样的东西:
public String search1() {
System.out.println("submitting form1");
return "success";
}
public String search2() {
System.out.println("submitting form2");
return "success";
}
当使用按“enter”键时,我什至没有到达支持 bean。
但是:当我“单击”提交按钮(用鼠标)时,一切正常。
任何对此的见解将不胜感激!
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>
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.
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";
}
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!
发布评论
评论(2)
这是一种 MSIE 特定异常,适用于只有一个
字段的表单。唯一的修复方法是添加另一个由 CSS
display: none;
隐藏的字段。
此问题与 JSF 无关。
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 CSSdisplay: none;
.This problem is not related to JSF.
inputText
未收到id="eventName"
。The
inputText
did not receive anid="eventName"
.