Results 1 to 6 of 6

Thread: Spring Tag format issue when using @NumberFormat with a List

  1. #1
    Join Date
    Apr 2010
    Posts
    5

    Default Spring Tag format issue when using @NumberFormat with a List

    I'm using Spring 3.0. There appears to be an issue when using the form tags or the spring:bind tag and the @NumberFormat annotation(custom ones also have this issue) to format numbers. For example

    class BeanChild {

    @NumberFormat(pattern="###,##0")
    private BigDecimal childField;

    // Getter's and Setter's omitted.

    }


    Class BeanParent {
    private List<BeanChild> childList; // there's lazy loading stuff for persisting, but I removed it and it didn't fixed the problem, hence it was omitted.

    private BeanChild properlyFormatted;

    // Getter's and Setter's omitted
    }


    <form:form modelAttribute="beanParent">
    <form:input path="properlyFormatted.childField" />

    <c:forEach var="child" items="${ beanParent.childList} varStatus="i">
    <form:input path="childList[${i.index}].childField" />
    </c:forEach>
    </form:form>

    When I use the child list in the jsp the properlyFormatted.childField gets properly formatted, the childField items in the loop do not.

    In debugging this with the Spring source, it appears to be a problem with how BeanWrapperImpl/PropertyAccessorUtils handles the List.

    Has anyone experienced this?

  2. #2
    Join Date
    Sep 2008
    Posts
    8

    Default

    Does anyone know about this problem and solution if any. thank you
    Last edited by swarnim; Oct 19th, 2010 at 12:45 AM.

  3. #3
    Join Date
    Jan 2012
    Posts
    2

    Default

    anyone has solution to this?

  4. #4
    Join Date
    Apr 2010
    Posts
    5

    Default

    The solution is to use the Spring AutoPopulatingList instead of the Apache Commons LazyList.

  5. #5
    Join Date
    Jan 2012
    Posts
    2

    Default

    I guess AutoPopluatingList addresses the dynamic list issue but does it also solve the @NumberFormat not running problem?

  6. #6
    Join Date
    Apr 2010
    Posts
    5

    Default

    Yes it does.

Tags for this Thread

Posting Permissions

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