Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Iterating for non-collection object

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying to create some sort of dynamic table with different rows and columns. Each cell in the table should contain one checkbox each.

Here's my action form. intColumnCount represents number of columns. intRowCount represents number of rows.



in my JSP i need to display them so I use logic iterate.



But I am getting error Cannot create iterator for this collection.
I am thinking its because, I cant iterate on non-collection object (intColumnCount and intRowCount). I need those two variable so I could generate my <tr></tr> and <td></td> html tags.

Is there a way I can iterate on non-collection object without using scripting? I hope I had explained things clearly. Thanks.
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I found my answer to my question but I had to resort to using scripting in my JSP wherein I need to display something like this.

element1 element2 element3
element4 element5 element6
element7 element8 element9

wherein each element represents 1 checkbox. Some sort of a minesweeper game on the web.





I cant find any ways on how to implement this using struts tag alone only.
My JSP looks bad with scripting on it and I cant generate a closing </tr> tag for my JSP also. But either way, my browser interpreted it as is and displayed it correctly.

Hope someone has better idea on how to implement this because I'm trying to avoid scripting in my JSP. But on my own, I think scripting still comes handy in some rare cases, am i right in this? Thanks.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another option would be to transform your data into a two dimensional array in your action class and then use nested iterate tags. I am not sure this would be a "better" solution but it would get rid of the scriptlet code.

- Brent
 
You've gotta fight it! Don't give in! Read this tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic