You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hartmut Bernecker <h....@dhw.de> on 2001/07/30 11:18:11 UTC

how to get the position when iterating over a vector?

Hi,

who knows how I can get the position of an object in a vector when
iterating about that vector?

<logic:iterate id="myVector" name="someBean" property="list">
<bean:write name="myVector" property="price"/>
</logic:iterate>

(I want to have the position as parameter of a link in each row).

TIA!
Hartmut

Re: how to get the position when iterating over a vector?

Posted by suhas <su...@techmas.hcltech.com>.
Check this out 
<logic:iterate id="element" name="bean" property="stringArray"
indexId="index">
  <li><em><bean:write name="element"/></em>&nbsp;[<bean:write
name="index"/>]</li>
</logic:iterate>
iterate tag which allows you to access
the
 current index as a scripting variable. If you specify the 'indexId'
 attribute, a scripting variable with the specified name will contain the
 current index (as an Integer) on each iteration

Suhas
----- Original Message ----- 
From: Hartmut Bernecker <h....@dhw.de>
To: <st...@jakarta.apache.org>
Sent: Monday, July 30, 2001 3:26 PM
Subject: Re: how to get the position when iterating over a vector?


> Oh, I see, thnx! But I have no idea how to use it;
> indexId is "The name of a page scope JSP bean that will contain the
> current index of the collection on each iteration."
> - How to use it? What is the property of the page scope bean? Do I have
> to write that bean first?
> 
> <logic:iterate id="myVector" name="someBean" property="list"
> indexId="nameOfTheBean">
> <bean:write name="myVector" property="price"/>
> <bean:write name="nameOfTheBean" property="??????????????"/>
> </logic:iterate>
> 
> Hartmut  
> 
> suhas schrieb:
> > 
> > check iterate tag in recent struts buidl - supports "indexid" as an
> > attribute .
> > 
> > Suhas
> > 
> > ----- Original Message -----
> > From: Hartmut Bernecker <h....@dhw.de>
> > To: <st...@jakarta.apache.org>
> > Sent: Monday, July 30, 2001 2:48 PM
> > Subject: how to get the position when iterating over a vector?
> > 
> > > Hi,
> > >
> > > who knows how I can get the position of an object in a vector when
> > > iterating about that vector?
> > >
> > > <logic:iterate id="myVector" name="someBean" property="list">
> > > <bean:write name="myVector" property="price"/>
> > > </logic:iterate>
> > >
> > > (I want to have the position as parameter of a link in each row).
> > >
> > > TIA!
> > > Hartmut
> 


Re: how to get the position when iterating over a vector?

Posted by Hartmut Bernecker <h....@dhw.de>.
Oh, I see, thnx! But I have no idea how to use it;
indexId is "The name of a page scope JSP bean that will contain the
current index of the collection on each iteration."
- How to use it? What is the property of the page scope bean? Do I have
to write that bean first?

<logic:iterate id="myVector" name="someBean" property="list"
indexId="nameOfTheBean">
<bean:write name="myVector" property="price"/>
<bean:write name="nameOfTheBean" property="??????????????"/>
</logic:iterate>

Hartmut  

suhas schrieb:
> 
> check iterate tag in recent struts buidl - supports "indexid" as an
> attribute .
> 
> Suhas
> 
> ----- Original Message -----
> From: Hartmut Bernecker <h....@dhw.de>
> To: <st...@jakarta.apache.org>
> Sent: Monday, July 30, 2001 2:48 PM
> Subject: how to get the position when iterating over a vector?
> 
> > Hi,
> >
> > who knows how I can get the position of an object in a vector when
> > iterating about that vector?
> >
> > <logic:iterate id="myVector" name="someBean" property="list">
> > <bean:write name="myVector" property="price"/>
> > </logic:iterate>
> >
> > (I want to have the position as parameter of a link in each row).
> >
> > TIA!
> > Hartmut

Re: how to get the position when iterating over a vector?

Posted by suhas <su...@techmas.hcltech.com>.
check iterate tag in recent struts buidl - supports "indexid" as an
attribute .

Suhas

----- Original Message -----
From: Hartmut Bernecker <h....@dhw.de>
To: <st...@jakarta.apache.org>
Sent: Monday, July 30, 2001 2:48 PM
Subject: how to get the position when iterating over a vector?


> Hi,
>
> who knows how I can get the position of an object in a vector when
> iterating about that vector?
>
> <logic:iterate id="myVector" name="someBean" property="list">
> <bean:write name="myVector" property="price"/>
> </logic:iterate>
>
> (I want to have the position as parameter of a link in each row).
>
> TIA!
> Hartmut
>