5

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>
Luca Molteni
  • 5,230
  • 5
  • 34
  • 42
Sam
  • 8,387
  • 19
  • 62
  • 97

2 Answers2

12

I think this should work:

<h:outputFormat value="#{msg.yourMessage}">
  <f:param value="#{myBean.jobCount}" />
</h:outputFormat>
Migol
  • 8,161
  • 8
  • 47
  • 69
2

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);
    }
}
Luca Molteni
  • 5,230
  • 5
  • 34
  • 42