4 Replies Latest reply on Apr 8, 2008 4:05 PM by Eniko zsido

    FacesMessages are not translated when I select new Message

    Eniko zsido Newbie

      Hello,


      I have an application that supports internationalization.


      I have a a registration form with validation. On language change everything is translated into new language except the faces messages.


      Lets see the scene: I fill out the form, hit next, validation error messages are displayed. Then I change the language. The messages disappear although, the fields keep their error style.


      Here is the source of language selector:



      <h:form name="languages" action="#{localeSelector.select}">
                  <h:selectOneMenu value="#{localeSelector.language}" onchange="document.forms[0].submit();">
                <f:selectItem itemLabel="English" itemValue="en"/>
                <f:selectItem itemLabel="Faroese" itemValue="fo"/>
           </h:selectOneMenu>
      </h:form>



      Do you have any idea why and how could I solve this?


      Thanks a lot:


      Eniko


       

        • 1. Re: FacesMessages are not translated when I select new Message
          Pete Muir Master

          You seem to be describing two separate problems - can you clarify?


          So, the error messages come from validation errors?


          Also, your xhtml snippet isn't valid, post the real xhtml ;-)

          • 2. Re: FacesMessages are not translated when I select new Message
            Eniko zsido Newbie

            Hello,


            Thanks for reply.
            I'll try to explain the problem again. I have  a form, I'm trying to fill it out, and go to the next step. I make a mistake, for example I put a letter instead of a number. I get conversion error on the field value must be a number. I decide to change the language, so I choose Faroese. The messages are not displayed.



            The code is:



            <div id="top"  xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:s="http://jboss.com/products/seam/taglib">
                <div id="logo">
                   <s:decorate rendered="#{not identity.loggedIn}"><h1 onclick="document.location='home.seam'" title="#{messages['homePageHint']}"><span>asktovan</span></h1></s:decorate>
                   <s:decorate rendered="#{identity.loggedIn}"><h1 onclick="document.location='task.seam'" title="#{messages['homePageHint']}"><span>asktovan</span></h1></s:decorate>
                </div>
                <div id="side-top">
                  <p class="top-img"><!-- --></p>
                  <p class="welcome" id="loginout">
                    <h:outputText value="#{messages['welcomeMessage']}!" rendered="#{identity.loggedIn}"/>
                    <s:link view="/login.xhtml" value="#{messages['login']}" rendered="#{not identity.loggedIn}"/>
                    <h:form name="login" action="#{localeSelector.select}">
                      <h:commandLink view="/home.xhtml" action="#{identity.logout}" value="#{messages['logout']}" rendered="#{identity.loggedIn}"/>
                      
                      <br /><br />
                           <h:selectOneMenu value="#{localeSelector.language}" onchange="document.forms[0].submit();">
                               <f:selectItem itemLabel="English" itemValue="en"/>
                               <f:selectItem itemLabel="Faroese" itemValue="fo"/>
                           </h:selectOneMenu>
                         
                    </h:form>
                  </p>
                </div>
            </div>




            Thanks : Eniko

            • 3. Re: FacesMessages are not translated when I select new Message
              Pete Muir Master

              No, its a different form. So there are no validation errors, and your xhtml is still invalid (there is no action attribute on <h:form />).

              • 4. Re: FacesMessages are not translated when I select new Message
                Eniko zsido Newbie

                Oh, I get it now, what you don't understand.


                The source I've sent you is part of a template. The template also has a content part: where the registration is included, that is a different form.


                When I submit the form validation errors are displayed, but after changing locale the messages get lost, though I want them to be translated.


                Thank you for your patience and promptness!