Seam / JSF表单提交触发按钮onclick事件 [英] Seam/JSF form submit firing button onclick event

查看:173
本文介绍了Seam / JSF表单提交触发按钮onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询生成器的搜索表单。构建器由一个按钮激活。像这样

 < h:form id =search_form> 
< h:outputLabel for =expressionvalue =Expression/>
< button onclick =openBuilder(); return false;> Open Builder< / button>
< h:commandButton value =Searchaction =#{searcher.search}/>
< / h:表格>

结果是HTML既有< button /> 和一个< input type =submit/> 。如果用户在表达式字段中输入字符串并点击回车键而不是点击提交按钮,则当预期的行为是提交搜索时,将显示查询生成器。什么给出了?

解决方案

假设HTML表单中的按钮用于提交表单。改变按钮来输入type =button,这应该修复它。



或者,在按钮元素中添加type =button。 b

I have a search form with a query builder. The builder is activated by a button. Something like this

<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>

The result is HTML that has both a <button/> and an <input type="submit"/> in the form. If the user enters a string into the expression field and hits the enter key rather than clicking the submit button, the query builder is displayed when the expected behavior is that the search be submitted. What gives?

解决方案

A button in an HTML form is assumed to be used to submit the form. Change button to input type="button" and that should fix it.

Alternatively, add type="button" to the button element.

这篇关于Seam / JSF表单提交触发按钮onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆