wood burning stoves 2.0*
The moose likes Struts and the fly likes Type conversion issue for Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Type conversion issue for Arrays" Watch "Type conversion issue for Arrays" New topic
Author

Type conversion issue for Arrays

Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 81
I know how to catch the type conversion error and display a custom message (ie: invalid.fieldvalue.fieldname). The issue im having is when its an array that gets caught in the type conversion. For instance if i have an Array of doubles



when i validate that and one of the fields is incorrect I will a message that says something like this

Invalid field value for field "units[1]".

even though I have this message defined

invalid.fieldvalue.units

sooooo....do i seriously need to have a message defined for each array element?? there has to be a better way to do it than
invalid.fieldvalue.fieldname[0] ... invalid.fieldvalue.fieldname[n]

i mean what if its a dynamic sized array or you have ALOT of elements. that doesn't seem right at all!!
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Raymond, which version of struts are you using?


Have Fun with Java
little,little.. little by little makes a lot..
Raymond Holguin
Ranch Hand

Joined: Aug 11, 2009
Posts: 81
ahh yes that would of been helpful lol. Im using 2.2.1
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

In earlier versions (before 2) it was too easy but i am not sure about the Struts 2 and i didnt find much in my search to learn the same. In earlier versions you could have just {0},{1},.. etc in the value part of the properties file and you can just pass the dynamic values in JSPs..
Just found that the same is possible in Struts2 as well (in the same way).. I saw only one related post here, just have a try. I didnt try it myself
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Type conversion issue for Arrays