• 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

Putting it together: Struts, Tags, OGNL

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have a very specific issue that I have researched all weekend and just can't find the right answer. It's driving me crazy!! I could proabably come up with a different solution, but I know I am close to making this work. I don't want to give up!!!

I am developing a Web application using Struts 2 and JPA/Hibernate. I have a great deal of experience with Struts 1.x and EJB 2 persistence but little with the more current technology. So I have decided I will upgrade my skills while I am working on this new development. I think I can explain my problem without including every line of code leading up to it.

In my JPA I have a DAO that reads all the instances of a one to many relationship and builds a list in the data object. I use auto increment for all my tables so all instances of the JPA objects will have an id field containing the key for the object. I have a situation where I need to display all the objects that exist under the primary and allow the user to select one of them along with other data. The radio button is just made for this. The description of the object is so long I want to build a vertical list of the radio buttons beside the lengthy description. Actually I am attempting to build a table with 4 columns. The first column is the radio button and the other three colums contain information from that instance. I want the value of each radio button to be the value of the id key value for each entry.

So in my JAP object I have a list of objects that represent the one-to-many relationship. I expose the primary object containing the list in my action class.

Here is the code in my jsp:



Notice what I have put in the list parameter of the s:radio function. The code generates output using this code. However, the value of every single entry is 1. Notice also that I have ${current.id} beside the radio button. This contains the key that I want to use for the radio button. It displays on the page just fine.

I have researched for hours, hours and more hours. I have tried both "c:forEach" and "s:iterator". I can't get this to work!!!

I know the answer will be embarasingly simple but I want to replace the


With something like (I have tried NUMEROUS variations based on what I have encountered on the 'net):


or

or


Or whatever I can make this work properly.

Everything I have tried results in the error:


tag 'radio', field 'list', name 'masterKey': The requested list key '#{${current.id}:''}' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]



Please!! Help me with this. How do I change the list parm to make this work?
 
reply
    Bookmark Topic Watch Topic
  • New Topic