• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Date and Dollar amounts in Form Beans

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I saw that <bean:write> has a "format" attribute for formatting dates and dollar values. But I didn't see similar thing for <html:text>. If my bean has a property called "amount" of type BigDecimal, and I want to display that as a <html:text> for the user to modify the value, How can I format it?

Also, if the user leaves the <html:text> field for BigDecimal as blank, I get an exception. So, is the solution to this is to make all formbean properties to be "String" type?


Thanks,
Kiran
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, chaging your ActionForm property to type String is recommended. Convert the BigDecimal to a String when populating your form bean. When the user submits the form, you would then apply validation logic to the property to test whether it will convert to the desired numeric type and scope. Once it has passed validation, you can then convert it back to BigDecimal for use in your model classes.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic