| Author |
Struts2 Iteator Tag with object in object
|
Srinivas Anumala
Greenhorn
Joined: Dec 22, 2004
Posts: 5
|
|
Hi
I have following data structure in my action class.
Action class has list of reports.
List<Report> reports;
I have created list in action class and trying get the values in JSP using <s:iterator> tag.
I am able to get report.id value... but could not get "report.user.name" value
Any suggestion how to retrieve "report.user.name" value in iterator tag .
Thanks
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
Code please.
|
 |
Srinivas Anumala
Greenhorn
Joined: Dec 22, 2004
Posts: 5
|
|
Here are the code details.
User Class:
Report Class:
Action Class:
In JSP, using the following iterator tag to retrieve the data from list:
Please suggest how to retrieve "report.user.name" in this case ? Thanks
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
I don't see anything obviously wrong, but I'm distracted at the moment.
Try assigning each report to a variable and accessing it directly using the iterator tag's "var" or "id" attribute (depends on S2 version) first.
|
 |
Srinivas Anumala
Greenhorn
Joined: Dec 22, 2004
Posts: 5
|
|
Hi david,
I have tried using iterator tag as shown below.
This also giving me only id, but did not work
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
What version of Struts?
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
That code won't even compile--are you sure you're deploying what you think you are?
If that's not the actual code, then save us both some time--post accurate information.
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
And the action configuration.
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
It's working fine for me with your original code--your compilation issues might be a problem.
|
 |
Srinivas Anumala
Greenhorn
Joined: Dec 22, 2004
Posts: 5
|
|
I am using Struts 2.1.8.
Its compiled for me and no compilation errors using both versions of tag code.
Please let me know which version you are using and tag code which you used.
Thanks
|
 |
Srinivas Anumala
Greenhorn
Joined: Dec 22, 2004
Posts: 5
|
|
Hi David,
Thanks for your time. Please ignore my last comment.
Its resolved.
Thanks
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
It's polite to include what the issue was in the followup, but I'm glad you got it resolved.
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
Srinivas Anumala wrote:Its compiled for me and no compilation errors using both versions of tag code.
There is *no* possible way the code you posted above compiled.
|
 |
 |
|
|
subject: Struts2 Iteator Tag with object in object
|
|
|