[jboss-user] [JBoss Seam] - Re: How to write a validator that compares two fields

chawax do-not-reply at jboss.com
Thu Oct 11 11:52:18 EDT 2007


One more problem I can't find how to workaround ...

I try to use my validator within a facelet taglib. I would like it to be used this way (t4:compareFields tag) :

<s:decorate template="/decorateField.xhtml" for="confirmerMotDePasse">
  |         <h:inputSecret id="confirmerMotDePasse" value="#{employeCrud.confirmerMotDePasse}" required="#{employe.id == null}">
  |                 <t4:compareFields compareTo="nouveauMotDePasse" message="error.motDePasse.differents" />
  |         </h:inputSecret>
  | </s:decorate>

My validator class has two properties : "compareTo" and "message", with getters and setters. But these properties are always null when the validate() method is called.

I added a t4.taglib.xml file in /WEB-INF :
<?xml version="1.0" encoding="UTF-8"?>
  | <!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 xmlns="http://java.sun.com/JSF/Facelet">
  | 	<namespace>http://myCompany.fr/t4/taglib</namespace>
  | 	<tag>
  | 		<tag-name>compareFields</tag-name>
  | 		<validator>
  | 			<validator-id>validator.compareFields</validator-id>
  | 		</validator>
  | 	</tag>
  | </facelet-taglib>

Note I had to remove @Name and @Validator annotations in my validator class, because it could not find the validator-id (is it a bug ?). So I added these lines in faces-config.xml file :

<validator>
  |         <validator-id>validator.compareFields</validator-id>
  |         <validator-class>fr.myCompany.t4.gui.validators.CompareFieldsValidator</validator-class>
  | </validator>

Is there something special to do in the validator class so that facelets can use my validator's setters ?

Thanks in advance

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4094173#4094173

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4094173



More information about the jboss-user mailing list