Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg Vector/Object in struts

 
Abrahim Daver
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Thanks,
Abra
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic