• 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

Struts 2 Aggregated Lists and Select Boxes

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JPA query which returns an aggregated list from a domain object. It looks something like this:
What this does is returns a list to my Action class that I can then iterate using the Struts 2 iterator tag like so:This works great for presenting lists with count relative displayed values, but when I try to display the list data in a select box, things don't work so well - meaning, I get nothing - I can't seem to access the indexed information. I've tried the following:
But the select box has no data.

Can anyone help steer me in the right direction? I'm trying to keep from having to either 1) write a separate procedure to generate this list or 2) have to build my own select list using a standard (more code to keep up with) approach:
Thanks
 
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
Not sure why you're trying to access element 0 inside an iterator, but that's a different issue.

The OGNL expression will go against the top of the stack: just use "id" and "author".
 
Eugene Williams
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply David. I've tried your recommendation and it didn't work. This is how I modified my statement:

The reason I'm doing this is because I have one named query that's used to generate all lists of books; this query is used in a number of contexts throughout the application. In certain views displaying the list, I require that the total number of books returned in the query be known, so that in paging, I can make a statement such as "Displaying 50-75 of 340 Books". Having my query return an aggregated value from "count" representing the total number of books (rows) allows me to do this (unless there's another way). In most views, I can access the data using an OGNL expression that references the indexed position of the COUNT aggregate - the aggregate resided at and the actual "book" object for the current row during iteration residing at with all relevant information about the book stored in it. As stated earlier - this methodology works flawlessly in circumstances where I'm using the "s:iterator", but in those where I have to use the "s:select" tag to access the list, I can't seem to access the column of the "book" object.

Thanks again for the response.

 
David Newton
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
It makes no sense to store the count in the list of books, besides that's it's already available as the size collection attribute.

Better to clean up the representation first, then approach the actual issue.
 
Eugene Williams
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When paging the results, the size of the list is determined by the value specified in the DAO.

Please review my first post to get a better understanding of the objective.

 
Eugene Williams
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To better clarify, in the DAO, I limit the size of the results returned by the query using the following:As you can see, the size of the list will only be 25 objects. The table contains many more. The view needs to know how many are actually in the table. This is why my SQL query includes the "count" column.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic