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 does struts handle dynamic forms that grow and its retrieval? 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 does struts handle dynamic forms that grow and its retrieval?" Watch "How does struts handle dynamic forms that grow and its retrieval?" New topic
Author

How does struts handle dynamic forms that grow and its retrieval?

John Zwick
Ranch Hand

Joined: Mar 02, 2009
Posts: 34
I have a page where a user can create an account using a form. Inside the form there is a table where they can add form elements (both text boxes and drop downs) dynamically using javascript to add as many new rows of inputs as the user wants.
I understand that when the input properties are stored as an array in the form bean, struts will automatically handle the inputs and set then into the appropriate arrays. However, when the user wants to "edit" their account, I have to display those rows of inputs they entered when they created the account. How does struts handle the order , will they be in the same order as the user entered? How do I tell the jsp to generate the x amount of input rows and populate each row correctly with what the user intially entered?
Pavel Kazlou
Ranch Hand

Joined: Sep 07, 2009
Posts: 33
Well, you should specify which version of Struts you use. It seems like Struts 1 (you use "form bean"). For generating input boxes use logic tags
http://struts.apache.org/1.2.9/userGuide/struts-logic.html
in the scope of each iteration you can access the element and its value.
 
jQuery in Action, 2nd edition
 
subject: How does struts handle dynamic forms that grow and its retrieval?