Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple forms - one jsp

 
M. Sigler
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a dilemma on how to handle two forms on one jsp page. The first form is basically a header with a drop down list in it. I have a form bean and an action mapping for that. The second form is a display of users from the database again with its own form bean and action mapping. Ultimately if the user changes the information on the drop down list the report under it will change as well, but I am not sure how I can get the data from the drop down list into the second form.

If I try to retrieve anything in the second action form that has to do with the first then I get a null pointer exception.

Do I need to set something up in my struts-config.xml that allows them to talk to each other or do I need to do something totally different?

Melissa
 
John Smith
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using your action class to extend LookupDispatchAction instead of action, this class is made for multiple submit buttons. You can have one big form with two different submit buttons, it will call your class and jump to the appropriate execute method depending on which submit button was clicked. Sounds a little tricky but the struts API shows you exactly what you need to have in your action class to set this up, it's really quite easy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic