You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mathias-ewald <ni...@gmx.net> on 2009/07/17 07:36:36 UTC

in JSP: rounding values

Hi,

I want to round a value during an interation:

------------------------------------------
<s:sort comparator="mapComparator" source="statsMap">
<s:iterator>
<tr>
	<td><s:property value="key.name" /><br>(Min: <s:property value="key.min"
/>, Max: <s:property value="key.max" />)</td>
	<td>
		<s:set name="average" value="value.average" />
		<%
			int val = 0;
		%>
		
		<s:property value="val" />
	</td>
</tr>
</s:iterator>
</s:sort>
------------------------------------------

As you can see, I iterate over a map. The value element of the map contains
a field named "averate". This average is a Float which I want to round
(Math.round()). I don't really know how to do that. I can find out how to
access the value from within <% %>. Once I have access to it, how can I
print that value? I never actually used <% %> tags.

Or ist there an easier way?

The whole idea if this code is to display ratings of serveral criteria where
a rating has a minimum value of key.min, a maximum of key.max and the
average rating is value.average. I want these values to be displays using
star icons. I am telling you this hoping there is a much easier way ;)

cu
mathias
-- 
View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24528871.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: in JSP: rounding values

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/7/17 mathias-ewald <ni...@gmx.net>:
> Okay, it was just my understanding of the whole thing. I will do as you
> suggested.

It even will be faster than searching for some strange solution with
Struts2 Tags ;-)


Regards
-- 
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/

Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have
given us arms." -
http://www.brainyquote.com/quotes/authors/m/mike_ditka.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: in JSP: rounding values

Posted by mathias-ewald <ni...@gmx.net>.
Okay, it was just my understanding of the whole thing. I will do as you
suggested.

cu


Lukasz Lenart wrote:
> 
> 2009/7/17 mathias-ewald <ni...@gmx.net>:
>> I don't think so - I want the exact value to be shown, too, so it's more
>> a UI
>> thing.
> 
> As you thing, but that's the business logic and even such simple
> operation shouldn't be performed in UI. Maybe it will be simpler to
> create TransferObject with original value and rounded value and put it
> on the list.
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> http://dailylog.lenart.org.pl/
> 
> Pablo Picasso  - "Computers are useless. They can only give you
> answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24531973.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: in JSP: rounding values

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/7/17 mathias-ewald <ni...@gmx.net>:
> I don't think so - I want the exact value to be shown, too, so it's more a UI
> thing.

As you thing, but that's the business logic and even such simple
operation shouldn't be performed in UI. Maybe it will be simpler to
create TransferObject with original value and rounded value and put it
on the list.


Regards
-- 
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/

Pablo Picasso  - "Computers are useless. They can only give you
answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: in JSP: rounding values

Posted by mathias-ewald <ni...@gmx.net>.
I don't think so - I want the exact value to be shown, too, so it's more a UI
thing.


Lukasz Lenart wrote:
> 
> 2009/7/17 mathias-ewald <ni...@gmx.net>:
>> I want to round a value during an interation:
> 
> Maybe it will be better to prepare a list on server side with rounded
> values and iterate over them?
> 
> 
> Regards
> -- 
> Lukasz
> http://www.lenart.org.pl/
> http://dailylog.lenart.org.pl/
> 
> Pablo Picasso  - "Computers are useless. They can only give you
> answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24530364.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: in JSP: rounding values

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/7/17 mathias-ewald <ni...@gmx.net>:
> I want to round a value during an interation:

Maybe it will be better to prepare a list on server side with rounded
values and iterate over them?


Regards
-- 
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/

Pablo Picasso  - "Computers are useless. They can only give you
answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org