Affichage page problème validator
J'ai intégré Validator dans mon application, voici la configuration que j'utilise
1- struts-config :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<!-- Formulaires...-->
<form-beans>
<form-bean name="acINForm" type="main.forms.TransactionForm"/>
</form-beans>
<!-- Properties...-->
<message-resources parameter="resources/application"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in> |
2- validation.xml :
Code:
1 2 3 4 5 6 7 8 9 10
| <formset>
<!-- Validation pour le formulaire acINForm -->
<form name="acINForm">
<field
property="codeINS"
depends="required">
<arg key="acIN.title.codeINS"/>
</field>
</form>
</formset> |
3- TransactionForm
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public class ContactForm extends ValidatorForm{
/** Serial Version UID */
private static final long serialVersionUID = 1L;
/** Champ du formulaire : codeINS*/
private String codeINS = "";
// Constructeur par défaut de ContactForm()...
public TransactionForm(){}
public String getCodeINS() {
return codeINS;
}
public void setCodeINS(String codeINS) {
this.codeINS = codeINS;
}
} |
4- et la JSP : acin.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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<div id=myform>
<h3><bean:message key="acIN.title.long"/></h3>
<table cellspacing="0">
<tbody>
<tr>
<td class="text"><bean:message key="acIN.title.codeOperation"/> :</td>
<td>
<html:select property="codeOperation" onchange="document.acINForm.submit();">
<html:option value="selection"><bean:message key="acIN.option.selection"/></html:option>
<html:option value="10"><bean:message key="acIN.option.code10"/></html:option>
<html:option value="11"><bean:message key="acIN.option.code11"/></html:option>
<html:option value="21"><bean:message key="acIN.option.code21"/></html:option>
<html:option value="22"><bean:message key="acIN.option.code22"/></html:option>
<html:option value="23"><bean:message key="acIN.option.code23"/></html:option>
<html:option value="24"><bean:message key="acIN.option.code24"/></html:option>
<html:option value="30"><bean:message key="acIN.option.code30"/></html:option>
<html:option value="31"><bean:message key="acIN.option.code31"/></html:option>
<html:option value="40"><bean:message key="acIN.option.code40"/></html:option>
</html:select>
</td>
</tr>
<c:if test="${acINForm.codeOperation!='selection' && acINForm.codeOperation!=null}">
<tr>
<c:choose>
<c:when test="${requestScope.Historic=='OK'}">
<td class="text"><bean:message key="acIN.title.codeINS"/> :</td>
<td>
<html:text property="codeINS" maxlength="6" size="30"/>
</td>
</c:when>
<c:when test="${acINForm.codeOperation=='10' && (requestScope.Editer1=='OK' || requestScope.Editer2=='OK')}">
<td class="text"><bean:message key="acIN.title.codeINS"/> :</td>
<td>
<html:text property="codeINS" maxlength="6" size="30"/>
</td>
</c:when>
<c:otherwise>
<td class="text"><bean:message key="acIN.title.codeINS"/> :</td>
<td>
<html:text property="codeINS" maxlength="6" size="30" value=""/>
</td>
</c:otherwise>
</c:choose>
</tr>
<tr>
<td colspan="2">
<html:errors property="codeINS"/>
</td>
</tr>
...
... |
A la base TransactionForm étendait la classe ActionForm, mnt, en ajoutant la validation, j'étends la classe ValidatorForm, et j'ai 2 problèmes, ma page acin.jsp qui était incluse dans main.jsp s'affiche seule dans la page, et quand je change le menu, j'ai toujours le message d'erreur, même sans valider mon formulaire...
Merci d'avance de votre aide...