Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display java.lang.Double using Struts in the front end

 
adrian mills
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I want to display a hospital list using struts.

Here is the problem.
I have a hospitaldata value object.
Hospital data contains the following fields

String hospitalname;
String hospitalcity;
Double hospitalid;
Integer zipcode;


I put all the hospitaldata objects in to an arrayList and set it in the request object.

I want to display the hospitalname to the user.
But when the user submits the form the hospitalid should be submitted.

Can anyone tell me how this is done.
I feel logic:iterate can be used.
But it gives problem when displaying Double values.Has anyone solved this problem.

Thanks for your help
With Regards
Adrian
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to do this would be to add a getFormattedHospitalId() and setFormattedHospitalId() method to your hospitaldata class. Have the getter method return a string which represents the the double value formatted using java.text.NumberFormat, and have the setter method convert the string to a double. You would then use the property formattedHospitalId in your jsp rather than hospitalId.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic