• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding form property as array

 
krish chaitu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have some basic question like
can i have a form bean having setters & getters for a firstname textfield on the screen with each text field has different property name for example like
first text box will have firstname ,second will have firstname1 etc for 10 text boxes & i want all this to be in array
can i define something like
public void setFirstName(String[] firstName){}

public String[] getFirstName(){}

Please help in this problem,

i need to figure out how i can make this working

Thanks
krish
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they all have the same name, you can retrieve them as an array with request.getPropertyValues.

See:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html
 
krish chaitu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

my problem is with the user entry .so i have in my entry screen for user to enter contact information & i have 5 contact informations for the user to enter ,so instead of having 15 first name setters & getters properties , i want to find some easiest solution to make the form bean not to have too many setters & getters.

so can i know how i can make the form bean proeprty to have all this 15 firstnames with one setter & getter methods.

Please help me out in this issue, iam already in big trouble to sort it.


Thanks
krish
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider representing this as a list of beans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic