Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
19. Aug 2008, 21:23 CET | Link

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

5 Replies:
19. Aug 2008, 22:52 CET | Link

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

20. Aug 2008, 16:20 CET | Link
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.

20. Aug 2008, 22:45 CET | Link

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

19. Aug 2008, 23:29 CET | Link
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()));
 

But I being poor have only my dreams. I have spread my dreams under your feet. Tread softly because you tread on my dreams...

21. Aug 2008, 13:53 CET | Link

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.