java - String representation of an integer division in EL (not truncated)? -


i thought automatic:

<rich:tooltip value="download (#{doc.size div 1024 + 1} kb)" /> 

i need calculate number of kb file has downloading (size integral). in regular java code same calculation truncate fractional part , return remaining integer. in jsf el however, there's no truncating division, division return float.

how done in el anyway - without introducing bean method job?

you can use fn:split() rid of fraction.

<ui:param name="size" value="#{fn:split(doc.size / 1024, '.')[0]}" /> <rich:tooltip value="download (#{size + 1} kb)" /> 

be cautious: it's locale dependent. on locales it's comma ,. i'd rather create/use el function job, omnifaces of:formatbytes() doing.

<rich:tooltip value="download (#{of:formatbytes(doc.size)})" /> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -