You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Dowd, Brian" <bd...@lehman.COM> on 2002/06/10 16:22:51 UTC
Formatting double/floats in bean:write and html:text
Hi,
I'm a relative newbie to struts, so apologies if this is a simple
question, I did look
around and failed to find the answer. Basically I want to know how to
display a
number in specific ways using the <bean:write ...> <html:text...> mechanisms
where
the number is a double, i.e. rather than the number "1.2459999999" appearing
I want
to arbitrarily be able to display it to s specific number of decimal places,
i.e. 3 above
giving me "1.246". Also, is there any way to specify parenthesising
negative numbers
i.e. instead of -23 display (23) (This is common format in banking). Has
anyone done
this ? I would have expected there to be some kind of attributes on the
tags to allow
for the specification of NumberFormat details (i.e. such as locale,
grouping, places etc)
but I couldn't find any such one ...... I would rather not subclass the
bean:write and
html:text tags for this purpose .... any ideas ?
Thanks in advance.
Brian.
------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Formatting double/floats in bean:write and html:text
Posted by Nic Holbrook <mo...@xmission.com>.
I already had a tag, so I don't use the struts version, but the one I
implemented I added a parameter called formatter which is the name of a
bean on the page that implements the Formatter interface in java. Works
really nice. I'm sure it wouldn't be hard to extend the bean:write to
take a formatter parameter and apply it to the output.
Nic
Dowd, Brian wrote:
>Hi,
> I'm a relative newbie to struts, so apologies if this is a simple
>question, I did look
>around and failed to find the answer. Basically I want to know how to
>display a
>number in specific ways using the <bean:write ...> <html:text...> mechanisms
>where
>the number is a double, i.e. rather than the number "1.2459999999" appearing
>I want
>to arbitrarily be able to display it to s specific number of decimal places,
>i.e. 3 above
>giving me "1.246". Also, is there any way to specify parenthesising
>negative numbers
>i.e. instead of -23 display (23) (This is common format in banking). Has
>anyone done
>this ? I would have expected there to be some kind of attributes on the
>tags to allow
>for the specification of NumberFormat details (i.e. such as locale,
>grouping, places etc)
>but I couldn't find any such one ...... I would rather not subclass the
>bean:write and
>html:text tags for this purpose .... any ideas ?
>
>Thanks in advance.
>Brian.
>
>
>------------------------------------------------------------------------------
>This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
>
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>