aspose file tools*
The moose likes Struts and the fly likes Displaying Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Displaying Data" Watch "Displaying Data" New topic
Author

Displaying Data

Prasath Thirumoorthy
Ranch Hand

Joined: Jul 23, 2004
Posts: 65
Hi Friends,

Im working in Struts Project.In my TransferObject the data type of an attribute(Say Market Price) is Double.While populating the values from database its displaying the data in the jsp with Exponential like 1.82684971E8

How to Avoid the E8 user doesnt want to show this in the Jsp.

Thanks in Advance

Cheers,
Prasath


Thanks,
Prasath

SCJP1.4, SCWCD
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try this:

<bean:write name="myBean" property="myDouble" formatKey="" />

This will write the number using the default number format for the locale.


Merrill
Consultant, Sima Solutions
Prasath Thirumoorthy
Ranch Hand

Joined: Jul 23, 2004
Posts: 65
Dear Merrill Higginson ,

Ya its working fine.Thank u very much.

Here is the piece of code what I used.
**************************************************************************
In my JSP:

<bean:write name="myBean" property="myDouble" formatKey="currencyFormat"/>
**************************************************************************
In my Resource Bundle:I added
currencyFormat = #,##0.00
**************************************************************************

Now The format is in US.But now I Need to customize the format according to type of Currency like USD, CLP, EUR, GBP...How can i do this.
Please kindly give me some idea..

Thanks in Advance

Cheers,
Prasath
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If the type of currency used is always tied to the locale of the user, you could simply create an ApplicationResources_xx_xx.properties files for each locale and put the appropriate currency symbol in the currencyFormat key for each of these properties files.

See this link for an explanation of how Struts handles resource bundles for internationalization.

If you can't always tie the currency to the locale, you will have to create a new getter for the bean (for example: getFormattedAmount) in which you put your own logic to format the amount with the appropriate currency symbol. In the JSP, you would then just write:

<bean:write name="myBean" property="formattedAmount" />
[ March 14, 2006: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying Data