Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

IndexedProperties doubt

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a ArrayList which has a bunch of DTO objects.

Following are the attributes in the DTO object.

1. String empName;
2. Integer empNumber;
3. java.util.Date doj;

I am iterating the arraylist in the jsp using logic:iterate and using bean:write, just to display the values in a table.

Is there any problem with the data types in the DTO object. Will this work, since the DTO doesn't have simple String objects.

I am just displaying the values in a table.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vishnu Prakash:
Is there any problem with the data types in the DTO object.


There's no problem with the data types as long as you're just displaying the values. It's only when you're creating input controls for these values that you would run into problems with non-String properties.
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what problems will we run into ? ( I am using indexed properties for first time ...)

In my grid ( which is editable ), my objects contain some int . Will Struts convert it into String before displaying and convert it back to int ? or should I convert into String and take care of int conversion in my Model class. ?

Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts will handle the conversion to and from int, but I still don't think it's a good idea to use it here. Struts will not handle the object wrapper Integer, or any other objects such as java.util.Date.

Here are reasons why it's not a good idea. The first is that uninitialized values will show as "0" instead of blank. Another is that if the user enters a non-numeric value in the field, Struts will throw a NumberFormatException. It's better to define the fields as String in the ActionForm and its contained objects and convert them to other data types later if you need to.

This is one area where Struts 1 is showing its age. Newer frameworks such as JSF and Struts 2 do handle data conversions and provide friendly error messages when the conversion fails.
[ July 31, 2007: Message edited by: Merrill Higginson ]
 
Bring out your dead! Or a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic