views:

213

answers:

2

I would like to retrieve the message information from the i18n bundle (messages.properties in seam), but I am not sure how to pass the declare / pass the jobCount variable dynamically in my xhtml

The existing code looks like this.

<s:decorate template="/layout/panel-name.xhtml">
    <ui:define name="label">User has been assigned #{jobCount} jobs</ui:define>
</s:decorate>
+2  A: 

I found this fragment of code:

#{interpolator.interpolate(messages['myMessage'],jobCount)}

I think this is what you're searching for. Messages and placeHolders

Otherwise you can use string concatenation (ugly) if it's a static message:

<s:decorate template="/layout/panel-name.xhtml">
    <ui:define name="label">#{messages['myMessage']} #{jobCount}</ui:define>
</s:decorate>

Or if it's a dynamic message and you're using h:message

Use this syntax in the message properties:

myMessage= User has been assigned {1} jobs

And then when you create the message in the bean

@Name("myBean") 
public class Bean {
    @In(create = true) FacesMessages facesMessages;
    @In Map messages;

    public String action() {
         // Action here
         facesMessages.add(messages.get("myMessage"), jobCount);
    }
}
volothamp
will try it out
Samuel
+2  A: 

I think this should work:

<h:outputFormat value="#{msg.yourMessage}">
  <f:param value="#{myBean.jobCount}" />
</h:outputFormat>
Migol
That's indeed the standard approach.
BalusC