• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form field population done right

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic