Announcement Announcement Module
No announcement yet.
Using the Form-Taglib with MessageSource to display an enum Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using the Form-Taglib with MessageSource to display an enum


    I'd like to do something like this:

    <form:option value="none" label="<spring:message code="message"/>"/>
    But it doesn't work:
    /WEB-INF/jsp/test.jsp(55,83) equal symbol expected
    Any ideas?

    What I ultimately want is to display an enum and getting the lables by using the same message source (I have explained my way of doing that in this post:

    I'd like to replace:
    <spring:bind path="testClass.color">
      <input type="hidden" name="_${status.expression}"/>
      <select name="${status.expression}" class="form_select">
      <option value=""><spring:message code="chooseColor"/></option>
      <c:forEach items="${colors}" var="color">
        <option value="${color}"<c:if test="${status.value == color}"> selected="selected"</c:if>><spring:message code="colors.${color}"/></option>
    with something like this:
    <form:select cssClass="form_select">
      <form:option labelMessage="chooseColor"/>
      <form:options items="${colors}" itemLabelMessage="colors"/>
    I would be interested if this is the "correct" way to provide internationalized messages for enum at all. I didn't want to extend all my Enums with functions to provide the messages themselves.

    So is there any possible way to do this with the form-taglib, if not will something like this be added or is there a better way to achieve what I want?

    Thank you for your help!

  • #2

    Better I18N integration with the formtag library is scheduled for 2.1.