bonjour à tous,
je débute dans struts et je souhaiterai faire un formulaire dynamique avec validation.
donc j'ai lu pas mal de chose mais je fini par m'embrouiller et donc je demande votre aide
J'ai vu la classe DynaValidatorActionForm, et vu le nom elle à l'air de tout faire mais c'est peut être superflu...je ne sais pas...
Je voulais donc savoir comment et quelle classe faire pour le formulaire dynamique qui gère la validation, et si je devais changer les fichiers existants.
Je vous met les fichiers utiles
----------------struts-config.xml---------------------
-------------------------validation.xml-----------------------------
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
24
25 <struts-config> <form-beans> <form-bean name="SearchForm" type="org.apache.struts.validator.DynaValidatorActionForm"> <form-property name="produit" type="java.lang.String" initial=""/> <form-property name="date" type="java.lang.String" initial=""/> ... </form-bean> </form-beans> <action-mappings> <action path="/main" name="SearchForm" validate="true" scope="session" input="/pages/erreur.jsp" type="org.apache.struts.validator.DynaValidatorActionForm"> </action> ... </action-mappings> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> </plug-in> </struts-config>
----------------------------formulaire.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
23 <form-validation> <global> <constant> <constant-name>chaine</constant-name> <constant-value>^[a-zA-Z]*$</constant-value> </constant> </global> <formset> <form name="SearchForm"> <field property="produit" depends="required"> <arg0 key="SearchForm.produit"/> </field> <field property="date" depends="required,mask"> <arg0 key="SearchForm.date"/> <var> <var-name>datePattern</var-name> <var-value>dd/MM/yyyy</var-value> </var> </field> ... </form> </formset> </form-validation>
Je suis ouvert à toute suggestion.
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 <html:form action="/main" name="SearchForm" type="org.apache.struts.validator.DynaValidatorActionForm"> <table widht="100%"> <tr> <td width="10%"> </td> <td width="45%"> <table> <tr> <td>Produit :<td> <td><html:select name="SearchForm" property="produit"> <html:options name="SearchForm" property="valeursProduits"/> </html:select> </td> </tr> <tr> <td>Date :</td> <td><html:text name="SearchForm" property="date" /></td> </tr> ... </table> </td> </tr> </table> </html:form>
Merci.
Partager