-
Apr 15th, 2010, 02:05 PM
#1
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?
-
Oct 19th, 2010, 12:41 AM
#2
Does anyone know about this problem and solution if any. thank you
Last edited by swarnim; Oct 19th, 2010 at 12:45 AM.
-
Jan 12th, 2012, 04:36 PM
#3
anyone has solution to this?
-
Jan 13th, 2012, 08:24 AM
#4
The solution is to use the Spring AutoPopulatingList instead of the Apache Commons LazyList.
-
Jan 13th, 2012, 06:20 PM
#5
I guess AutoPopluatingList addresses the dynamic list issue but does it also solve the @NumberFormat not running problem?
-
Jan 13th, 2012, 06:25 PM
#6
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
-
Forum Rules