[英]JSF Form with AJAX validation - Focus issues
Hi JSF experts out there ... 嗨,JSF专家在那里...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:o="http://omnifaces.org/ui">
<h:head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
</h:head>
<h:body>
<h:form>
<o:validateOneOrMore components="one two three" id="validate"/>
<p:message for="validate"/>
<p:inputText id="one" value="#{testBean.valueOne}">
<p:ajax event="change" process="@this" update="@form"/>
</p:inputText>
<p:inputText id="two" value="#{testBean.valueTwo}">
<p:ajax event="change" process="@this" update="two"/>
</p:inputText>
<p:inputText id="three" value="#{testBean.valueThree}">
<p:ajax event="change" process="@this" update="one two validate"/>
</p:inputText>
<p:commandButton process="@form"
update="@form"
value="Submit"
partialSubmit="true"
action="#{testBean.submit}"/>
</h:form>
</h:body>
</html>
a simple form with requirement of at least one form filled, immediate error reset and tab-able. 一种简单的表单,要求至少填写一张表单,立即重置错误并可以制表。
But i didn't get it work, tried different things as you can see in sample code. 但是我没有使它起作用,您尝试了一些不同的事情,如示例代码所示。
What happens 怎么了
Is there any solution out, for having a form like that ... where after each input validation of form will happen (meaning remove such global errors) and still have it quickly usable by using the tab-key? 对于这样的表单,是否有解决方案……在每次输入表单后都会进行验证(意味着删除此类全局错误),并且仍然可以使用Tab键快速使用它?
thx. 谢谢。
This is a very annoying issue, which has to do with the way JSF preforms partial renders, there is an in depth post regarding JSF 2 AJAX focus issues . 这是一个非常烦人的问题,与JSF预执行部分渲染的方式有关,关于JSF 2 AJAX焦点问题有深入的文章。
Which offers a potential solution in the form of using the JSF JavaScript API to listen for triggered AJAX request and refocusing, have a look at the post for further details. 通过使用JSF JavaScript API来侦听触发的AJAX请求和重新聚焦,它提供了一种潜在的解决方案,有关更多详细信息,请查看文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.