To add to the previous answer, add this to the Enum declaration:
public String getLabel() { return play.i18n.Messages.get(name()); }
Be sure to use the following declaration:
#{select "[field]", items:models.[Enum].values(), valueProperty:'name', labelProperty: 'label' /}
You can also add this to Enum:
@Override public String toString() { return getLabel(); }
Which will be useful if you want to display the internationalized value in your view file (since toString is called automatically when it is displayed), but the name of the function () uses toString (), so you have to bind valueProperty to another function, as follows:
public String getLabel(){ return toString(); } public String getKey() { return super.toString(); } @Override public String toString() { return Messages.get(name()); }
And select # select:
#{select "[field]", items:models.[Enum].values(), value:flash.[field], valueProperty:'key', labelProperty: 'label' /}
source share