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

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

    Hi,

    I'd like to do something like this:

    Code:
    <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: http://forum.springframework.org/sho...&postcount=12).

    I'd like to replace:
    Code:
    <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>
      </c:forEach>
      </select>
    </spring:bind>
    with something like this:
    Code:
    <form:select cssClass="form_select">
      <form:option labelMessage="chooseColor"/>
      <form:options items="${colors}" itemLabelMessage="colors"/>
    </form>
    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
    http://opensource.atlassian.com/proj...rowse/SPR-2512

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

    Comment

    Working...
    X