5 Replies Latest reply on Aug 21, 2008 1:53 PM by djn

    Help with messages.properties!

    benmoore

      Hi,


      How can I add a message to messages.properties which has a variable? Example:


      newmails=You have {0} new mails.


      If I then write:

      <h:outputText value="#{messages.newmails}"
        <f:param value="#{user.newMails.count}/>
      </h:outputText>


      it doesn't work. I found a bug about this here.


      Is there any other way to do this with Seam?


      thanks,
      Ben

        • 1. Re: Help with messages.properties!
          michaelcourcy

          Did you try this ?


          newmails=You have #{user.newMails.count} new mails.
          



          http://docs.jboss.com/seam/2.1.0.A1/reference/en/html/i18n.html#d0e9302


          Maybe not what you really want.


          You also have this option


          <h:outputFormat
           value="#{messages.newmails}}">
            <f:param value=""#{user.newMails.count}"/>  
          </h:outputFormat> 
          



          Cheers

          • 2. Re: Help with messages.properties!
            tony.herstell1
            booking_in_past=Cannot book resource #0 in the past.
            
            facesMessages.addToControlFromResourceBundle(
              "bookingResourceAttempt", 
              FacesMessage.SEVERITY_ERROR,
              "booking_in_past",
              messages.get(eachBookingResource.getResource().getKind().getInlLabel()));

            • 3. Re: Help with messages.properties!
              benmoore

              Michael Courcy wrote on Aug 19, 2008 22:52:


              Did you try this ?

              newmails=You have #{user.newMails.count} new mails.
              


              Maybe not what you really want.


              Right. Not what I want.



              Michael Courcy wrote on Aug 19, 2008 22:52:

              You also have this option

              <h:outputFormat
               value="#{messages.newmails}}">
                <f:param value=""#{user.newMails.count}"/>  
              </h:outputFormat> 
              




              That doesn't work in Seam, and that's precisely the problem. See the bug I linked to above. It works in a plain JSF application, but not Seam apps.

              • 4. Re: Help with messages.properties!
                michaelcourcy

                Hi Ben


                I've been testing this myself


                newmails=You have {0} new mails.
                



                <h:outputFormat
                 value="#{messages.newmails}">
                  <f:param value="#{user.newMails.count}"/>  
                </h:outputFormat>
                



                It just works.


                My version of seam is 2.0.2.SP1 and I use jboss-4.2.3.GA


                Cheers

                • 5. Re: Help with messages.properties!
                  djn

                  Hi.


                  We have used the following:


                  our_message=Foo #0 Bar
                  



                  <h:outputText value="#{interpolator.interpolate(messages.our_message, myBean.value}" />
                  



                  Which then displays the message with the data we want. #{interpolator} is a builtin seam component.