New at Spring! I'm trying to translate an Enum like Gender dynamically but I do not find how. Let say I have a gender object...
public enum Gender { FEMALE, MALE; }
And I have a Controller that will use it to fill a jsp, like this....
@RequestMapping(value = "/edit-profile-about3", method = RequestMethod.GET)
public ModelAndView editProfileAbout3(ModelAndView modelAndView) {
SiteUser user = getUser();
Profile profile = profileService.getUserProfile(user);
Profile webProfile = new Profile();
webProfile.safeCopyFrom(profile);
List<Gender> gender = new ArrayList<Gender>(EnumSet.allOf(Gender.class));
modelAndView.getModel().put("gender", gender);
modelAndView.setViewName("app.editprofileabout3");
return modelAndView;
}
Now I would like to show not the values MALE and FEMALE uppercase like they show up from the Enum, but like Male and Female in English or Hombre and Mujer in Spanish in my JSP:
<form:form modelAttribute="profile" class="sky-form" id="sky-form4">
<dl class="dl-horizontal">
<dt>Gender:</dt>
<dd>
<form:radiobuttons path="gender" items="${gender}" />
</dd>
</dl>
<button class="btn-u btn-u-default" type="button" value="Cancel">Cancelar</button>
<button class="btn-u" type="submit" name="submit" value="Save">Guardar</button>
</form:form>`
How can I do it? I think it is not a properties internationalization since the jsp charges dynamically the form:radiobuttons path="gender" items="${gender}" with MALE FEMALE and I want that to be translated before it gets to the JSP (in other words, I can not use a properties to translate both Enums at the same time, right? When I get the answer to my POST Controller I want to get MALE, FEMALE, but may be show Hombre, Mujer (translation). Thanks