This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi I have a .jsp page that has forms for entering information. Let's say this page has forms to enter X Users into a database. on a website. In my HTML code I can seperate each FORM by giving them a name, but the problem is when I submit this page to another .jsp where I want to do <jsp:useBean name="someUsers"/> and <jsp:setProperty name="someUsers" property="*"/> Will the setProperty tag create an Array of Users so that each form is one user? If not, CAN I setup the useBean to make an array of Users? If my original page had only 1 form and I did the useBean and setProperty it would populate the bean with the user information, but I would really like to be able to process multiple users at once. Oh yeah, the page with the multiple user forms can have an undetermined number of User forms. I can also do something like pass a value of 'total forms' and then loop through them populating User objects but this is messy and also doesn't allow me to seperate my business logic from the display. I would much rather setProperty and then pass my array/collection of Users to my servlet for processing. Any help would be very appreciated. Thanks.
If I understand what you are trying to do - it isn't possible. Only one <form> .. </form> at a time can be submitted in a request. "Will the setProperty tag create an Array of Users so that each form is one user? If not, CAN I setup the useBean to make an array of Users?" The setProperty tag is going to be calling methods based on the names of the properties with the data for the properties. It will not build an array for you. I think you are trying to do too much in one Bean - how about making a Bean correspond to a single user, then have it check for legal data from the form properties. If all is well, pass that Bean to another class responsible for keeping the collection of users. Bill
I think you are trying to do too much in one Bean - how about making a Bean correspond to a single user, then have it check for legal data from the form properties. If all is well, pass that Bean to another class responsible for keeping the collection of users.
Hi Thanks for the response. As an aside I think your exam cram book is great, I'd love to comment on the others but it's the only one I've got. I guess I mislead you with my example, the real reason I am trying to process multiple forms with useBean is because if I have a User object that contains multiple Lottery Tickets, get populated in one command. (setProperty). I guess I'll have to stop trying to be so lazy and do it the long way. Thank again.
Originally posted by William Brogden: If I understand what you are trying to do - it isn't possible. Only one <form> .. </form> at a time can be submitted in a request.
BTW, I have never done this before but the logic seems ok.. it should work!