Since I have tried many ways , all dont work!! I re-read the examples from
http://cwiki.apache.org/WW/iterator.html
and realize some things like :
quote "retrieves the value of the getDays() method of the current object on
the value stack and uses it to iterate over..."
quote "The following example uses a Bean tag and places it into the
ActionContext..."
quote " using a DAO obtained from the action class through OGNL..."
I thought, I just write class following POJO then in my JSP I just define it
as s:bean then s:iterator over it.
So how can I put my current object into value stack or into ActionContext or
into OGNL? or I am missing something here!
cvu wrote:
>
> Hi Mark,
> You're right, it does not work. I have tried this too:
> <s:bean name="test.Door" id="i"></s:bean>
> <s:bean name="test.House" id="iter"/>
> <s:iterator value="#iter.list">
> <s:property value="#i.color"/>
> </s:iterator>
> thanks
>
>
>
> Mark Menard wrote:
>>
>> On 12/27/06 2:38 PM, "cvu" <[EMAIL PROTECTED]> wrote:
>>
>>>
>>> Hi,
>>> Anyone knows how to iterate over a collection of object each object has
>>> string property:
>>> public class Door {
>>> String color;
>>> public void setColor(String color){
>>> this.color=color;
>>> }
>>> public String getColor(){
>>> return color;
>>> }
>>> }
>>> public class House {
>>> List list= new ArrayList();
>>> public House(){
>>> list.add(new Door().setColor("red");
>>> list.add(new Door().setColor("blue");
>>> }
>>> public void setDoor(Door d) {
>>> list.add(d);
>>> }
>>> public List getList(){
>>> return list;
>>> }
>>> }
>>> Would any guru shows me how to use struts2 s:iterator to iterate over a
>>> collection of Door to show the color of it ?
>>> Thanks a million
>>
>> Assuming your House is available using a getHouse() method on your Action
>> class:
>>
>> <s:iterator value="%{house.list}">
>> <s:property value="%{color}" />
>> </s:iterator>
>>
>> That's off the top of my head, and I haven't tested it. You also might
>> not
>> need the %{} on these. I don't remember at the moment. I'm tired and out
>> of
>> S2 practice having spent too much time getting a Xen setup running.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/struts2-bean-and-iterator-tf2887373.html#a8075446
Sent from the Struts - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]