命令按钮不会在“输入”时提交仅在 IE 中按 < 9

发布于 2025-01-04 11:43:36 字数 988 浏览 2 评论 0 原文

我有 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间你老了 2025-01-11 11:43:36

这是一种 MSIE 特定异常,适用于只有一个 字段的表单。唯一的修复方法是添加另一个由 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 无关。

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>

This problem is not related to JSF.

岁吢 2025-01-11 11:43:36

inputText 未收到 id="eventName"

The inputText did not receive an id="eventName".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文