Announcement Announcement Module
Collapse
No announcement yet.
Spring Tag format issue when using @NumberFormat with a List Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Does anyone know about this problem and solution if any. thank you
    Last edited by swarnim; Oct 19th, 2010, 12:45 AM.

    Comment


    • #3
      anyone has solution to this?

      Comment


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

        Comment


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

          Comment


          • #6
            Yes it does.

            Comment

            Working...
            X