开发者

Use message bundle in Java class with Seam with a parametric proprerty

开发者 https://www.devze.com 2023-04-05 05:10 出处:网络
Th开发者_如何学JAVAe same question Use message bundle in Java class with Seam but what when you need use a parametric property like:

Th开发者_如何学JAVAe same question Use message bundle in Java class with Seam but what when you need use a parametric property like:

message.property = Some message with {0} this parameter.

How should I use the map for doing that?

Thanks.


Inject the StatusMessages component, and call one of the addFromResourceBundle methods. You might need to change {0} to #0; I'm not sure if the Seam components make use of the MessageFormat syntax. Also, these messages can use EL and Seam components directly: #{myComponent.property}, and then you don't have to pass anything else.


This was my solution

@In
private Map<String, String> messages;
String property = messages.get("property.key");
MessageFormat.format(property, params);

Thx https://stackoverflow.com/users/115541/mac.

0

精彩评论

暂无评论...
验证码 换一张
取 消