Bonjour,
Ma validation javascript est ok mais pas de validation coté serveur ...![]()
Si qqu'un a une idee je suis preneur :-)
Je me demande si cela ne vient pas du fait que mon formBean n'a pas le meme nom que mon formulaire html (SearchFile et searchFile)
Dans la jsp j'ai :
Mon fichier validation.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 <html:javascript formName="searchFile" dynamicJavascript="true" staticJavascript="true" /> <html:form action="/searchFile" onsubmit="return validateSearchFile(this);">
Mon 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
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 <form-validation> <formset> <form name="searchFile"> <field property="noLot" depends="validwhen"> <arg0 key="searchFileForm.error.allBlanks"/> <var> <var-name>test</var-name> <var-value>( (noOCT != null) or ((debPeriode != null) or ((finPeriode != null) or ((ptControle != null) or ((noLot != null) or ((normeFlux != null) or ((noPS != null) or ((etatTransfert != null) or (*this* != null) ))))))))</var-value> </var> </field> <!-- juste la pour le debug --> <field property="noLot" depends="required"> <arg0 key="REQUIRED" resource="false"/> </field> <field property="debPeriode" depends="date"> <arg0 key="searchFileForm.debPeriode"/> <var> <var-name>datePattern</var-name> <var-value>dd/MM/yyyy</var-value> </var> </field> <field property="finPeriode" depends="date"> <arg0 key="searchFileForm.finPeriode"/> <var> <var-name>datePattern</var-name> <var-value>dd/MM/yyyy</var-value> </var> </field> </form> </formset> </form-validation>
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
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans> <form-bean name="SearchFileForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="noAMC" type="java.lang.String"/> <form-property name="ptControle" type="java.lang.String"/> <form-property name="noOCT" type="java.lang.String"/> <form-property name="noLot" type="java.lang.String"/> <form-property name="noPS" type="java.lang.String"/> <form-property name="finPeriode" type="java.lang.String"/> <form-property name="debPeriode" type="java.lang.String"/> <form-property name="alerteEnCours" type="java.lang.String"/> <form-property name="normeFlux" type="java.lang.String"/> <form-property name="etatTransfert" type="java.lang.String"/> </form-bean> <form-bean name="SearchFactForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="etatFacture" type="java.lang.String"/> <form-property name="noAMC" type="java.lang.String"/> <form-property name="noFacture" type="java.lang.String"/> <form-property name="anomalie" type="java.lang.String"/> <form-property name="dateFacture" type="java.lang.String"/> <form-property name="alerteEnCours" type="java.lang.String"/> <form-property name="noINSEE" type="java.lang.String"/> </form-bean> </form-beans> <global-exceptions /> <global-forwards> <forward name="error" path="/WEB-INF/jsp/error.jsp" redirect="false"/> </global-forwards> <action-mappings> <action path = "/choose" type = "org.apache.struts.actions.ForwardAction" parameter = "/WEB-INF/jsp/chooser.jsp"/> <action path = "/welcome" type = "org.springframework.web.struts.DelegatingActionProxy" input = "/WEB-INF/index.jsp"> <forward name="file" path="/WEB-INF/jsp/searchFileForm.jsp"/> <forward name="fact" path="/WEB-INF/jsp/searchFactForm.jsp"/> </action> <action path="/searchFile" name="SearchFileForm" parameter="submit" scope="session" attribute="searchFile" type="org.springframework.web.struts.DelegatingActionProxy" input="/WEB-INF/jsp/searchFileForm.jsp" validate="true"> <forward name="showFiles" path="/WEB-INF/jsp/resultFile.jsp" /> </action> <action path="/searchFact" name="SearchFactForm" parameter="submit" scope="session" attribute="searchFact" type="org.springframework.web.struts.DelegatingActionProxy" input="/WEB-INF/jsp/searchFactForm.jsp" validate="true"> <forward name="showFacts" path="/WEB-INF/jsp/resultFact.jsp" /> </action> <action path="/fileDetails" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" input="/WEB-INF/jsp/searchFileForm.jsp" validate="false"> <forward name="showFile" path="/WEB-INF/jsp/fileDetails.jsp" /> </action> </action-mappings> <message-resources parameter="messagesStruts"/> <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml"/> </plug-in> <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>
Merci ciao
ps : les "DelegatingActionProxy" c'est normal c'est parce que j'utilise Spring
Partager