Reputation: 2060
I have just started learning struts. Most of the tutorials I read, it mentions capturing data using an ActionForm. ie. Performing a http post request with a form filled with data.
However, upon the initial loading of the form, populating of the dropdown boxes etc. How should I retrieve the data and populate to the view?
By saving the ArrayList to the request attribute and iterate it on the jsp.
Setting the ArrayList to a corresponding string[] array in the ActionForm.
Which is the correct / better implementation approach?
Upvotes: 0
Views: 229
Reputation: 160191
Two options:
I prefer to use the ActionForm
only for form input data, but there are just as many people that say it should be used for anything in the form, including drop-down values.
(Some say it should be used for everything on a page, but they're clearly mad.)
Keeping data out of ActionForm
s reduces framework coupling. This may make a transition to a modern framework that expects data to live in scoped attributes, either free-form or in a model object.
Upvotes: 0
Reputation: 240900
in your Action
class you can fetch the data using services and store it in a List
which is a property of a Form
Upvotes: 1