Hi Spring experts,
I have a problem trying to get formatters to be applied when I return a list of my model object. It works when saving/binding the object but not when displaying the objects in a list.
Here's the scenario.
The format is applied when saving. egCode:public class Customer { @Numberformat(pattern="#,###.00") BigDecimal salary; }
However, when I have List<Customer> and am iterating through each and displaying on a table, I can't get the formatter to apply. egCode:<form:form commandName="customer"> ... <spring:bind path="salary"> <input type="text" ... value="${status.value}"/> </spring:bind> </form:form>
I've also tried to wrap the bind in a <form:form> but it also doesn't work. egCode:<table> <c:forEach items="${customers}" var="customer"> <c:set var="customer" value="${customer}" scope="request"/> <tr> <td><spring:bind path="customer.salary">${status.value}</spring:bind></td> </tr> </c:forEach> </table>
I'm guessing that's because there isn't a request model object bound to BindingResult.MODEL_KEY_PREFIX + "customer" ... but how do I get one in there when iterating through my List<Customer>?Code:<td> <form:form commandName="customer"> <spring:bind path="salary">${status.value}</spring:bind> </form:form> </td>
Can someone show me where I went wrong here and how I can activate the formatters?
thanks,
dave


Reply With Quote
