This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes How  to iterate a vector attribute? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How  to iterate a vector attribute?" Watch "How  to iterate a vector attribute?" New topic
Author

How to iterate a vector attribute?

Stefano Bertz
Greenhorn

Joined: Jul 14, 2005
Posts: 3
Ih All,
I have a DTO:
class nameDTO implement serializable {
private Vector v = null;

public Vector getV() {...}
publuc Void setV(...){}

}

how can I iterate vector attibute in JSP page ?
Thanks

rgds,
Stefano

Sorry formy english ;-)
Ajay Reddy
Ranch Hand

Joined: Apr 08, 2005
Posts: 43
You can use ---

<logic:iterate id="element" name="myhashtable">
Next element is <bean:write name="element" property="value"/>
</logic:iterate>

For more info. ---

http://struts.apache.org/userGuide/struts-logic.html#iterate
Stefano Bertz
Greenhorn

Joined: Jul 14, 2005
Posts: 3
Hi,
maybe there was a misunderstanding
I have a object in session set.tribute("nameDTO",nameDTO);
where nameDTO is:

class nameDTO implement serializable {
private Vector v;

public Vector getV() {...}
publuc Void setV(...){}

}


I can't use this
<logic:iterate id="element" name="nameDTO">
Next element is <bean:write name="element" property=" ??? "/>
</logic:iterate>

instead if I do so
Vector vector = (Vector)nameDTO.getV();

where into vector: objects nameDTO2

class nameDTO2 implements Serializable {
private String thing;

public String getThing() {...}
publuc Void setThing(...){}
}

session.setAttribute("vector","vector")

<logic:iterate id="element" name="vector">
Next element is <bean:write name="element" property="thing" />
</logic:iterate>

is works !

How can I do ?

rgds,
Stefano
Stefano Bertz
Greenhorn

Joined: Jul 14, 2005
Posts: 3
I found a solution !

The solution is this:

into JSP page

<bean efine id="list" name="nameDTO" property="v" scope="session"/>
<logic:iterate name="list" id="rowNameDTO2" indexId="indice">
<bean:write name="rowNomeDTO2" property="thing"/>
</logic:iterate>

what do u thing?

Stefano
 
jQuery in Action, 2nd edition
 
subject: How to iterate a vector attribute?