Support for different resource bundles in the Commons Validator DTD was added in Struts 1.2.7 and Commons Validator 1.1.4 (although I would recommend Struts 1.2.9 if you're upgrading and Validator 1.3.0).
So in you validation.xml you can specify a "bundle" attribute on either the <msg> or <arg> element: <field property="contexte" depends="required"> <msg name="required" key="custom.required" bundle="angersErreurs"/> <arg position="1" key="frmSelection.contexte" bundle="angers" /> </field> There is a "bundles" example page (in the "validator" section) in the struts-examples.war webapp which is shipped with the binary distribution. You will need to switch from using the <arg0> - <arg3> elements to the new <arg> element to take advantage of this. For example <arg position="0"/> is the same as <arg0> and if you don't specify the position attribute then it will guess a (hopefully) sensible value. Niall On 7/3/06, Olivier Godineau <[EMAIL PROTECTED]> wrote:
I use several resource bundle for my application. The particularity is the resource bundle is depending of the user?group. Here, an extract from the struts config file : <message-resources parameter="com.convergence.ressources.ressources" null="false" /> <message-resources key="angers" parameter="com.convergence.ressources.angers.ressources" null="false" /> <message-resources key="angersErreurs" parameter="com.convergence.ressources.angers.erreurs" null="false" /> <message-resources key="nantes" parameter="com.convergence.ressources.nantes.ressources" null="false" /> <message-resources key="nantesErreurs" parameter="com.convergence.ressources.nantes.erreurs" null="false" /> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml" /> </plug-in> When I submit a form to be validated There is no problem to post the right message from the right resource bundle, whether the validation is on the client side (with javascript)or on the server side. But these messages to be posted contain some arguments (the names of the invalidate form fields). That?s the problem. The validation on the customer side returns arguments from the right resource bundle (the same which contains the messages to expose) due to the following tag in the JSP: <html:javascript formName="frmSelection" bundle="angersErreurs" /> The validation ont the server side returns arguments from the application resource bundle (the default resource bundle as declared at the struts config file : <message-resources parameter="com.convergence.ressources.ressources" null="false" /> However the JSP declaration is : <html:errors bundle="angersErreurs"/> Because of the dynamic call of the resource bundle(in the jsp examples, i hide the dynamic bundle call for more readability ), it isn't possible to specify the resource bundle on the validation.xml file as field "arg0" attribute from the field "field". Extract of the file validation.xml : <formset> <form name="frmSelection"> <field property="contexte" depends="required"> <arg0 key="frmSelection.contexte" /> </field> <field property="selection" depends="required"> <arg0 key="frmSelection.selection" /> </field> </form> Does exists a solution at this problem of behavior between server and client or is it a bug from struts? Regards Olivier Godineau -- View this message in context: http://www.nabble.com/-STRUTS--Resource-bundle-and-form-validation-tf1884718.html#a5152197 Sent from the Struts - User forum at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]