Does #{messages[color.key]} work?
Also to accomplish this in my app using facelets I created a facelets
function 'concat' so that I could do something like:
#{messages[custom:concat('colors', color)]} That way I didn't have to
put i18N keys in my Enum.
Mike
On 4/4/07, Adam Brod <ABrod_at_intralinks.com> wrote:
>
> Hi-
>
> We've got some Enums in our backend code. We need to display those enums in
> an i18n way. I was thinking of having the Enum return a String message key.
> For example, the enums could implement this interface:
>
> public interface I18n {
> /** @return key to a property bundle */
> public String getKey();
> }
>
> public enum Color implements I18n {
> RED("colors.red"),
> BLUE("colors.blue");
>
> private String key;
> public Color(String key) { this.key = key; }
> public String getKey() { return this.key; }
> }
>
> Then, in my page I want to be able to use an EL expression to get the
> message key from the object. For example:
>
> <ui:iterate var="color" value="#{controller.colors}">
> <li>#{messages.color.key}</li>
> </ui:iterate>
>
> However, this tries to load the message key "color.key" not "colors.red".
> Is there a way I can get the EL to evaluate the section after messages as
> another expression? Alternately, is there a more standard way to use Enums
> with interationalization?
>
> Thanks,
>
> Adam Brod
> Product Development Team
> Disclaimer: This electronic mail and any attachments are confidential and
> may be privileged. If you are not the intended recipient, please notify the
> sender immediately by replying to this email, and destroy all copies of this
> email and any attachments. Thank you.
>
>