• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sticky nested lists problem in Struts 2

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, all...

I'm having trouble figuring out how to access a nested list via the <s:iterator> tag. I understand about nesting the <s:iterator> tag in my JSP, but my returned list is a little complicated.

My basic list is a list of a type called Record which is basically just a hash map. What I'm trying to accomplish is returning a list that contains some properties of a particular row in a table, and then has some sub-lists of accounts that have hit targets, missed them, or have no data. Note that in the following description square brackets ([) indicate a list and curly braces ({) indicate a Record, which is a hash map. So my basic list item looks like this:

[ {header record}, [{ item1=value, item2=value, item3=value, hits=[{account=, id=}, {account=, id=}...], miss=[{account=, id=}, {account=, id=}...] } ] ]

The hits, miss, and nodata (not shown here) could have any number of accounts or could be an empty list. The super-high level diagram of what my list looks like, taking into account that structure above, looks like this:

[main list: {header record}, [list: {items [list], [list], [list]} ], [list: {items [list], [list], [list]} ], {header record}, [list: {items [list], [list], [list]} ], ... ]


My JSP code, then, to display the data, looks like this:



For the life of me, I can't figure out how to access the list values of "account" and "id" from the "hits" and "misses" list. I've tried the following ways to access them:

<s:iterator value="hits">
<s:iterator value="#hits">
and within the code where the values are used, <s:property value="#hits.account"/> or even <s:property value="%{#hits.account}"/>

Can anyone help me figure out how to access these sub lists? I think that the main issue here is that my list isn't a straight list of lists - there are some items that I need to get for the overall row, and the sublists are just a part of that record. Any ideas would be welcomed, because I'm really at a wall here.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what your JSON-like stuff is supposed to represent. Sure would have been a lot easier to just pseudo-code the actual Java object(s) you're sending.

If you're using a list as a poor-man's object, I wouldn't iterate over the "meta"-list, but access its elements directly. But this is, in general, a Bad Idea. Send an object that exposes the lists: keep it clean.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic