• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Type conversion issue for Arrays

 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raymond, which version of struts are you using?
 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahh yes that would of been helpful lol. Im using 2.2.1
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic