2

我有一个带有 inputText 和 commandButton 的简单表单。通常,如果我使用onkeypress="if (event.keyCode == 13) this.submit();"我可以按 Enter 键提交表单。在我的应用程序的上下文中,虽然这不起作用。当我按下 Enter 键时,inputText 被清除但没有提交表单并且没有调用 commandButton 的操作。我正在使用 Icefaces,我ice.captureEnterKey在页面的源代码中看到了一些,但我不知道这是否相关。

页面代码:

<h:form id="form1">
    <h:inputText value="#{myBean.query}"/>
    <h:commandButton id="search" value="Search" action="#{myBean.submitQuery()}" onkeypress="if (event.keyCode == 13) this.submit();"/>
</h:form>

更新:我设法使它像这样工作:

`<h:form id="form1">
    <h:inputText value="#{myBean.query}" onkeypress="if (event.keyCode == 13) document.getElementById('form1:search').click();"/>
    <h:commandButton id="search" value="Search" action="#{myBean.submitQuery()}"/>
</h:form>`

现在的问题是,在导航到下一页之前,我收到了这个奇怪的错误:

Network connection interrupted. Reload this page to try to reconnect.

该错误仅在我按 Enter 提交表单时出现。如果我用鼠标按下按钮,它不会出现。此外,如果我删除 Icefaces 库,一切正常。

4

0 回答 0