Announcement Announcement Module
Collapse
No announcement yet.
Passing message code as argument in message tag Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing message code as argument in message tag

    Hello all,

    Is there a way to tell spring:message tag to treat/resolve arguments attribute as message code?

    Example:

    If in messages.properties one has:

    Code:
    ...
    someclass.somefield.name=somefieldname
    field.required=Field "{0}" is required.
    ...
    in a validator:

    Code:
    ...
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "somefield", "field.required", new Object[] {"someclass.somefield.name"});
    ...
    and in JSP view:

    Code:
    ...
    <c:forEach items="${errors.fieldErrors}" var="fieldError">
    <spring:message code="${fieldError.code}" arguments="${fieldError.arguments}"/>
    </c:forEach> ...


    If I understood well, currently this can not be done, and I have to pass arguments array with already resolved messages, e.g.

    Code:
    ...
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "somefield", "field.required", new Object[] {messageSource.getMessage("someclass.somefield.name", null, locale)});
    ...
    Thanks in advance for feedback!
    Last edited by sslavic; Oct 21st, 2008, 11:09 AM.
Working...
X