Is there any solution for client-side validation in JSF ?I heard Struts has some code generation (Java script) mechanism for this.
you can use jsf commonValidatoruse this link http://shale.apache.org/shale-validator/index.htmlOr take following steps . this one work fine for me1. define a taglib like this on your project WEB_INF path with “corejsf-validator.taglib.xml†name and following content <?xml version="1.0"?><!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"><facelet-taglib> <namespace>http://corejsf.com/validator</namespace> <tag> <tag-name>commonsValidator</tag-name> <validator> <validator-id>com.corejsf.validator.CommonsValidator</validator-id> </validator> </tag> <tag> <tag-name>validatorScript</tag-name> <component> <component-type>com.corejsf.validator.UIValidatorScript</component-type> </component> </tag></facelet-taglib>2. on your web.xml add this context param <context-param> <param-name>facelets.LIBRARIES</param-name> <param-value> /WEB-INF/corejsf-validator.taglib.xml </param-value> </context-param>3. add this lines on your faces-config.xml file<component> <component-type>com.corejsf.validator.UIValidatorScript</component-type> <component-class>com.corejsf.validator.UIValidatorScript</component-class> </component><validator> <validator-id>com.corejsf.validator.CommonsValidator</validator-id> <validator-class>com.corejsf.validator.CommonsValidator</validator-class> </validator>4. and finally your page should be like this one<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:v="http://corejsf.com/validator"><f:view><h:form id="userForm" onsubmit="return validateUserForm(this)"> <h:inputText value="#{user.username}" id="username" required="true" </h:form><v:validatorScript functionName="validateUserForm"/></f:view></html>