You can use these attributes to format the display of your form bean properties. This works pretty well in displaying currency and date/time values. For example, you can display 1234.567 as $1,234.57 and 08/12/2006 as Aug 12, 2006.
In order to get the second tag to work you will need to add the following line to your resource bundle:
The preferred way is to use the second format because it makes the code portable. Plus, if you want to change the format, you can make the change in resource bundle without having to worry about changing all your JSPs.
The type of the property being formatted cannot be String. The format attribute simply uses default format (display the property as is) when the property is of type java.lang.String. In other words:
private double amount; // will be formatted correctly private String amount; // will NOT be formatted at all
- <bean:write name="myForm" property="amount" format="$#,000.00" />
- <bean:write name="myForm" property="amount" formatKey="myapp.currency.format" />
You need to login to post a comment.