3 Replies Latest reply on Dec 29, 2008 7:22 PM by Riccardo Serafin

    Hibernate validator does not use the seam locale

    raoul schmidiger Newbie

      Hi all




      I still have this problem. Hibernate validation messages are shown in the language of the server’s locale setting instead of being shown in the language that has been selected over the localeSelector. What’s the matter here?




      To change the locale the following method is used:




      <h:commandLink disabled="#{localeSelector.getLocale() == 'en'}" value="EN" action="#{localeSelector.selectLanguage('en')}"/>




      Interestingly it partially works, when using this method to change the locale:


      <h:selectOneMenu value="#{localeSelector.language}" id="changeLanguage" style="width:100px">

            <f:selectItem itemLabel="English" itemValue="en"/>

            <f:selectItem itemLabel="Français" itemValue="fr"/>

      </h:selectOneMenu>

      <h:commandButton id="translate" action="#{localeSelector.select}" value="Change locale" />
                




      It works only partially in that the validation messages are only shown correctly, when French is selected. Selecting English still shows the messages in German, which is the locale setting of my computer.




      I’m using SEAM 2.0.1.GA




      Any help is highly appreciated.- Thank you very much!


        • 1. Re: Hibernate validator does not use the seam locale
          Pete Muir Master

          Please file a bug report in JIRA. Include clear reproduction steps.

          • 2. Re: Hibernate validator does not use the seam locale
            Taha Ghasemi Newbie

            Hibernate validator 3.0.0 GA uses Locale.getDefault() to determine the locale of messages, apparantly this problem is resolved in 3.1.0 CR2.
            you can fix this problem temporarily by changing the default locale in your action.

            • 3. Re: Hibernate validator does not use the seam locale
              Riccardo Serafin Newbie

              It looks like I'm falling in the same trap. I'm currently using JBoss 4.2.3.GA and Seam 2.1.1.CR2, with an ear packaged project that does not include (in the ear) any hibernate lib (as I suppose they are provided by JBoss). With this configuration, it looks like that when changing the seam locale the hibernate validator messages are not affected.


              After reading the previous message I checked which version of Hibernate Validator is provided by default with JBoss 4.2.3 and, to my surprise, I wasn't able to find the library (where is it btw?).


              In any case, I noticed that the other hibernate lib are a little old so I swapped them out and included what I believe is the latest version (that is Validator 3.1.0 GA, Core 3.3.0 SP1, Annotations 3.4.0 GA and Entity Manager 3.4.0 GA, plus other dependencies). Unfortunately the result was the same: once the validation message has been shown in one locale, changing the locale through seam doesn't affect the validation messages already loaded by hibernate and at the next validation the message in the old locale is shown.


              Any idea why? Suggestion to solve the problem?


              Thanks,
              Riccardo.


              PS: btw, I've also found and old, solved, JIRA issue that seems related JBSEAM-1880 and marked as solved, but the problem seems to be still there.