I thought this would be an automatic:
<rich:tooltip value="Download (#{doc.size div 1024 + 1} KB)" />
I need to calculate the number of KB a file has for downloading (size is integral). In regular Java code the same calculation would truncate the fractional part and return that remaining integer. In JSF EL however, there’s no truncating division, so the division return a float.
How is it done in EL anyway – that is without introducing a bean method that does the job?
You can use
fn:split()to get rid of the fraction.Be cautious: it’s locale dependent. On some locales it’s a comma
,. I’d rather create/use an EL function for the job, something like as OmniFacesof:formatBytes()is doing.