I have some objects of same type in action class..
E.g.:
LivingThings fish = new LivingThings("FISH");
LivingThings dog = new LivingThings("DOG");
LivingThings lion = new LivingThings("LION");
The contents of each objects will be different.
Also in the same action class I have a list with values as the name of the objects i.e.
ArrayList<String> animalsList = new ArrayList<String>();
animalsList.add("fish");
animalsList.add("dog");
animalsList.add("lion");
=====
Now in the jsp page, I need dynamically get the object contents using the animalsList
contents. i.e.
<s:iterator value="animalsList" id="eachAnimal">
<s:property value="#eachAnimal.lifespan" />
</s:iterator>
Here all I am trying to do is, instead of directly giving the code like
<s:property value="fish.lifespan" />
<s:property value="dog.lifespan" />
<s:property value="lion.lifespan" />
Somehow, I need append the object name from the animalsList
list. Is it possible in struts 2.0. I am little bit confused with OGNL concept.
I tried these scenarios:
<s:iterator value="animalsList" id="eachAnimal">
<s:property value="#eachAnimal.lifespan" />
<s:property value="%{eachAnimal}.lifespan" />
<s:property value="%{#eachAnimal}.lifespan" />
</s:iterator>
Can someone give me suggestions?