Results 1 to 2 of 2

Thread: How to use a Formatter on a String with the spring:eval tag?

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Default How to use a Formatter on a String with the spring:eval tag?

    I ran into a small problem today when I wanted to show a String property using spring:eval tag. The property has a custom converter associated with it using the AnnotationFormatterFactory.

    When the property is rendered using a form:input tag everything works as expected and the formatted output is shown.
    If the same property is rendered using the spring:eval tag the original, unformatted, value is shown.

    This is caused by the convertTypedValue() method in the ExpressionUtils class determining that the expression value is already a String and will not using the TypeConverter. I can imagine that most of the time this is the desired behavior, but when formatting a string it causes a problem.

    Maybe the spring:eval tag should get another attribute to indicate that the conversionservice should be used even if the type is already a String?

  2. #2
    Join Date
    Sep 2004
    Posts
    1

    Default

    I am running into the same issue. My custom formatter (declared in FormattingConversionServiceFactoryBean) is applied to fields on a form-backing bean, but in any other scenario where I place an object into a ModelMap and attempt to display it on my .jsp, the formatter is not applied.

    Does anyone have an approach that works?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •