This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I have been looking a lot around the net, to solve my problem, but actually I feel like to be very far from solution. I have a jsp page where the user can insert a monetary value, then when the page is submitted the string should be converted in a BigDecimal value. At the beginning I had on jsp a dojo component:
and on a pojo I had just private BigDecimal currency; with set and get. I liked that situation because looked simple and I could validate currency right on client side. That solution was fine except with decimal numeric since I needed currency with comma decimal separator. So I had substituted the NumberTextBox with the following:
with this kind of dojo component I could not validate currency on client side. On server side on the pojo property I did:
This solution was fine on page submit, but then on the cancel submit of the following page to the page with currency inserted by the user, an exception was thrown TypeMismatchException. Could you please suggest me a best way to validate a currency (with decimal character and comma separator) user text field and to convert it in a BigDecimal variable? Thank you
Joined: Aug 14, 2009
Right now I'm trying, on the client side:
and on the server side I have on my pojo:
but if I insert from client side the number: 10,44 with comma separator I got the exception typeMismatch!
Joined: Aug 14, 2009
another solution that I have been trying is with converter. I defined a converter like this:
where FormatUtility.convertStringToBigDecimal is an utility method that converts numeric strings like 23232,98 to BigDecimal. On spring configuration file I wrote:
but when I submit the form the converter is not called. I thought that the above configuration would be enough to trigger the convert automatically. Thanks, bye
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: spring mvc convert from string to currency