le Validator n'affiche pas les messages
bonjour j'utilise struts 1.2.9, j'ai un souci par rapport à l'utilisation du framework validator
la liste des fichiers:
*** messages_fr.properties
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
addIncident.title = Titre de l'incident
addIncident.description = Description
addIncident.dateEnd = Date d'échéance
addIncident.btnSubmit = Ajouter
addIncident.btnReset = Effacer
### messages d'erreur pour la vérification des parametres
addIncidentError.title = Le titre doit être renseigné
addIncidentError.description = La description doit être renseignée
addIncidentError.dateEnd = La date doit être renseignée, et elle doit être au bon format
### validation rules messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address. |
*** struts-config.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<form-bean name="addIncidentForm" type="com.XXXX.client.web.form.incident.AddIncidentFormBean"></form-bean>
<action path="/addIncident"
input="/jsp/test/addIncident.jsp"
type="com.XXXX.client.web.action.incident.AddIncidentAction"
name="addIncidentForm"
scope="request"
validate="true"
>
</action>
<!-- action qui appelle la jsp addIncident -->
<action path="/newIncident"
type="com.XXXX.client.web.action.SuccessAction"
scope="request"
validate="true"
>
<forward name="success" path="site.addIncident.page" />
</action>
<message-resources parameter="messages" /> |
*** ma jsp addIncident.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<html:form action="/addIncident">
<p>
<label><bean:message key="addIncident.title"/></label>
<html:text property="title"></html:text>
</p>
<p>
<label> <bean:message key="addIncident.description"/> </label>
<html:text property="description"></html:text>
</p>
<p>
<label> <bean:message key="addIncident.dateEnd"/> aaaa-mm-jj </label>
<html:text property="dateEnd"></html:text>
</p>
<p>
<html:submit value="Ajouter"> </html:submit>
<html:reset value="Effacer"> </html:reset>
</p>
</html:form> |
*** une classe Action :
Code:
1 2
|
public class AddIncidentAction extends Action |
*** une classe form bean
Code:
1 2
|
public class AddIncidentFormBean extends ValidatorForm |
*** un fichier validation.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<formset>
<form name="addIncidentForm">
<field property="title" depends="required">
<arg key="addIncident.title"/>
<msg name="errorTitle" key="addIncidentError.title"/>
</field>
<field property="description" depends="required">
<arg key="addIncident.description"/>
</field>
<!--
<field property="dateEnd" depends="required,date">
<arg key="addIncident.dateEnd"/>
<msg name="dateEnd" key="addIncidentError.dateEnd"/>
<var>
<var-name>datePattern</var-name>
<var-value>yyyy-MM-dd</var-value>
</var>
</field>
-->
</form>
</formset>
</form-validation> |
*** et un fichier validation-rules.xml
que j'ai tout simplement copié collé
Voila mon problème c'est que quand je saisie des paramètres valides tout se passe bien et l'insertion en BD se passe.
Par contre quand je saisi des paramètres non valides rien ne se passe(c'est bien) mais j'ai aucun message d'erreur qui s'affiche.
Help please ça fait un bon bout de temps que je bloque sur ce truc et ce sont mes premiers pas avec struts.
Merci