我正在使用Primefaces开发移动网络应用,并希望集成客户端验证,但它不起作用。移动渲染工具包似乎与它不兼容,或者我忘了做某事。谁能帮助我?提前谢谢。
问题出在我使用时:
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
和
<default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>
和
validateClient="true" attribute,
未调用客户端验证脚本,即使启用了ajax,单击commandButton后页面也会自动刷新。
在网页浏览器中,加载页面时出现此java脚本错误:
validators.js; jsessionid = 1409a4a5b3f93be1b8d3134bfcce:1 Uncaught TypeError:无法设置属性&#39; custom.emailValidator&#39;未定义的 at validators.js; jsessionid = 1409a4a5b3f93be1b8d3134bfcce:1
当我删除PRIMEFACES_MOBILE时,所有工作都没有任何错误
这是我的sign_in.xhtml :(对于javascript和EmailValidator,我从Primefaces Showcase复制了示例代码)
我还在一个页面中包含多个pm:页面。
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:pm="http://primefaces.org/mobile"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<pm:page id="sign_in">
<pm:content>
<h1 id="kie_title" align="center">KIE</h1>
<h:form id="form_sign_in">
<p:messages id="messages" autoUpdate="true" globalOnly="true"/>
<pm:field>
<p:panelGrid columns="1">
<p:outputLabel for="email" value="Email"/>
<p:inputText id="email" value="#{signInCtrl.email}" required="true">
<!--<f:validateRegex pattern="[a-zA-Z]*"/>-->
<f:validator validatorId="custom.emailValidator"/>
</p:inputText>
<p:message for="email"/>
</p:panelGrid>
</pm:field>
<pm:field>
<p:panelGrid columns="1">
<p:outputLabel for="password" value="Password"/>
<p:password id="password" value="#{signInCtrl.password}" required="true"/>
</p:panelGrid>
<p:message for="password"/>
</pm:field>
<p:commandButton id="cmdbtn_sign_in" value="Sign In" action="#{signInCtrl.signIn()}" validateClient="true"
update="@form"/>
</h:form>
</pm:content>
<!--Block fixed to the bottom of the page with New user and Forgot password links-->
<div id="new_user">
<p:button outcome="pm:sign_up?transition=slide" value="Sign Up"/>
<p:link outcome="pm:password_recovery?transition=slide" value="Forgot your password ?"/>
</div>
</pm:page>
</ui:composition>