Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Iteator Tag with object in object

 
Srinivas Anumala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code please.
 
Srinivas Anumala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Struts?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the action configuration.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's working fine for me with your original code--your compilation issues might be a problem.
 
Srinivas Anumala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Thanks for your time. Please ignore my last comment.

Its resolved.

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's polite to include what the issue was in the followup, but I'm glad you got it resolved.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic