IndexedProperties doubt
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
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.
posted 18 years ago
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.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
Merrill
Consultant, Sima Solutions
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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 ]
Merrill
Consultant, Sima Solutions
| when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |






