hardy.ferentschik wrote:
Does your code for reloading the bundle works as unit test or does it work in the running web application. Maybe you can isolate a testcase I can run. I don't see where the latest version of HV should still be caching the bundles.
Hi Hardy,
Its reloading the Resource bundle, when ResourceBundleMessageInterpolator cacheMessages=false. I have tested this by changing cacheMessages=false in debug mode.
But not able to set cacheMessages=false programatically.
<p>
Here is my code:
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
ResourceBundleLocator defaultResourceBundleLocator = configure.getDefaultResourceBundleLocator();
ResourceBundleLocator myResourceBundleLocator = new MyCustomResourceBundleLocator(defaultResourceBundleLocator);
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(myResourceBundleLocator, false));
//MyCustomResourceBundleLocator
public class MyCustomResourceBundleLocator implements ResourceBundleLocator
{
private PlatformResourceBundleLocator delegate;
MyCustomResourceBundleLocator(ResourceBundleLocator locator)
{
this.delegate = (PlatformResourceBundleLocator) locator;
}
@Override
public ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle("ValidationMessages");
}
}
</p>
If the ResourceBundleMessageInterpolator cacheMessages is static variable then it may solve our problem. By default it is setting to true.
And here is test scenario
1. Statring the websphere application server.
2. Login to the application and invoking the product search page (for example)
3. Clicking the submit button without entering the search fields will prompts error message say "please select mandatory fields to search" from ValidationMessages.properties
4. Changed the ValidationMessages.properties message to "please select necessary fields to search"
5. Invoke the CustomeMessageInterpolator.jsp to reload updated resource bundle (This page will updated properties from the DB and to write ValidationMessages.properties. Above code included in this logic after writing properties file)
6. Click submit button on product search page without entering the search fileds is prompts same error message.
Please give me some tips to resolve this.
Thank you