Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple forms in Struts

 
Matthew Anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a simple Struts app that's connected to a DB. I can search for an "employee" and now I want to add the functionality to add an employee, so I have two buttons in a JSP page. When I come to the Action/controller page, how can I know which button that has been pressed, i.e, which form that is populated? Can I set a variable in the JSP page, or what kind of info can I retrieve from the JSP page.

Thanks,
Mattias
 
rahul khanna
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than having buttons If you can have two hyperlinks that would solve the issue as you can call different actions..

If you have two buttons ..I am not sure .. but try enclosing them in two different forms within the same jsp..
 
Matthew Anderson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this solution: http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24165.html

/Matt
[ July 04, 2007: Message edited by: Code Exception ]
 
Ranjit Gopinathan
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you have a look at LookUpDispatchAction or DispatchAction.

I believe, that will solve your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic