File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Putting it together:  Struts, Tags, OGNL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Putting it together:  Struts, Tags, OGNL" Watch "Putting it together:  Struts, Tags, OGNL" New topic
Author

Putting it together: Struts, Tags, OGNL

Eloy Vargas
Greenhorn

Joined: Mar 20, 2011
Posts: 3


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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Putting it together: Struts, Tags, OGNL