Primefaces mobile and client side validation doesn't work

UI Components for JSF
Post Reply
i.kuzmin
Posts: 1
Joined: 25 May 2017, 22:03

08 Jul 2017, 10:19

Hello everybody,

I'm developing a mobile web app with Primefaces and want to integrate a client side validation but it doesn't work. It seems that the mobile render kit is not compatible with it or maybe I forgot to do something. Could anyone help me ? Thank you in advance.

The problem is when I use :

<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>

AND

<default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>

AND

validateClient="true" attribute,

client side validation script is not called and the page is automatically refreshed after I click the commandButton even if ajax is enabled.

In the web browser I have this java script error once a page is loaded :

validators.js;jsessionid=1409a4a5b3f93be1b8d3134bfcce:1 Uncaught TypeError: Cannot set property 'custom.emailValidator' of undefined
at validators.js;jsessionid=1409a4a5b3f93be1b8d3134bfcce:1

ALL WORKS FINE WITHOUT ANY ERRORS when I remove <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>

This is my sign_in.xhtml : (for the javascript and EmailValidator I copied example code from the Primefaces Showcase)

I include multiple pm:pages in one page.

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 13 guests