Bonjour à tous,

J'aimerais créer des validateurs qui utilisent mes propres balises.
J'ai suivi le tutorial suivant : JSF: a regular expression validator

Voici mon code :

* DataTypeValidatorTag
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package bss.gesnet.beans.validators;
 
import javax.faces.validator.Validator;
import javax.faces.webapp.ValidatorELTag;
import javax.servlet.jsp.JspException;
 
public class DataTypeValidatorTag extends ValidatorELTag
{
    private static final long serialVersionUID = 1L;
 
    private String message;
 
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
 
    protected Validator createValidator() throws JspException
    {
	DataTypeValidator validator = new DataTypeValidator();
	validator.setMessage(message);
 
	return validator;
    }
}
* DataTypeValidator
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package bss.gesnet.beans.validators;
 
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
 
public class DataTypeValidator implements Validator
{
    private String message;
    public void setMessage(String message) { this.message = message; }    
 
    private String dataType;
    public void setDataType(String dataType) { this.dataType = dataType; }
 
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
    {
	System.out.println(
		"DataTypeValidator.getMessage() = " + message
	);
    }
}
* web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
	<jsp-config>
		<taglib>
			<taglib-uri>myValidators</taglib-uri>
			<taglib-location>/WEB-INF/tags/myValidators.tld</taglib-location>
		</taglib>
	</jsp-config>
* myValidators.tld
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" 
	version="2.0">
	<tlibversion>1.0</tlibversion>
	<uri>myValidators</uri>
 
	<tag>
		<name>dataTypeValidator</name>
		<tag-class>bss.gesnet.beans.validators.DataTypeValidatorTag</tag-class>
		<attributes>
			<name>message</name>
		</attributes>
	</tag>
</taglib>
* ma page jsf
Code : Sélectionner tout - Visualiser dans une fenêtre à part
xmlns:my="myValidators"
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<my:dataTypeValidator message="message de test" />
Voici mon erreur :
Erreur d'analyse XML : préfixe non limité à un espace de noms
Je ne vois pas d'ou viens mon erreur. Si quelqu'un sais m'éclairer !