Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to create dynamic <s:property tag using <s:iterator

 
Suresh Ganti
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anyone suggest me the solution for the below problem.

I have iterators have list of objects in both the iterators. What exactly I am doing is I am iterating the first list and for each object in that list I have to iterator the second list of objects which are having the property names of first object iterated and I want to display the values of first object in jsp. Please find the sample code below.



In the code shown above 'tableData' contains list of user defined objects. I am iterating the list of objects and some fields available in the object I am displaying directly using <s:property /> tag. But some filed names are stored in the object 'selectedColumns'. I want to display the values of the first object using the secord object field name by dinamically creating the <s:property tag.

I have used like this <s:property value='<s:property value="key" />' /> but it didnt work.
Can you please any one tel me the solution how this can be done.

Thanks,
Suresh.

 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It didn't work


Okay, but what is happening when you are doing that?
 
Suresh Ganti
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Its is displaying empty space. Do you have any solution how can we do using struts2
Thanks,
Suresh.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the code shown above 'tableData' contains list of user defined objects. I am iterating the list of objects and some fields available in the object I am displaying directly using <s:property /> tag. But some filed names are stored in the object 'selectedColumns'. I want to display the values of the first object using the secord object field name by dinamically creating the <s:property tag.


List><TableData> tableData;

TableData is hold selectedColumns object right?
 
sarath j nair
Greenhorn
Posts: 11
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example, 'countries' is the first list of country objects, and cities is the second list to get all cities based on countries what comes in top
I need one value from countries to compare with cities. I actual call you will not get. So you should use like "<s:property value="[1].name"/>"
that means,

country = value from countries list
city = value from cities list

<s:if test="[1].country == city">



The output looks like

Wellington, New Zealand
Auckland, New Zealand
Moscow, Russia
Glasgow, Scotland
Edinburgh, Scotland
Stockholm, Sweden

I think your Doubt may clear....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic