File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Reg Vector/Object in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Reg Vector/Object in struts" Watch "Reg Vector/Object in struts" New topic

Reg Vector/Object in struts

Abrahim Daver
Ranch Hand

Joined: Aug 06, 2004
Posts: 69
Hello there,
I am facing a problem for getting values from a vector(using DynaForm), which contains objects having setter/getter method.
Suppose a Vector v is having objects of a class login, which has username and password's setter/getter method. I create those empty objects and store that in vector. On other side,in JSP,I define a textfield named as v.login.username OR v.login.password. Later in action class,if I iterate through Vector v and get hold of object login, I am not able to get values of username/password in action class, using login.getUsername() OR login.getPassword.
Any suggestion, is highly appreciated.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In your JSP, you must define the name of the text field as v[0].login.username, v[0].login.password or v[1].login.username, etc. Since there could be any number of login objects in the vector, you have to specify which one you're updating. If you want the jsp to display all the Login objects in the vector and don't know how many there are, use either the <logic:iterate> or <c:forEarch> tags to iterate over the collection.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Reg Vector/Object in struts
It's not a secret anymore!