The moose likes Struts and the fly likes Need to create dynamic <s:property tag using <s:iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need to create dynamic <s:property tag using <s:iterator" Watch "Need to create dynamic <s:property tag using <s:iterator" New topic
Author

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

Suresh Ganti
Greenhorn

Joined: Jun 12, 2011
Posts: 11
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

Joined: Aug 01, 2007
Posts: 485

It didn't work


Okay, but what is happening when you are doing that?


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Suresh Ganti
Greenhorn

Joined: Jun 12, 2011
Posts: 11
Hi,
Its is displaying empty space. Do you have any solution how can we do using struts2
Thanks,
Suresh.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

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

Joined: Nov 10, 2011
Posts: 11

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....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to create dynamic <s:property tag using <s:iterator