Java-Seam / JSF表单提交触发按钮onclick事件

我有一个带有查询生成器的搜索表单.通过按钮激活构建器.像这样

<h:form id="search_form">
  <h:outputLabel for="expression" value="Expression"/>
  <h:inputText id="expression" required="true" value="#{searcher.expression}"/>
  <button onclick="openBuilder(); return false;">Open Builder</button>
  <h:commandButton value="Search" action="#{searcher.search}"/>
</h:form>

结果是HTML同时具有< button />和< input type =“ submit” />的形式.如果用户在表达式字段中输入字符串,然后按Enter键而不是单击“提交”按钮,则当预期行为是提交搜索时,将显示查询构建器.是什么赋予了?

最佳答案

假定使用HTML表单中的按钮来提交表单.将button更改为输入type =“ button”,这应该可以解决.

或者,将type =“ button”添加到button元素.

发布了549 篇原创文章 · 获赞 0 · 访问量 2364

猜你喜欢

转载自blog.csdn.net/weixin_44109689/article/details/103943818