我正在尝试使用f:ajax标记在inputText框中触发我的验证器,但我没有运气。它似乎没有触发验证器。但验证人员会在表单提交时触发。
这就是我正在使用的。
<td>
<h:inputText id="email" value="#{contactInfo.email}">
<f:validator validatorId="com.tcs.trn.validator.EmailValidator"></f:validator>
<f:validator validatorId="com.tcs.trn.validator.TcsEmailValidator"></f:validator>
<f:ajax execute="@this" event="blur" render="emailMessage"></f:ajax>
</h:inputText>
</td>
<td>
<h:message for="email" warnClass="warningMessage" errorClass="errorMessage" id="emailMessage"></h:message>
</td>
请求标题
Request URL:http://localhost:9080/JSF2Template/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:oam.Flash.RENDERMAP.TOKEN=y4ftx6y5q; JSESSIONID=0000N5Uz-oCoU910GNVdCP3M8jc:-1
Host:localhost:9080
Referer:http://localhost:9080/JSF2Template/login/userDetails.xhtml
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
Query String Parametersview URL encoded
ln:javax.faces
stage:Development
Response Headersview source
Content-Language:en-US
Content-Type:application/x-javascript
Date:Thu, 14 Mar 2013 19:32:10 GMT
Expires:Thu, 14 Mar 2013 19:32:10 GMT
Last-Modified:Thu, 14 Mar 2013 18:33:59 GMT
Server:WebSphere Application Server/7.0
Transfer-Encoding:chunked
通过将此添加到头部来解决这个问题。默认情况下,脚本链接显示,但实际上它允许它出于某种原因工作。
<h:outputScript name="jsf.js" library="javax.faces" />