Reputation: 6469
I have a .gsp, that displays a number in the page. The problem is, i receive that number (from the server) with decimals, even if the decimal is 0. I would like to "if the last character in this string is 0, erase from the dot till the end"
Any idea? if possible, without touching the server side.
Thank you.
Upvotes: 0
Views: 206
Reputation: 2097
You're better off treating numbers as numbers (parsing them if needed), and then using format tags that come bundled with Grails. In this case g:formatNumber would be appropriate.
Upvotes: 2
Reputation: 526
on your .gsp page do a g:if test at the place where you display the number. Check if the last character is 0, if it is, do a toString() on the number, split by the '.' and show the the string at 0th index.
Upvotes: 0