To get the first element of the Vector set the length=1 in the iterate tag
for example:

<logic:iterate id="currRecord" name="beanName" property="vectorName"
length="1">
 <bean:write name="currRecord" property="name"/>
 <bean:write name="currRecord" property="desc"/>
 <bean:write name="currRecord" property="price"/>
 <bean:write name="currRecord" property="storeroom"/>
 <bean:write name="currRecord" property="buyer"/>
</logic:iterate>


Then to read the rest of the entries in the vector set the offset of the
iterate to such as:
<logic:iterate id="currRecord" name="beanName" property="vectorName"
offset="1">
 <bean:write name="currRecord" property="name"/>
 <bean:write name="currRecord" property="desc"/>
 <bean:write name="currRecord" property="price"/>
 <bean:write name="currRecord" property="storeroom"/>
 <bean:write name="currRecord" property="buyer"/>
</logic:iterate>


Kimberly MacKellar

-----Original Message-----
From: Alex Colic [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 04, 2001 7:17 AM
To: Struts
Subject: REPOST: A hint how to do the following with a bean.


Hi,

Need a hint on how to do the following:

I have a bean which is a vector of items. Each item object has a name,
description price etc. When the user selects an item I create this vector
and pass it to a page which iterates through the vector and creates a table.
Something like:

name     desc     price     storeroom    buyer

The table I get has the same data for the first two rows. I want to take out
those first two rows and place them into the table caption. Without
iterating through the vector how can I get the name and desc property of the
first item. That data is going to be the same for all the other items in the
vector.

Thanks for any help.

Alex

Reply via email to