Facing problem with double value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Facing problem with double value

Sumit Porwal
Hi All,

     I am using " ${shoppingCart.getTotalSalesTax()?if_exists} " in ftl and
it shows the output like "4" but my requirement is to display it like "4.00"
how can I implement it? I tried to use BigDecimal object like " <#assign xyz
= "java.math.BigDecimal"?new(shoppingCart.getTotalSalesTax()?if_exists)> "
so that I can use the " setScale(decimals, rounding) " method but I got the
error given bellow:

  Error rendering included template at location
[component://xyz/webapp/xyz/order/checkout/OrderReview.ftl]:
freemarker.template.TemplateException: Class java.math.BigDecimal does not
implement freemarker.template.TemplateModel
Exception: freemarker.template.TemplateException
Message: Class java.math.BigDecimal does not implement
freemarker.template.TemplateModel

Thanks and Regards,
Sumit
Reply | Threaded
Open this post in threaded view
|

Re: Facing problem with double value

cjhowe
http://freemarker.org/docs/ref_builtins_number.html

----- Original Message ----
From: Sumit Porwal <[hidden email]>
To: [hidden email]
Sent: Wednesday, December 19, 2007 9:17:45 AM
Subject: Facing problem with double value


Hi All,

     I am using " ${shoppingCart.getTotalSalesTax()?if_exists} " in ftl
 and
it shows the output like "4" but my requirement is to display it like
 "4.00"
how can I implement it? I tried to use BigDecimal object like "
 <#assign xyz
=
 "java.math.BigDecimal"?new(shoppingCart.getTotalSalesTax()?if_exists)> "
so that I can use the " setScale(decimals, rounding) " method but I got
 the
error given bellow:

  Error rendering included template at location
[component://xyz/webapp/xyz/order/checkout/OrderReview.ftl]:
freemarker.template.TemplateException: Class java.math.BigDecimal does
 not
implement freemarker.template.TemplateModel
Exception: freemarker.template.TemplateException
Message: Class java.math.BigDecimal does not implement
freemarker.template.TemplateModel

Thanks and Regards,
Sumit



Reply | Threaded
Open this post in threaded view
|

Re: Facing problem with double value

Sumit Porwal
Thanks Chris.......and Marry X-Mas :)

On Dec 19, 2007 9:58 PM, Chris Howe <[hidden email]> wrote:

> http://freemarker.org/docs/ref_builtins_number.html
>
> ----- Original Message ----
> From: Sumit Porwal <[hidden email]>
> To: [hidden email]
> Sent: Wednesday, December 19, 2007 9:17:45 AM
> Subject: Facing problem with double value
>
>
> Hi All,
>
>     I am using " ${shoppingCart.getTotalSalesTax()?if_exists} " in ftl
>  and
> it shows the output like "4" but my requirement is to display it like
>  "4.00"
> how can I implement it? I tried to use BigDecimal object like "
>  <#assign xyz
> =
>  "java.math.BigDecimal"?new(shoppingCart.getTotalSalesTax()?if_exists)> "
> so that I can use the " setScale(decimals, rounding) " method but I got
>  the
> error given bellow:
>
>  Error rendering included template at location
> [component://xyz/webapp/xyz/order/checkout/OrderReview.ftl]:
> freemarker.template.TemplateException: Class java.math.BigDecimal does
>  not
> implement freemarker.template.TemplateModel
> Exception: freemarker.template.TemplateException
> Message: Class java.math.BigDecimal does not implement
> freemarker.template.TemplateModel
>
> Thanks and Regards,
> Sumit
>
>
>
>


--
Thanks & Regards,

Sumit Porwal
Mobile: +919926082468
HotWax Media Inc.
[hidden email]