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.