• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterate through multiple arrays

 
Hasif Subair
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 Arrays, say a[],b[] and c[]. I need to loop through these arrays and show the values on a jsp.



This can be done using scriptlets. but i am avoiding it completely. I need some tag to iterate all three array at once. Is it possible with <logic:iterate> tag or is there any other way to do this
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It'd be substantially cleaner, and easier to test, to build a proper data transfer object on the server side. Iterate through *that* on the JSP side.
 
Hasif Subair
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually David, i am getting these arrays from a html table. This table have more than one fields with the same property name. So when the form is submit it creates an array of values. These tables are dynamically added to the form, so their number is uncertain.

here are the codes from jsp files.



when the hyperlink is clicked the rows below are added to the form within the <div id="spec"> using ajax.


when you submit, it creates an array values for the above fields and are saved in action form. Now what i want, is to display the values of these field to the user in another jsp.

is there any better way of doing this?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how that makes my suggestion not work.
 
Hasif Subair
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because My data transfer objects has some variables other than these arrays. These variable does not required to be iterated.

i resolved the issue by the following method.
I knew it, but didn't test it before posting it here.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic