Hi, bigdecimal knows its own rounding, can't You use it? Also You can write your own bigdecimal converter, but it think it won't be necessary in this case.
Best greetings, Pawel Wielgus. 2009/9/12, ashwin ala <ashwin...@gmail.com>: > We currently display BigDecimal values in <s:textfield> tags in our jsps. > These values need to be formatted to display as currency values. Example: > "123.350000" should display as "123.35" > I extended the simple theme to create a currency theme using only the > text.ftl template file. I basically copied the text.ftl to > /template/currency and changed this line: > > <#if parameters.nameValue??> > value="<@s.property value="parameters.nameValue"/>"<#rt/> > </#if> > > to this: > <#if parameters.nameValue??> > value="<@s.property > value="%{getText('{0,number,#.00}',{parameters.nameValue})}"/>"<#rt/> > </#if> > > This does not work and gives a template error like > (WARNING: Parameters: Invalid chunk ignored.). > > The extended theme by itself does work as this line works: > <#if parameters.nameValue??> > value="<@s.property value="parameters.nameValue*5"/>"<#rt/> > </#if> > ...which multiplies the bigdecimal value by 5 before displaying. > > So can anyone let us know what is the best way to apply formatting in an > extended theme in a freemarker template? We also have some date values that > need formatting so will create another theme for that. I could add getText() > to each <s:textfield> tag explicitly but specifying a theme that handles the > formatting seems a lot cleaner. I have also tried freemarker formatting like > the one below with no success > > ${x?string("0.##")} > > Any help or pointers would be much appreciated. > > thanks > ash. > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org