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.
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?
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.