Hi James
Thanks for your answer.
I have already tried that solution, but I need the PathInfo to know which MessageResource to pull from the db...
In the meantime I've made the following progress on my own:
I realized the it isn't the Validator which is the problem; It's the JavascriptValidatorTag and ErrorsTag which uses a MessageResource from ServletContext to generate the error messages.
I've figured out that the MessageResource is placed on the ServletContext in an attribute named by Globals.MESSAGES_KEY.
I have (just for testing) replaced the struts-config.xml MessageResource with another MessageResource in my code - it works, but leaves a major thread synchronization issue...
If I could only make Struts look for the MessageResource on the request or session...
I have also found out that I can easily extend JavascriptValidatorTag to use another ServletContext attribute than standard and less easily use a request/session attribute...
The name of the attribute is in a protected String so by extending JavascriptValidatorTag and adding a setter I can use custom attributes on the ServletContext.
If I want to use a request/session attribute I have to override 2/3 of the extended JavascriptValidatorTag, because the oneliner of code is in a private method which again uses private method's.... NO GO - a nightmare at all Struts upgrades..
In the ErrorsTag it's even easier to use a custom ServletContext attribute because it already have the setter for the MessageResource attribute name.
So I guess I have to place the MessageResources under custom names on the ServletContext and use so kind of LRU algoritm to remove them again.
Thanks, Christian Bjørnbak
James Mitchell wrote:
The validator pulls it from the request.
So, you need a custom impl of MessageResources. Then, you just configure your message resource factory in the struts-config and you are done.
-- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx
----- Original Message ----- From: "Christian Bjørnbak" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 11, 2004 3:17 AM
Subject: Using non struts-config.xml MessageResource in the Validator
Hi
I'm currently migrating a system from some homemade XML framework to Struts.
The system is an application service provider where lots of companies have the own db driven ResourceBundle for i18n.
All the companies use the same struts-config.xml as they all share the same Actions, Forms and jsps, and servlet's PathInfo decide which company's pages is requested..
The i18n for the texts on the pages is solved by extending the JSTL messageTag to use our own ResourceBundle.
Now the problem is the texts used at validation of errors...
I would like to be able to use the Struts Validator, but how do I tell the Validator to use a custom ResourceBundle/MessageResource instead of the one from struts-config.xml??
I've figured that extending the ValidatorPlugin is the entrence, but I can't find where the errors converted to texts..
Any pointers??
/Christian Bjørnbak
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]