| Author |
form field population done right
|
Pranav Sharma
Ranch Hand
Joined: Oct 27, 2003
Posts: 254
|
|
I'am populating a form by getting data from the database. In the action I instantiate myform, set form data and call return forward as following. ACTION 1 in the JSP i have But the form is not populated. Now if I put the form in session scope request.getSession().setAttribute("data",myForm); and in the jsp call <html:text name="data" property="data1"> this works but I dont want to add my forms to session scope because I have many and also I think this also gives me the following problem when I hit my "next" link the form that i get in the action is empty. thanks
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
|
The execute method of your Action has an ActionForm parameter for a reason. It is not necessary to instantiate forms. Define your form for the ActionMapping in your struts-config. Using this method, and if you use the html:form tag, the name attribute of your html: tags is no longer necessary. This will prevent a lot of confusing errors like the one you're having.
|
A good workman is known by his tools.
|
 |
Pranav Sharma
Ranch Hand
Joined: Oct 27, 2003
Posts: 254
|
|
Thanks Marc. I still have a doubt on this, The ActionForm in the Action is from the previous page(right?), and if I'am trying to set values for a form on the next jsp, would I not have to do the above to populate. (if not could you point me in the right direction with a general outline of what you have said above in terms of dummy code) also i find that the next action gets an empty actionform because i'am using <a href="ViewData4.do?dispatch=prev&page=dis1"> link. Maybe I will have to use a submit button, or can I use <html:link> to achieve the above
|
 |
 |
|
|
subject: form field population done right
|
|
|