Bonjour ,
J’essai de mettre en pratique le DynaValidatorForm et Validation.xml.
Je n’arrive pas à faire déclencher les controles sur les champs.
![]()
![]()
Je ne vois pas ou se situe mon erreur:
:
A+
TomCat 5.5
Struts 1.2
----------------------------------------------------------------------------------------------------------
Page : livre.jsp
----------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
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 <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %> <html:html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>test </h1> <body bgcolor="white"> <html:errors/> <html:form action="/InputLivre.do" > <bean:message key="auteur.titre"/> <html:text property="titre" size="30"></html:text> <html:errors property="titre" /><br> <html:submit></html:submit> </html:form> </body> </html:html>
fichier : struts-config.xml
----------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <struts-config> <form-beans> <form-bean name="livreForm" type ="org.apache.struts.validator.DynaValidatorForm"> <form-property name="titre" type ="java.lang.String" initial =""/> </form-bean> </form-beans> <action name="livreForm" path="/InputLivre" scope="request" input="input" validate="true" type="org.apache.struts.actions.ForwardAction" parameter="/livre.jsp"/> <forward name="input" path="/livre.do" /> </action-mappings>
fichier : validtion.xml
----------------------------------------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <form name="livreForm"> <field property="titre" depends="required,minlength" > <arg key="auteur.titre" /> <var> <var-name>minlength</var-name> <var-value>5</var-value> </var> </field> </form>
[Modéré par Didier] : ajout de tag dans le titre - Les règles du forum Java
Partager