Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to submit a form like this, using struts?

 
jaman tai
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form having 3 buttons. One is �Approve�, one is �Reject� and one is �Back�. If click Approve, update db directly and back. If click �Reject�, pup up a small window to ask the reject reason. (I am using javascript�s windows.open) after input the reason and click �go�, close the small window, update db and the original page goes back. If click �Back�, go back directly. How can I design this page? I know a little about LookupDispatchAction. Can anybody help me? Thanks a lot!
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Struts forum...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this, I'd use DispatchAction rather than LookupDispatchAction. The main reason for using LookupDispatchAction over DispatchAction is that it allows you to avoid using JavaScript. Since you have to pop up a window, you have to use JavaScript anyway.

Here's what I'd do:

1-Code an Action extending DispatchAction with accept() reject() and back() methods.
2-Put a hidden field in your JSP named "actionCode" with a corresponding property in your ActionForm.
3-Specify parameter="actionCode" when you define the action path.
4-When any of the buttons are pressed, use JavaScript to change the value of actionCode appropriately and submit the form.
5-In the case of a reject, code a hidden field named "rejectReason" in your main JSP. When the user presses the reject button, pop up the window. When the user presses go on the popup window, use JavaScript to populate the rejectReason field, change the actionCode appropriately, submit the form, and close the popup window.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic