0

Hi I am using jquery autoNumeric to format my input values in currency format. I want to bind these formatted values to BigDecimal in SpringPortlet. Please let me know how I can do it ?

1 Answers1

2

If you're using spring 3+ or 4+ you should use format annotations. For example (from the spring docs):

@NumberFormat(style=Style.CURRENCY)
private BigDecimal decimal;

In the docs, section 5.6.2, there is a full description on how to enable this. I'm currently doing exactly this with the jquery autoNumeric lib and it seems to work without problems for me.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102
  • 1
    Thanks, I checked this but I get a easy work around by implementing the below webDataBinder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, NumberFormat.getCurrencyInstance(new Locale("en", "US")), false)); – blackeyes123 Apr 04 '14 at 20:23
  • 1
    That solution is good only if *all* BigDecimal instances are used for US currencies. The app I'm building uses BigDecimal for currency, but also for other values, such as percentages. – Software Engineer Apr 04 '14 at 20:34